How to configure Code Workbook's timezone for CURRENT_TIMESTAMP?

263 views Asked by At

How can I configure Code Workbooks's timezone such that calling CURRENT_TIMESTAMP in SQL returns my local time instead of the default UTC?

Are there any reasons this would be advised against?

1

There are 1 answers

0
Adil B On

Timestamps in Spark have no concept of timezones since they represent the number of microseconds since Unix epoch. I'm not aware of any Code Workbook setting to change this, but Spark likely uses the system clock of whatever host it executes the function on to determine what the current timestamp should be, and it wouldn't be possible to fiddle with those settings.

Sounds like what you're looking for is some function like from_utc_timestamp, which takes your timestamp in UTC and shifts it to your timezone. Note that your timestamp would still be timezone-agnostic, but if you were to print the string representation of your timestamp, it would now look like the wall-clock date/time in your local timezone.