<?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 federated queries on PostgreSQL - TimestampNTZ option in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119073#M45790</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to migrate some spark reads away from JDBC into the federated queries based in unity catalog.&lt;/P&gt;&lt;P&gt;Here is an example of the spark read command that I want to migrate:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;spark.read.&lt;/SPAN&gt;&lt;SPAN&gt;format&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"jdbc"&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"driver"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"org.postgresql.Driver"&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"url"&lt;/SPAN&gt;&lt;SPAN&gt;, url).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"user"&lt;/SPAN&gt;&lt;SPAN&gt;, user).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"password"&lt;/SPAN&gt;&lt;SPAN&gt;, password).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"query"&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;, query)&lt;STRONG&gt;.option("&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;preferTimestampNTZ", True&lt;/STRONG&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;load&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;SPAN&gt;That "preferTimestampNTZ" option is really important because I have many table columns in the source that timestamps without timezone and are not in UTC.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Problem is that I cannot find in the documentation on how to set up the catalog to leverage this option.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;The closest that I can find is at the bottom of this link here:&amp;nbsp;&lt;A href="https://docs.databricks.com/aws/en/query-federation/postgresql?language=SQL" target="_blank" rel="noopener"&gt;Run federated queries on PostgreSQL | Databricks Documentation&lt;/A&gt;&amp;nbsp;but that doesn't explain how that option can be applied.&lt;/P&gt;&lt;P&gt;Here is an example of how I want the future queries to look like:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;spark.table("postgres_catalog.postgres_database.postgres_table")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone know?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank You&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 13 May 2025 17:05:33 GMT</pubDate>
    <dc:creator>thomas_berry</dc:creator>
    <dc:date>2025-05-13T17:05:33Z</dc:date>
    <item>
      <title>federated queries on PostgreSQL - TimestampNTZ option</title>
      <link>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119073#M45790</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to migrate some spark reads away from JDBC into the federated queries based in unity catalog.&lt;/P&gt;&lt;P&gt;Here is an example of the spark read command that I want to migrate:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;spark.read.&lt;/SPAN&gt;&lt;SPAN&gt;format&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"jdbc"&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"driver"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"org.postgresql.Driver"&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"url"&lt;/SPAN&gt;&lt;SPAN&gt;, url).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"user"&lt;/SPAN&gt;&lt;SPAN&gt;, user).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"password"&lt;/SPAN&gt;&lt;SPAN&gt;, password).&lt;/SPAN&gt;&lt;SPAN&gt;option&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"query"&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;, query)&lt;STRONG&gt;.option("&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;preferTimestampNTZ", True&lt;/STRONG&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;load&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;SPAN&gt;That "preferTimestampNTZ" option is really important because I have many table columns in the source that timestamps without timezone and are not in UTC.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Problem is that I cannot find in the documentation on how to set up the catalog to leverage this option.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;The closest that I can find is at the bottom of this link here:&amp;nbsp;&lt;A href="https://docs.databricks.com/aws/en/query-federation/postgresql?language=SQL" target="_blank" rel="noopener"&gt;Run federated queries on PostgreSQL | Databricks Documentation&lt;/A&gt;&amp;nbsp;but that doesn't explain how that option can be applied.&lt;/P&gt;&lt;P&gt;Here is an example of how I want the future queries to look like:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;spark.table("postgres_catalog.postgres_database.postgres_table")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone know?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank You&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 13 May 2025 17:05:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119073#M45790</guid>
      <dc:creator>thomas_berry</dc:creator>
      <dc:date>2025-05-13T17:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: federated queries on PostgreSQL - TimestampNTZ option</title>
      <link>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119076#M45791</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/47963"&gt;@thomas_berry&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's a common challenge when transitioning from Spark JDBC reads to Unity Catalog federated tables, especially when dealing with timestamp types.&lt;BR /&gt;This option is specific to the JDBC data source and tells Spark to treat timestamp columns without timezone as TIMESTAMP_NTZ (no time zone) instead of defaulting to TIMESTAMP (which is UTC by default).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Federated Tables in Unity Catalog&lt;/STRONG&gt;&lt;BR /&gt;When you migrate to Unity Catalog federated tables, the underlying mechanics change:&lt;BR /&gt;-- You're no longer using spark.read.format("jdbc") — Databricks uses SQL pushdown via connectors in foreign catalogs.&lt;BR /&gt;-- These are managed metadata tables that automatically sync schemas and push down query execution to the external system (PostgreSQL in your case).&lt;BR /&gt;-- Because you're querying them via spark.table("...") or SQL (SELECT * FROM ...), you're using Databricks SQL dialect, not raw JDBC options.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;No Option for preferTimestampNTZ:&lt;/STRONG&gt;&lt;BR /&gt;Currently, Unity Catalog does not expose a documented setting like preferTimestampNTZ=True for federated PostgreSQL connections.&lt;BR /&gt;Instead, Databricks does automatic type inference, and by default:&lt;BR /&gt;-- PostgreSQL’s timestamp without time zone is mapped to TIMESTAMP (UTC) in Databricks.&lt;BR /&gt;-- If your data is not in UTC, this mapping can silently shift your values unless you apply manual conversion logic (e.g., using from_utc_timestamp()).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Workarounds:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;1. Manually adjust time zones in queries&lt;/STRONG&gt;&lt;BR /&gt;If your timestamps are in a known local timezone (say "America/New_York"), you can do:&lt;/P&gt;&lt;P&gt;In SQL:&lt;BR /&gt;SELECT from_utc_timestamp(your_column, 'America/New_York') FROM postgres_catalog.db.table&lt;/P&gt;&lt;P&gt;Or in PySpark:&lt;BR /&gt;from pyspark.sql.functions import from_utc_timestamp&lt;BR /&gt;df = spark.table("postgres_catalog.db.table").withColumn("local_ts", from_utc_timestamp("your_column", "America/New_York"))&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. Use Views to Abstract the Logic&lt;/STRONG&gt;&lt;BR /&gt;If this transformation is needed in many places, create views in Unity Catalog that do this adjustment:&lt;/P&gt;&lt;P&gt;CREATE VIEW postgres_catalog.db.adjusted_table AS&lt;BR /&gt;SELECT from_utc_timestamp(ts_col, 'America/New_York') as ts_col_local, ...&lt;BR /&gt;FROM postgres_catalog.db.raw_table&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;3. Keep JDBC reads where necessary&lt;/STRONG&gt;&lt;BR /&gt;If your timestamp logic is critical and cannot be centralized via views, you may need to keep JDBC reads for&lt;BR /&gt;certain use cases until Databricks exposes a control for this behavior in Unity Catalog.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Federated tables abstract away many low-level controls (like JDBC options) to simplify cross-source querying&lt;BR /&gt;— but that means some fine-grained behaviors are lost, especially those related to timezone-sensitive data types.&lt;BR /&gt;Until Databricks adds an equivalent of preferTimestampNTZ to foreign catalog configurations,&lt;BR /&gt;you'll need to handle these cases explicitly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 May 2025 18:01:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119076#M45791</guid>
      <dc:creator>lingareddy_Alva</dc:creator>
      <dc:date>2025-05-13T18:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: federated queries on PostgreSQL - TimestampNTZ option</title>
      <link>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119129#M45803</link>
      <description>&lt;P&gt;Thank you for your reply. I will mark your answer as accepted solution but I hope that in the future this options, as you explained, gets added!&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 08:21:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119129#M45803</guid>
      <dc:creator>thomas_berry</dc:creator>
      <dc:date>2025-05-14T08:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: federated queries on PostgreSQL - TimestampNTZ option</title>
      <link>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119211#M45817</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/47963"&gt;@thomas_berry&lt;/a&gt;&amp;nbsp;I hope so&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 May 2025 15:46:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/federated-queries-on-postgresql-timestampntz-option/m-p/119211#M45817</guid>
      <dc:creator>lingareddy_Alva</dc:creator>
      <dc:date>2025-05-14T15:46:10Z</dc:date>
    </item>
  </channel>
</rss>

