Skip to main content
Solved

setting parentExternaliD as an empty string, "" and not as NULL

  • May 2, 2024
  • 1 reply
  • 23 views

Forum|alt.badge.img+4

Busy with training module:

Data Engineer Basics - Transform and Contextualize > CDF Transformations > Assets transformation

I have the following SQL:

 

The Preview works:

 

But, doing Run, leads to an error.

So, of course the NULL in the 1st row above ought to be   “ “ for the root asset.

Q1. How do I test for NULL and set NULL value to “ ” in the Spark SQL query?

Thank you!

Regards,

Doug

 

 

 

Best answer by Sofie Haug

Hi @Mugless Durry 

you can use a IF statement, like: 

 

IF(parent_loc_id='' OR parent_loc_id IS NULL, '', parent_loc_id) AS parentExternalId,

 

View original
Did this topic help you find an answer to your question?

1 reply

Sofie Haug
Practitioner
Forum|alt.badge.img+7
  • Cognite Academy Instructor
  • 151 replies
  • Answer
  • May 2, 2024

Hi @Mugless Durry 

you can use a IF statement, like: 

 

IF(parent_loc_id='' OR parent_loc_id IS NULL, '', parent_loc_id) AS parentExternalId,

 


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings