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.