Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

PutDatabaseRecord into snowflake Variant field

avatar
Explorer

I am trying to read a json field from mySQL using executeSQLRecord and insert into snowflake VARIANT field type using PutDataBaseRecord in NiFi 2.6.0.

its giving me this error "

03:20:05 UTC

ERROR

1695731e-9b6f-3cb8-5a9a-98ab38589597

PutDatabaseRecord[id=1695731e-9b6f-3cb8-5a9a-98ab38589597] Failed to put Records to database for FlowFile[filename=c6087904-71a5-479c-9301-2c99883f5f59]. Routing to failure.: net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:

Expression type does not match column data type, expecting VARIANT but got VARCHAR(2) for column JSON_STORE

"

how do I fix this? 

1 REPLY 1

avatar
Master Collaborator

Hello @Samya, 

Thanks for joining our community. 

That issue is happening because JSON_STORE format is VARCHAR(2), not VARIANT as required. 

Something you can try is to add a ConvertRecord processor before the PutDatabaseRecord. 
There, you can use a JsonTreeReader → JsonRecordSetWriter to reformat the content. In that way, the JSON_STORE field becomes a proper JSON object.

vafs_0-1763047465364.png

vafs_1-1763047516379.png

Something like this👆


Regards,
Andrés Fallas
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs-up button.