Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Rekha1
Contributor III
Contributor III

Salesforce to snowflake ingestion converting datetime to PST on TMC cloud

Hi,

I have a job to load data from salesforce to snowflake which is working as expected in local machine.

However when I deploy the job in TMC, we can only run on cloud (not on remote engine) due to firewall issue.

On TMC when i run the job, all the date columns which are in UTC in salesorce are converted to PST. I dont have any conversions in my job.

Using dynamic schema in the job. Any pointers would be appreciated. The job is already in production and needs to be fixed asap.

0695b00000OE1g2AAD.png

0695b00000OE1g7AAD.png

0695b00000OE1gHAAT.png

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable

I've experienced this issue. It's a pain, but it is caused by the timestamp type of the Snowflake column. I'm going to guess that your column timestamp type is TIMESTAMP_NTZ. This is "wall clock time" and essentially stores the time without considering timezone. I suspect you are also using a US based Cloud engine (which will be set to PST time). Salesforce always returns the time in UTC. What happens is that is read by Talend and sent to Snowflake as "wall clock time". This results in the incorrect time being kept in Snowflake. There are a couple of ways to deal with this. The first (and easiest) is to change your column type to TIMESTAMP_LTZ. This should be all you need to do and it should just work. Just in case you aren't aware of the default Snowflake timezone, you should test this by querying your timestamp column using "convert_timezone" to convert it to UTC like this....

 

convert_timezone(‘UTC’,TIMESTAMPCOL) 

 

The Snowflake timestamp types are described below....

 

https://docs.snowflake.com/en/sql-reference/data-types-datetime.html#timestamp-ltz-timestamp-ntz-timestamp-tz

 

The other way to mitigate for this is to change the JVM timezone to UTC before you read the data and then alter the JVM timezone to the default timezone of your Snowflake. This is clumsy and not ideal. But it does work. You can do that like below in tJava....

 

//Change JVM timezone to UTC

java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("UTC"));

 

//Change JVM timezone to PST

java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("America/Los_Angeles"));

 

Have a play with this and see which way works best for you.

View solution in original post

1 Reply
Anonymous
Not applicable

I've experienced this issue. It's a pain, but it is caused by the timestamp type of the Snowflake column. I'm going to guess that your column timestamp type is TIMESTAMP_NTZ. This is "wall clock time" and essentially stores the time without considering timezone. I suspect you are also using a US based Cloud engine (which will be set to PST time). Salesforce always returns the time in UTC. What happens is that is read by Talend and sent to Snowflake as "wall clock time". This results in the incorrect time being kept in Snowflake. There are a couple of ways to deal with this. The first (and easiest) is to change your column type to TIMESTAMP_LTZ. This should be all you need to do and it should just work. Just in case you aren't aware of the default Snowflake timezone, you should test this by querying your timestamp column using "convert_timezone" to convert it to UTC like this....

 

convert_timezone(‘UTC’,TIMESTAMPCOL) 

 

The Snowflake timestamp types are described below....

 

https://docs.snowflake.com/en/sql-reference/data-types-datetime.html#timestamp-ltz-timestamp-ntz-timestamp-tz

 

The other way to mitigate for this is to change the JVM timezone to UTC before you read the data and then alter the JVM timezone to the default timezone of your Snowflake. This is clumsy and not ideal. But it does work. You can do that like below in tJava....

 

//Change JVM timezone to UTC

java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("UTC"));

 

//Change JVM timezone to PST

java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("America/Los_Angeles"));

 

Have a play with this and see which way works best for you.