I have a raw table from firebase in snowflake. All the information that I need is in the field "Data" (JSON). Because of that, I created a view to extract all the data in deferents columns.
I use json_extract_path_text(data, ‘createdAt’) to extract the createdAt timestamp. But, that function converts my data in a string like: {"_nanoseconds":248000000,"_seconds":1641850613}
.
I want to convert them to TIMESTAMP format in snowflake. Is there anyway to do it?
I try with TO_TIMESTAMP but doesn’t work.
2
Answers
TO_TIMESTAMP(integer) could be used:
Output:
You can use the TO_TIMESTAMP function as shown below but bear in mind that this works for seconds, as by default the timestamps in Snowflake will be treated as seconds (Deprecation Warning: Future versions of Snowflake might automatically interpret stringified integer values as seconds, rather than as milliseconds, microseconds, or nanoseconds.). For nanoseconds, you would need to divide it first by 10e9: