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

Transformation rules inside mapper snap not exported to output file

darshthakkar
Valued Contributor

Hi Team,

I have found one of the transformational rules applied on โ€œdate fieldโ€ not getting exported to the final output file (i.e. excel file) when the pipeline has been executed.
Output preview on the snap does show the right data (i.e. expected one), pipeline validation also shows the right data however the file which gets generated after pipeline execution doesnโ€™t get those details.

I have tried the following:

  • validated pipeline via shift+validate
  • tweak the transformation rule, save the pipeline and check the output in the preview
  • validated the preview file (with default 50 records)
  • deleted the file generated by โ€œvalidate & executeโ€ snap on File writer with default 50 records so that new instance of data comes in
  • executed the pipeline with different file name multiple times

Itโ€™s a simple pipeline consisting of

            Snowflake Execute --> Mapper --> Excel Formatter --> File Writer

Sharing some screenshots to help it understand better:
(1) Pipeline with 4 snaps
image

(2) Snowflake execute output preview in JSON format (highlighted yellow fields needs transformation)
image

(3) Transformation Rules on Date fields
image

(4) Transformation Rule: $Expire_Date.toString().replace('{Timestamp=',"").replace('.000+0000}',"Z")

image

(5) Output preview after transformational rule
image

(6) Mapper output preview shows different data
image

โ†’ Iโ€™ve observed certain times that the transformation rules wonโ€™t work so I go inside the mapper, modify the rule a bit, bring it back to default rule so that I can save it (save is not enabled if there is no change thus this workaround)

(7) As shift+validate didnโ€™t work, had to change the transformation rule, save it and then this is the output preview on mapper snap:
image

(8) Settings under excel formatter snap for reference:
image

(9) Settings under File Writer snap for reference:
image

(10) File generated with default 50 records due to validate & execute on File writer snap
image

(11) Downloaded the file that gets generated in step 10 and below is the output (expected)
image

(12) Executed Pipeline
image

(13) Output File of Executed pipeline
image


image


image

Iโ€™ve seen this happening numerous times particularly to fields containing timestamp in other pipelines too, am I doing something wrong over here? Any settings that needs to be changed either in Mapper, Excel Formatter or File Writer snap?

Thanking in advance for your valuable time and suggestions on this one.

Best Regards,
DT

1 ACCEPTED SOLUTION

ptaylor
Employee
Employee

The Snowflake snaps have a setting called Handle Timestamp and Date Time Data. Unfortunately, its default setting, Default Date Time format in UTC Time Zone, has less-than-ideal behavior. The object type of the timestamp objects is java.sql.Timestamp, which will result in the odd inconsistencies youโ€™re seeing between validation vs execution, and itโ€™s also not a very usable type on the SnapLogic expression language.

I suggest changing this setting to the other option, SnapLogic Date Time format in Regional Time Zone. This will convert the timestamps to the type org.joda.time.DateTime, the type that the SnapLogic EL functions are designed to deal with.

This option will also produce a DateTime with the default time zone of the plex node, which can complicate things if the nodeโ€™s default timezone isnโ€™t UTC. But based on what youโ€™ve shown, your nodeโ€™s default timezone is UTC, so this shouldnโ€™t be a problem for you, fortunately.

After changing that setting, try using an expression like $Expire_Date.toLocaleDateTimeString({format: "yyyy-MM-dd'T'HH:mm:ss'Z'"}).

Hope that helps.

View solution in original post

23 REPLIES 23

darshthakkar
Valued Contributor

This worked! Thank you, Robin.

image

However, the exported file has no values under dates, screenshot below for your convenience:

image

Just for my understanding, why would the Expire_Date not give us the same results? Is it because itโ€™s an object vs Expire_Date.Timestamp a string? (Q-1)

Moreover, $Expire_Date.toString().replace('{Timestamp=',"").replace('.000+0000}',"Z") did give us the expected results during output preview of the snap and after validating the pipeline however the transformation didnโ€™t work when the pipeline was executed, what would be the rationale behind it? (Q-2)

I want to understand this in details so that I can learn snapLogic in a better fashion and be a good snapLogic developer. Please donโ€™t get me wrong.

Best Regards,
Darsh

In addition to this,

Output preview is different on the field and mapper snap, screenshots below:

image

image

image

Isnโ€™t this strange as the same snap which shows a preview as expected output in one of the fields shows a null when doing a sanity check on the entire snap.

@darshthakkar You can check the setup of excel formatter. But I would suggest go with CSV formatter rather excel formatter , and create file with .csv extension.

!
image

Thank you, @Supratim for the suggestion.
If you check my previous responses, Iโ€™ve tried both with excel and csv formatter and it doesnโ€™t work. Iโ€™ve also shared the screenshots of excel formatter in my first comment which can be accessed here

Moreover, I want an excel file and not csv.

darshthakkar
Valued Contributor

Providing a summary of the transformational rules applied so far:

1. $Expire_Date.toString().replace('{Timestamp=',"").replace('.000+0000}',"Z") โ†’ Output Preview [works expected] โ†’ Exported Excel File [transformation rules donโ€™t appear to work]

2. $Expire_Date.toLocaleDateTimeString({format: "yyyy-MM-dd'T'HH:mm:ss'Z'"}) โ†’ Output Preview [shows Null values] โ†’ Exported Excel File [all blank values]

3. Date.parse($Expire_Date.Timestamp).toLocaleDateTimeString({format: "yyyy-MM-dd'T'HH:mm:ss'Z'"}) โ†’ Output preview [works expected] โ†’ Exported Excel File [all blank values]