<?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 Re: Datetime conversion on streaming tables in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131655#M2236</link>
    <description>&lt;P&gt;Agreed. There is nothing wrong with the above code as well. Logically it should result in the same value.&lt;BR /&gt;I am seeing problem when running this as a sql model through dbt.&lt;/P&gt;&lt;P&gt;I tried 10 runs consecutively and it gave me the wrong outputs again and again (not the databricks cell run). On the 11th run the same code results in a different output. Is this kind of a bug or something ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Sep 2025 13:37:23 GMT</pubDate>
    <dc:creator>singh_tushar_14</dc:creator>
    <dc:date>2025-09-11T13:37:23Z</dc:date>
    <item>
      <title>Datetime conversion on streaming tables</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131648#M2234</link>
      <description>&lt;P&gt;I am using streaming tables to read from multiple parquet files and create a table in my raw layer.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Tech Stack&lt;/STRONG&gt; -- &lt;EM&gt;&lt;STRONG&gt;dbt-databricks&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;While loading I have a column called "ets" in my source which is nothing "milliseconds since Jan 1st 1970."&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want this to be converted into a timestamp format for which I use&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timestampadd(millisecond, ets, '1970-01-01')

ets = 1746046131518
expected_output = 2025-04-30T20:48:51.518+00:00
actual_output = 1969-12-08T18:54:02.046+00:00&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;Running it as a dry code on databricks notebook gives the correct output but when compiled through dbt and ran as a model same code gives a different output.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DBT Model code&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SELECT
    *,
    {{ dbt.dateadd("MILLISECOND", "ets", "'1970-01-01'") }} AS ets_converted,
    {{ add_metadata_fields() }}
FROM STREAM read_files(
    'path/to/volume',
    format =&amp;gt; 'parquet',
    header =&amp;gt; TRUE
)&lt;/LI-CODE&gt;&lt;P&gt;Compiled DBT Code from Databricks.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE STREAMING TABLE `catalog_name`.`schema_name`.`table_name` (&amp;lt;inferredSchema&amp;gt;)
SELECT
  *,
  timestampadd(MILLISECOND, ets, '1970-01-01') AS ets_converted,
  CURRENT_TIMESTAMP() AS meta_loaded_at
FROM
  STREAM read_files(
    'path/to/volumes',
    format =&amp;gt; 'parquet',
    header =&amp;gt; TRUE
  )&lt;/LI-CODE&gt;&lt;P&gt;I am not able to make an assumption is this thing wrong with dbt or streaming table or code.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2025 13:01:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131648#M2234</guid>
      <dc:creator>singh_tushar_14</dc:creator>
      <dc:date>2025-09-11T13:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime conversion on streaming tables</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131653#M2235</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/184146"&gt;@singh_tushar_14&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Since your ets columns already contains integer that represents&amp;nbsp;&lt;SPAN&gt;milliseconds since Jan 1st 1970, can't you just use Spark SQL fuction? You don't need to add anything to&amp;nbsp;1970-01-01, since that information is already "encoded" in your ets attribute:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%sql SELECT timestamp_millis(1746046131518)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="szymon_dybczak_0-1757597163490.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/19913iCD8A1670E0F789D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="szymon_dybczak_0-1757597163490.png" alt="szymon_dybczak_0-1757597163490.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2025 13:26:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131653#M2235</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2025-09-11T13:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime conversion on streaming tables</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131655#M2236</link>
      <description>&lt;P&gt;Agreed. There is nothing wrong with the above code as well. Logically it should result in the same value.&lt;BR /&gt;I am seeing problem when running this as a sql model through dbt.&lt;/P&gt;&lt;P&gt;I tried 10 runs consecutively and it gave me the wrong outputs again and again (not the databricks cell run). On the 11th run the same code results in a different output. Is this kind of a bug or something ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2025 13:37:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131655#M2236</guid>
      <dc:creator>singh_tushar_14</dc:creator>
      <dc:date>2025-09-11T13:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime conversion on streaming tables</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131660#M2237</link>
      <description>&lt;P&gt;Maybe there's something wrong with datatypes? Could you provide data type of that column?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Sep 2025 13:48:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131660#M2237</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2025-09-11T13:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime conversion on streaming tables</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131728#M2238</link>
      <description>&lt;P&gt;Datatype - BIGINT. Sample Data&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ets = 1754013182959&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 Sep 2025 05:12:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/datetime-conversion-on-streaming-tables/m-p/131728#M2238</guid>
      <dc:creator>singh_tushar_14</dc:creator>
      <dc:date>2025-09-12T05:12:46Z</dc:date>
    </item>
  </channel>
</rss>

