Skip to main content
Answer

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

  • May 2, 2024
  • 1 reply
  • 30 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,

 

1 reply

Sofie Haug
Seasoned Practitioner
Forum|alt.badge.img+12
  • Cognite Academy Instructor
  • 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,