12-03-2020 12:50 PM
Hey All,
So I’m trying to load certain columns from a csv file into snowflake, but facing some issues.
I have the file, properly parsed it via the csv parser, and I’ve also used a mapper to map the columns properly. However, I need snaplogic to be able to do tell snowflake, if the entry in this row says “(null)” or “(None)” to treat it as a NULL insert in the bulk load.
Is there a way to do this?
For example, say I have a snowflake DB with column that accepts only 1 char, a Y or N. The row from the dataset has a “(null)” as the entry for that column, which is causing an issue since it is > 1 char. Is there a way for snaplogic to understand “(null)” means NULL and insert a NULL into snowflake via the bulk load snap?
Thank you!
12-03-2020 03:12 PM
Just curious If you have checked this option Load empty strings on the Snowflake Bulk load Snap.
12-03-2020 03:43 PM
@amubeen There are two ways that you can handle this use case
2.The null values coming from a csv parser will be a string. A condition in the mapper to convert the null String values to null will work:
$NULLABLECHAR == “null” ? null : $NULLABLECHAR
cc: @robin
12-10-2020 02:21 PM
@amubeen Were you able to resolve your issue with the above information ?
12-11-2020 01:05 PM
Hi @amubeen,
You’d better use multiple checks when it comes to nulls from csv file. It can be an empty string, or NULL or null or Null or (null), , etc.
One way is this:
($NULLABLECHAR == ““ || $NULLABLECHAR.toLowerCase().indexOf(‘null’) > -1) ? null : $NULLABLECHAR
However, settings can help you also, but if you fully trust the csv incoming data (e.g. always having null, but not (null) which is different)
/Igor