<?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: Retrieving OBJECT values with the JDBC driver may lead to invalid JSON in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/retrieving-object-values-with-the-jdbc-driver-may-lead-to/m-p/136564#M50592</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/122653"&gt;@EricCournarie&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I believe this is a JDBC driver limitation. The Databricks JDBC driver serializes complex types (STRUCT/ARRAY) to a JSON-like string but doesn’t always quote DATE/TIMESTAMP (and some characters) correctly, so rs.getObject()/rs.getString() can yield invalid JSON.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Similar thread:&amp;nbsp;&lt;/STRONG&gt;&lt;A href="https://stackoverflow.com/questions/79432459/how-to-fetch-nested-data-structures-in-databricks-using-jdbc" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/79432459/how-to-fetch-nested-data-structures-in-databricks-using-jdbc&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;One way to fix this is to serialise on the server with &lt;STRONG&gt;to_json&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary"&gt;
&lt;DIV class="overflow-y-auto p-4" dir="ltr"&gt;&lt;LI-CODE lang="python"&gt;SELECT
  id,
  nom,
  to_json(infos, map('dateFormat','yyyy-MM-dd','timestampFormat','yyyy-MM-dd HH:mm:ss.SSS')) AS infos_json,
  to_json(tags) AS tags_json
FROM main.eric.eric_complex_team;​&lt;/LI-CODE&gt;&lt;CODE class="whitespace-pre! language-sql"&gt;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="overflow-y-auto p-4" dir="ltr"&gt;&lt;CODE class="whitespace-pre! language-sql"&gt;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="overflow-y-auto p-4" dir="ltr"&gt;&lt;CODE class="whitespace-pre! language-sql"&gt;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Wed, 29 Oct 2025 15:05:04 GMT</pubDate>
    <dc:creator>K_Anudeep</dc:creator>
    <dc:date>2025-10-29T15:05:04Z</dc:date>
    <item>
      <title>Retrieving OBJECT values with the JDBC driver may lead to invalid JSON</title>
      <link>https://community.databricks.com/t5/data-engineering/retrieving-object-values-with-the-jdbc-driver-may-lead-to/m-p/136550#M50590</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Using the JDBC driver , I try to retrieve values in the ResultSet for a OBJECT type.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sadly, it returns invalid JSON&lt;/P&gt;&lt;P&gt;Given the SQL&lt;/P&gt;&lt;PRE&gt;CREATE OR REPLACE TABLE main.eric.eric_complex_team (&lt;BR /&gt;`id` INT,&lt;BR /&gt;`nom` STRING,&lt;BR /&gt;`infos` STRUCT&amp;lt;`age`: INT, `ville`: STRING, `genre`: BOOLEAN, `anniv`: DATE, `vma`: DECIMAL(3,1), `temps`: TIMESTAMP_NTZ&amp;gt;,&lt;BR /&gt;`tags` ARRAY&amp;lt;STRING&amp;gt;&lt;BR /&gt;);&lt;BR /&gt;INSERT INTO main.eric.eric_complex_team VALUES&lt;BR /&gt;(1, 'Manon', named_struct('age', 30, 'ville', 'Paris', 'genre', true, 'anniv', '1995-10-12', 'vma', 17.4, 'temps', '2025-10-29 12:12:12.789'), array('elite', 'science')),&lt;BR /&gt;(2, 'Paul', named_struct('age', 25, 'ville', 'Lyon', 'genre', false, 'anniv', '2000-09-12', 'vma', 19.6, 'temps', '2025-10-29 12:10:12.234'), array('dev', 'elite'));&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;The value returned by rs.getObject() is something like&lt;/P&gt;&lt;PRE&gt;{"age":30,"ville":"Paris","genre":true,"anniv":1995-10-12,"vma":17.4,"temps":2025-10-29 12:12:12.789}&lt;/PRE&gt;&lt;P&gt;Dates are not quoted.&lt;/P&gt;&lt;P&gt;Is there an opened bug or a workaround ?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Oct 2025 13:15:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/retrieving-object-values-with-the-jdbc-driver-may-lead-to/m-p/136550#M50590</guid>
      <dc:creator>EricCournarie</dc:creator>
      <dc:date>2025-10-29T13:15:38Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving OBJECT values with the JDBC driver may lead to invalid JSON</title>
      <link>https://community.databricks.com/t5/data-engineering/retrieving-object-values-with-the-jdbc-driver-may-lead-to/m-p/136564#M50592</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/122653"&gt;@EricCournarie&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I believe this is a JDBC driver limitation. The Databricks JDBC driver serializes complex types (STRUCT/ARRAY) to a JSON-like string but doesn’t always quote DATE/TIMESTAMP (and some characters) correctly, so rs.getObject()/rs.getString() can yield invalid JSON.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Similar thread:&amp;nbsp;&lt;/STRONG&gt;&lt;A href="https://stackoverflow.com/questions/79432459/how-to-fetch-nested-data-structures-in-databricks-using-jdbc" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/79432459/how-to-fetch-nested-data-structures-in-databricks-using-jdbc&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;One way to fix this is to serialise on the server with &lt;STRONG&gt;to_json&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary"&gt;
&lt;DIV class="overflow-y-auto p-4" dir="ltr"&gt;&lt;LI-CODE lang="python"&gt;SELECT
  id,
  nom,
  to_json(infos, map('dateFormat','yyyy-MM-dd','timestampFormat','yyyy-MM-dd HH:mm:ss.SSS')) AS infos_json,
  to_json(tags) AS tags_json
FROM main.eric.eric_complex_team;​&lt;/LI-CODE&gt;&lt;CODE class="whitespace-pre! language-sql"&gt;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="overflow-y-auto p-4" dir="ltr"&gt;&lt;CODE class="whitespace-pre! language-sql"&gt;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;DIV class="overflow-y-auto p-4" dir="ltr"&gt;&lt;CODE class="whitespace-pre! language-sql"&gt;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 Oct 2025 15:05:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/retrieving-object-values-with-the-jdbc-driver-may-lead-to/m-p/136564#M50592</guid>
      <dc:creator>K_Anudeep</dc:creator>
      <dc:date>2025-10-29T15:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving OBJECT values with the JDBC driver may lead to invalid JSON</title>
      <link>https://community.databricks.com/t5/data-engineering/retrieving-object-values-with-the-jdbc-driver-may-lead-to/m-p/136573#M50593</link>
      <description>&lt;P&gt;Hello, &amp;nbsp;thanks for the quick response .&lt;BR /&gt;&lt;BR /&gt;Sadly I do not have the hand on the SQL request , so no way for me to modify it ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Oct 2025 15:43:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/retrieving-object-values-with-the-jdbc-driver-may-lead-to/m-p/136573#M50593</guid>
      <dc:creator>EricCournarie</dc:creator>
      <dc:date>2025-10-29T15:43:45Z</dc:date>
    </item>
  </channel>
</rss>

