Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
anushaya1512
Contributor III
Contributor III

Error "Error parsing json" while loading xml data in variant column in Snowflake

Hi 

Input = XML file

I want to load it into a variant column in Snowflake.

Below is the XML file:

 

<school school_name='School'>
<dept dept_id='100'>
<dept_Name>'Secondary'</dept_Name>
</dept>
<student id='1'>
<name>'ABC'</name>
<std>'10th'</std>
</student>
</school>

 

Code:

 

0683p000009M98H.png

 

 

 

 

0683p000009M9Ab.png

 

 

 

 

0683p000009M9Ag.png

 

 

 

0683p000009M96C.png

 

 

 

Can someone help here please?

Output should be the entire content of XML doc should be saved in the variant column.

Labels (5)
11 Replies
manodwhb
Champion II
Champion II

@anushaya1512 , what is the data type of XML_DATA in snowflake DB?

manodwhb
Champion II
Champion II

@anushaya1512 , If you remove the reject link,you will get the error. I believe the data types are not matching.

 

You may need to convert to string?

 

anushaya1512
Contributor III
Contributor III
Author

@manodwhb 

The data type in Snowflake for XML_DATA is variant

anushaya1512
Contributor III
Contributor III
Author

@manodwhb 

I tried with the document and string data type both. Still I get the same Error parsing XML error.

Check below screenshots.

 

Tried an Example with document data type at the initial level and string data type while loading:

0683p000009M6SY.png

 

 

 

 

 

0683p000009M8ss.png

 

 

 

Tried an Example with String data type throughout:

0683p000009M9BU.png

 

 

 

0683p000009M9BV.png

 

 

 

 

 

 

 

 

manodwhb
Champion II
Champion II

@anushaya1512 , if you have not take reject link the job will fail and will give the error. Can you share that.

 

manodwhb
Champion II
Champion II

@anushaya1512 , you can convert document data type to sting using .toString() function.

anushaya1512
Contributor III
Contributor III
Author

@manodwhb 

Just tried it, it doesn't help. 0683p000009MPcz.png

 

0683p000009M9Bj.png

manodwhb
Champion II
Champion II

@anushaya1512 ,can  you remove the reject part and run the job and share the error?

 

 

anushaya1512
Contributor III
Contributor III
Author

@manodwhb 

If I remove the reject part, the Snowflake component doesn't throw any error, shows the job has successfully completed, it kind off by passes the record.

 

Note: The snowflake db components, do not throw error for such records like the other DB components.

 

0683p000009M9Bo.png