<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic from_utc_timestamp silently double-shifts time when session timezone isn't UTC — docs should call th in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/from-utc-timestamp-silently-double-shifts-time-when-session/m-p/162182#M55046</link>
    <description>&lt;P class=""&gt;&lt;STRONG&gt;Summary:&lt;/STRONG&gt;&lt;BR /&gt;from_utc_timestamp(current_timestamp(), '&amp;lt;tz&amp;gt;') produces an incorrect (future-shifted) timestamp whenever the Spark session timezone is already set to something other than UTC. This is a very common pattern for teams stamping dp_load_ts/created_at/audit columns, and the current docs don't warn against it.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Root cause:&lt;/STRONG&gt;&lt;BR /&gt;current_timestamp() returns the current time in the &lt;STRONG&gt;session's configured timezone&lt;/STRONG&gt; (spark.sql.session.timeZone / cluster timezone setting), not UTC. from_utc_timestamp(ts, tz) always treats its input ts as if it were UTC, regardless of what it actually is, and converts it into tz.&lt;/P&gt;&lt;P class=""&gt;So if a cluster's session timezone is set to Asia/Bangkok (UTC+7):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT current_timezone();
-- Asia/Bangkok

SELECT
  current_timestamp()                                    AS raw_ts,       -- correct Bangkok wall-clock time
  from_utc_timestamp(current_timestamp(), 'Asia/Bangkok') AS double_shifted -- Bangkok time + 7 more hours&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;double_shifted ends up 7 hours ahead of the actual current time, because current_timestamp() is already local, and from_utc_timestamp adds the offset a second time on top of it.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Why this matters:&lt;/STRONG&gt;&lt;BR /&gt;from_utc_timestamp(current_timestamp(), '&amp;lt;local tz&amp;gt;') is a very natural-looking pattern to write when a team wants a "load timestamp in our local timezone," and it's silently wrong whenever the session timezone isn't UTC. It produces no error — just a plausible-looking but incorrect future timestamp — so it can go unnoticed in production pipelines for a long time.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Suggested fix:&lt;/STRONG&gt;&lt;BR /&gt;Add an explicit warning/example on the from_utc_timestamp (and ideally current_timestamp()) doc pages, something like:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class=""&gt;&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt; from_utc_timestamp always assumes its input is UTC. If your session timezone (current_timezone()) is not UTC, do not pass current_timestamp() directly into from_utc_timestamp() — this will double-apply the timezone offset. If the session timezone already matches your target timezone, use current_timestamp() directly instead.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Jul 2026 05:52:08 GMT</pubDate>
    <dc:creator>rikkyvai</dc:creator>
    <dc:date>2026-07-08T05:52:08Z</dc:date>
    <item>
      <title>from_utc_timestamp silently double-shifts time when session timezone isn't UTC — docs should call th</title>
      <link>https://community.databricks.com/t5/data-engineering/from-utc-timestamp-silently-double-shifts-time-when-session/m-p/162182#M55046</link>
      <description>&lt;P class=""&gt;&lt;STRONG&gt;Summary:&lt;/STRONG&gt;&lt;BR /&gt;from_utc_timestamp(current_timestamp(), '&amp;lt;tz&amp;gt;') produces an incorrect (future-shifted) timestamp whenever the Spark session timezone is already set to something other than UTC. This is a very common pattern for teams stamping dp_load_ts/created_at/audit columns, and the current docs don't warn against it.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Root cause:&lt;/STRONG&gt;&lt;BR /&gt;current_timestamp() returns the current time in the &lt;STRONG&gt;session's configured timezone&lt;/STRONG&gt; (spark.sql.session.timeZone / cluster timezone setting), not UTC. from_utc_timestamp(ts, tz) always treats its input ts as if it were UTC, regardless of what it actually is, and converts it into tz.&lt;/P&gt;&lt;P class=""&gt;So if a cluster's session timezone is set to Asia/Bangkok (UTC+7):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT current_timezone();
-- Asia/Bangkok

SELECT
  current_timestamp()                                    AS raw_ts,       -- correct Bangkok wall-clock time
  from_utc_timestamp(current_timestamp(), 'Asia/Bangkok') AS double_shifted -- Bangkok time + 7 more hours&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;double_shifted ends up 7 hours ahead of the actual current time, because current_timestamp() is already local, and from_utc_timestamp adds the offset a second time on top of it.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Why this matters:&lt;/STRONG&gt;&lt;BR /&gt;from_utc_timestamp(current_timestamp(), '&amp;lt;local tz&amp;gt;') is a very natural-looking pattern to write when a team wants a "load timestamp in our local timezone," and it's silently wrong whenever the session timezone isn't UTC. It produces no error — just a plausible-looking but incorrect future timestamp — so it can go unnoticed in production pipelines for a long time.&lt;/P&gt;&lt;P class=""&gt;&lt;STRONG&gt;Suggested fix:&lt;/STRONG&gt;&lt;BR /&gt;Add an explicit warning/example on the from_utc_timestamp (and ideally current_timestamp()) doc pages, something like:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class=""&gt;&lt;span class="lia-unicode-emoji" title=":warning:"&gt;⚠️&lt;/span&gt; from_utc_timestamp always assumes its input is UTC. If your session timezone (current_timezone()) is not UTC, do not pass current_timestamp() directly into from_utc_timestamp() — this will double-apply the timezone offset. If the session timezone already matches your target timezone, use current_timestamp() directly instead.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jul 2026 05:52:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/from-utc-timestamp-silently-double-shifts-time-when-session/m-p/162182#M55046</guid>
      <dc:creator>rikkyvai</dc:creator>
      <dc:date>2026-07-08T05:52:08Z</dc:date>
    </item>
  </channel>
</rss>

