cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Convert Base64 to HEX

ADORAISWAMY
New Contributor II

I am working on a Snaplogic pipeline to copy data from Oracle to Snowflake. A few tables at source have BLOB column which needs to be copied. Snaplogic sees them as โ€œBase64 encoded dataโ€ but Snowflake needs the data in HEX format. I would like to know if its possible to convert the data as required and load into Snowflake tables. Iโ€™ve attached a sample pipeline.
TEST_2021_06_18.slp (7.1 KB)

17 REPLIES 17

bojanvelevski
Valued Contributor

Hi @ADORAISWAMY ,

There is an irregular mapping in your sample pipeline,

image

This way you are mapping a target path. If you are trying to encode the CONTENT in Base64 format, you should set the mapping like this:

image

Hi Bojan,
Thank you for responding. Since I am converting from base64 to HEX, I need to use โ€œbase64.decodeโ€ function. But that doesnโ€™t seem to work. I have attached the error.

Screen Shot 2021-06-21 at 9.24.29 AM

Appreciate your help.

ADORAISWAMY
New Contributor II

Bojan,

I am not sure what Snaplogic is trying to tell me here. One one hand, the output view from the Oracle SELECT shows the data as โ€œbase64 encided dataโ€โ€ฆ

Screen Shot 2021-06-21 at 11.04.49 AM

But again, when I try to decode the data in the mapper snap, it says the data is not a valid base64 data, which is contradictoryโ€ฆ

Screen Shot 2021-06-21 at 11.04.16 AM

Can you please advise a course of action ? Thanks.

Iโ€™m afraid the SnapLogic UI is rather misleading here. When you see โ€œBase64 encoded dataโ€ for a fieldโ€™s content in the preview output, it really means that the field contains binary data (an array of bytes). If it were really Base64 encoded data, you would just see a string containing the Base64 encoding of the binary data. I think this is because the UI is reflecting the representation of the preview data itโ€™s getting from the control plane, rather than the actual raw data being passed between snaps.

So, the $CONTENT field from Oracle is the binary data itself โ€“ a byte array. How were you planning on hex-encoding that? I donโ€™t believe that our expression language provides a hex encoding function similar to the Base64.encode() function it provides.