<?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 Cannot use Delta Table columns containing struct with date fields in Power BI in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/cannot-use-delta-table-columns-containing-struct-with-date/m-p/83437#M36932</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I have a Delta Table in Databricks with a column of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;struct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;type (containing a field of type&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;date) and a column of type&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;date:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;create&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; date_struct (s struct&lt;SPAN class=""&gt;&amp;lt;&lt;/SPAN&gt;d:&lt;SPAN class=""&gt;date&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt;, d &lt;SPAN class=""&gt;date&lt;/SPAN&gt;, s_json string);
&lt;SPAN class=""&gt;insert&lt;/SPAN&gt; &lt;SPAN class=""&gt;into&lt;/SPAN&gt; date_struct (s, d, s_json) &lt;SPAN class=""&gt;values&lt;/SPAN&gt; (
    named_struct(&lt;SPAN class=""&gt;'d'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;'2020-01-01'&lt;/SPAN&gt;), 
    &lt;SPAN class=""&gt;'2020-02-01'&lt;/SPAN&gt;, 
    to_json(named_struct(&lt;SPAN class=""&gt;'d'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;'2020-01-01'&lt;/SPAN&gt;)))&lt;/PRE&gt;&lt;P&gt;When importing this&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;date_struct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;table from Power BI, I get the following result (the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column is mapped to a string and the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;d&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column is mapped to a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;date):&lt;/P&gt;&lt;DIV class=""&gt;s d s_json &lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;{"d":2020-01-01}&lt;/TD&gt;&lt;TD&gt;01/02/2020&lt;/TD&gt;&lt;TD&gt;{"d":"2020-01-01"}&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;The value of the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column is a malformed JSON format (missing quotes on date&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;2020-01-01). As the JSON is malformed, the Power BI function&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Json.Document()&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;cannot be used to convert the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;string column into a JSON document e.g. when adding a new column. However, the same conversion works without error on the pre-serialized&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s_json&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;let&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;Source&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Databricks&lt;/SPAN&gt;.&lt;SPAN class=""&gt;Catalogs&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"xxx.azuredatabricks.net"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"/sql/1.0/warehouses/yyy"&lt;/SPAN&gt;, [&lt;SPAN class=""&gt;Catalog&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;""&lt;/SPAN&gt;, &lt;SPAN class=""&gt;Database&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;""&lt;/SPAN&gt;]),
    my_Database &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Source&lt;/SPAN&gt;{[&lt;SPAN class=""&gt;Name&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"my"&lt;/SPAN&gt;,&lt;SPAN class=""&gt;Kind&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Database"&lt;/SPAN&gt;]}[&lt;SPAN class=""&gt;Data&lt;/SPAN&gt;],
    delta_tutorial_Schema &lt;SPAN class=""&gt;=&lt;/SPAN&gt; my_Database{[&lt;SPAN class=""&gt;Name&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"myschema"&lt;/SPAN&gt;,&lt;SPAN class=""&gt;Kind&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Schema"&lt;/SPAN&gt;]}[&lt;SPAN class=""&gt;Data&lt;/SPAN&gt;],
    ds1 &lt;SPAN class=""&gt;=&lt;/SPAN&gt; delta_tutorial_Schema{[&lt;SPAN class=""&gt;Name&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"date_struct"&lt;/SPAN&gt;,&lt;SPAN class=""&gt;Kind&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Table"&lt;/SPAN&gt;]}[&lt;SPAN class=""&gt;Data&lt;/SPAN&gt;],
    ds2 &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Table&lt;/SPAN&gt;.&lt;SPAN class=""&gt;AddColumn&lt;/SPAN&gt;(ds1, &lt;SPAN class=""&gt;"record_from_s"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;each&lt;/SPAN&gt; &lt;SPAN class=""&gt;Json&lt;/SPAN&gt;.&lt;SPAN class=""&gt;Document&lt;/SPAN&gt;([s])),
    ds3 &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Table&lt;/SPAN&gt;.&lt;SPAN class=""&gt;AddColumn&lt;/SPAN&gt;(ds2, &lt;SPAN class=""&gt;"record_from_s_json"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;each&lt;/SPAN&gt; &lt;SPAN class=""&gt;Json&lt;/SPAN&gt;.&lt;SPAN class=""&gt;Document&lt;/SPAN&gt;([s_json]))
&lt;SPAN class=""&gt;in&lt;/SPAN&gt;
    ds3&lt;/PRE&gt;&lt;P&gt;gives the following error:&lt;/P&gt;&lt;DIV class=""&gt;s d record_from_s record_from_s_json &lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;{"d":2020-01-01}&lt;/TD&gt;&lt;TD&gt;01/02/2020&lt;/TD&gt;&lt;TD&gt;Error&lt;/TD&gt;&lt;TD&gt;Record&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;PRE&gt;DataFormat.&lt;SPAN class=""&gt;Error&lt;/SPAN&gt;: We found extra characters at the &lt;SPAN class=""&gt;end&lt;/SPAN&gt; &lt;SPAN class=""&gt;of&lt;/SPAN&gt; the JSON input.
&lt;SPAN class=""&gt;Details:&lt;/SPAN&gt;
    Value=-
    Position=&lt;SPAN class=""&gt;9&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;What can I do to access the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s.d&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field ?&lt;/P&gt;&lt;P&gt;Note that the above is a minimal example in order to reproduce the problem. The real use-case is another table with a much more complex&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;struct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and no pre-serialized&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s_json&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column. Thus, I want a reliable solution, not something like "use Json.Document() on the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s_json&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column" or "&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/Error-While-parsing-JSON/td-p/2997153" target="_blank" rel="nofollow noopener noreferrer"&gt;add quotes on the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column with the Replace function&lt;/A&gt;".&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Stackoverflow post:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/78879730/date-fields-are-serialized-without-quotes-when-imported-databricks-delta-table-w" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/78879730/date-fields-are-serialized-without-quotes-when-imported-databricks-delta-table-w&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2024 12:23:43 GMT</pubDate>
    <dc:creator>Julien_Kronegg</dc:creator>
    <dc:date>2024-08-19T12:23:43Z</dc:date>
    <item>
      <title>Cannot use Delta Table columns containing struct with date fields in Power BI</title>
      <link>https://community.databricks.com/t5/data-engineering/cannot-use-delta-table-columns-containing-struct-with-date/m-p/83437#M36932</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I have a Delta Table in Databricks with a column of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;struct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;type (containing a field of type&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;date) and a column of type&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;date:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;create&lt;/SPAN&gt; &lt;SPAN class=""&gt;table&lt;/SPAN&gt; date_struct (s struct&lt;SPAN class=""&gt;&amp;lt;&lt;/SPAN&gt;d:&lt;SPAN class=""&gt;date&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt;, d &lt;SPAN class=""&gt;date&lt;/SPAN&gt;, s_json string);
&lt;SPAN class=""&gt;insert&lt;/SPAN&gt; &lt;SPAN class=""&gt;into&lt;/SPAN&gt; date_struct (s, d, s_json) &lt;SPAN class=""&gt;values&lt;/SPAN&gt; (
    named_struct(&lt;SPAN class=""&gt;'d'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;'2020-01-01'&lt;/SPAN&gt;), 
    &lt;SPAN class=""&gt;'2020-02-01'&lt;/SPAN&gt;, 
    to_json(named_struct(&lt;SPAN class=""&gt;'d'&lt;/SPAN&gt;, &lt;SPAN class=""&gt;'2020-01-01'&lt;/SPAN&gt;)))&lt;/PRE&gt;&lt;P&gt;When importing this&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;date_struct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;table from Power BI, I get the following result (the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column is mapped to a string and the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;d&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column is mapped to a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;date):&lt;/P&gt;&lt;DIV class=""&gt;s d s_json &lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;{"d":2020-01-01}&lt;/TD&gt;&lt;TD&gt;01/02/2020&lt;/TD&gt;&lt;TD&gt;{"d":"2020-01-01"}&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;The value of the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column is a malformed JSON format (missing quotes on date&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;2020-01-01). As the JSON is malformed, the Power BI function&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Json.Document()&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;cannot be used to convert the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;string column into a JSON document e.g. when adding a new column. However, the same conversion works without error on the pre-serialized&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s_json&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;let&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;Source&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Databricks&lt;/SPAN&gt;.&lt;SPAN class=""&gt;Catalogs&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"xxx.azuredatabricks.net"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"/sql/1.0/warehouses/yyy"&lt;/SPAN&gt;, [&lt;SPAN class=""&gt;Catalog&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;""&lt;/SPAN&gt;, &lt;SPAN class=""&gt;Database&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;""&lt;/SPAN&gt;]),
    my_Database &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Source&lt;/SPAN&gt;{[&lt;SPAN class=""&gt;Name&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"my"&lt;/SPAN&gt;,&lt;SPAN class=""&gt;Kind&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Database"&lt;/SPAN&gt;]}[&lt;SPAN class=""&gt;Data&lt;/SPAN&gt;],
    delta_tutorial_Schema &lt;SPAN class=""&gt;=&lt;/SPAN&gt; my_Database{[&lt;SPAN class=""&gt;Name&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"myschema"&lt;/SPAN&gt;,&lt;SPAN class=""&gt;Kind&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Schema"&lt;/SPAN&gt;]}[&lt;SPAN class=""&gt;Data&lt;/SPAN&gt;],
    ds1 &lt;SPAN class=""&gt;=&lt;/SPAN&gt; delta_tutorial_Schema{[&lt;SPAN class=""&gt;Name&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"date_struct"&lt;/SPAN&gt;,&lt;SPAN class=""&gt;Kind&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Table"&lt;/SPAN&gt;]}[&lt;SPAN class=""&gt;Data&lt;/SPAN&gt;],
    ds2 &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Table&lt;/SPAN&gt;.&lt;SPAN class=""&gt;AddColumn&lt;/SPAN&gt;(ds1, &lt;SPAN class=""&gt;"record_from_s"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;each&lt;/SPAN&gt; &lt;SPAN class=""&gt;Json&lt;/SPAN&gt;.&lt;SPAN class=""&gt;Document&lt;/SPAN&gt;([s])),
    ds3 &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;Table&lt;/SPAN&gt;.&lt;SPAN class=""&gt;AddColumn&lt;/SPAN&gt;(ds2, &lt;SPAN class=""&gt;"record_from_s_json"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;each&lt;/SPAN&gt; &lt;SPAN class=""&gt;Json&lt;/SPAN&gt;.&lt;SPAN class=""&gt;Document&lt;/SPAN&gt;([s_json]))
&lt;SPAN class=""&gt;in&lt;/SPAN&gt;
    ds3&lt;/PRE&gt;&lt;P&gt;gives the following error:&lt;/P&gt;&lt;DIV class=""&gt;s d record_from_s record_from_s_json &lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;{"d":2020-01-01}&lt;/TD&gt;&lt;TD&gt;01/02/2020&lt;/TD&gt;&lt;TD&gt;Error&lt;/TD&gt;&lt;TD&gt;Record&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;PRE&gt;DataFormat.&lt;SPAN class=""&gt;Error&lt;/SPAN&gt;: We found extra characters at the &lt;SPAN class=""&gt;end&lt;/SPAN&gt; &lt;SPAN class=""&gt;of&lt;/SPAN&gt; the JSON input.
&lt;SPAN class=""&gt;Details:&lt;/SPAN&gt;
    Value=-
    Position=&lt;SPAN class=""&gt;9&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;What can I do to access the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s.d&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field ?&lt;/P&gt;&lt;P&gt;Note that the above is a minimal example in order to reproduce the problem. The real use-case is another table with a much more complex&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;struct&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and no pre-serialized&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s_json&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column. Thus, I want a reliable solution, not something like "use Json.Document() on the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s_json&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column" or "&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/Error-While-parsing-JSON/td-p/2997153" target="_blank" rel="nofollow noopener noreferrer"&gt;add quotes on the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;s&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column with the Replace function&lt;/A&gt;".&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Stackoverflow post:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/78879730/date-fields-are-serialized-without-quotes-when-imported-databricks-delta-table-w" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/78879730/date-fields-are-serialized-without-quotes-when-imported-databricks-delta-table-w&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 12:23:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/cannot-use-delta-table-columns-containing-struct-with-date/m-p/83437#M36932</guid>
      <dc:creator>Julien_Kronegg</dc:creator>
      <dc:date>2024-08-19T12:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use Delta Table columns containing struct with date fields in Power BI</title>
      <link>https://community.databricks.com/t5/data-engineering/cannot-use-delta-table-columns-containing-struct-with-date/m-p/139664#M51258</link>
      <description>&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;To access the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;s.d&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;field from your Delta table in Power BI, you need the content of the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;s&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column to be correctly formatted as JSON so that Power BI's&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;Json.Document()&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;function can parse it. Your issue arises because the default string representation of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;struct&amp;lt;d:date&amp;gt;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in Databricks returns&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;{"d":2020-01-01}&lt;/CODE&gt;, which is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;not valid JSON&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;since string values—like dates—need to be quoted:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;{"d":"2020-01-01"}&lt;/CODE&gt;.&lt;/P&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;s_json&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column works fine because it uses&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;to_json()&lt;/CODE&gt;, which produces a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;properly quoted&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;JSON string, unlike the default cast of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;struct&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to string.&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Why This Happens&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Databricks&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;generates a simplified, spark-internal JSON-like representation for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;struct&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;values when you SELECT or export them directly, not standard JSON (dates are not in quotes).&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Power BI's&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;Json.Document()&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;requires strict JSON compliance: string values must be quoted.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Solutions&lt;/H2&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;1. Use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;to_json()&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in Your Databricks Views/Queries&lt;/H2&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Ensure that the data you supply to Power BI for complex columns like structs is always pre-serialized to a valid JSON string.&lt;/P&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;For example, in your Databricks SQL, use:&lt;/P&gt;
&lt;DIV class="w-full md:max-w-[90vw]"&gt;
&lt;DIV class="codeWrapper text-light selection:text-super selection:bg-super/10 my-md relative flex flex-col rounded-lg font-mono text-sm font-normal bg-subtler"&gt;
&lt;DIV class="translate-y-xs -translate-x-xs bottom-xl mb-xl flex h-0 items-start justify-end md:sticky md:top-[calc(var(--header-height)+var(--size-xs))]"&gt;
&lt;DIV class="overflow-hidden rounded-full border-subtlest ring-subtlest divide-subtlest bg-base"&gt;
&lt;DIV class="border-subtlest ring-subtlest divide-subtlest bg-subtler"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="-mt-xl"&gt;
&lt;DIV&gt;
&lt;DIV class="text-quiet bg-subtle py-xs px-sm inline-block rounded-br rounded-tl-lg text-xs font-thin" data-testid="code-language-indicator"&gt;sql&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;CODE&gt;&lt;SPAN class="token token"&gt;SELECT&lt;/SPAN&gt; to_json&lt;SPAN class="token token punctuation"&gt;(&lt;/SPAN&gt;s&lt;SPAN class="token token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token token"&gt;as&lt;/SPAN&gt; s_json&lt;SPAN class="token token punctuation"&gt;,&lt;/SPAN&gt; d &lt;SPAN class="token token"&gt;FROM&lt;/SPAN&gt; date_struct
&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;And then let Power BI use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;s_json&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;column, as it already does in your example. This is the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cleanest and most reliable approach&lt;/STRONG&gt;.&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;2. Modify Power BI M Query to Parse the Malformed JSON&lt;/H2&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;If you cannot change your Databricks view/table, you can&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;fix the malformed JSON in Power BI&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;before calling&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;Json.Document()&lt;/CODE&gt;. You can substitute the date pattern without quotes, e.g.:&lt;/P&gt;
&lt;DIV class="w-full md:max-w-[90vw]"&gt;
&lt;DIV class="codeWrapper text-light selection:text-super selection:bg-super/10 my-md relative flex flex-col rounded-lg font-mono text-sm font-normal bg-subtler"&gt;
&lt;DIV class="translate-y-xs -translate-x-xs bottom-xl mb-xl flex h-0 items-start justify-end md:sticky md:top-[calc(var(--header-height)+var(--size-xs))]"&gt;
&lt;DIV class="overflow-hidden rounded-full border-subtlest ring-subtlest divide-subtlest bg-base"&gt;
&lt;DIV class="border-subtlest ring-subtlest divide-subtlest bg-subtler"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="-mt-xl"&gt;
&lt;DIV&gt;
&lt;DIV class="text-quiet bg-subtle py-xs px-sm inline-block rounded-br rounded-tl-lg text-xs font-thin" data-testid="code-language-indicator"&gt;text&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;CODE&gt;let
    // previous steps,
    FixedS = Table.TransformColumns(ds1, {
        "s", each Text.Replace(Text.From(_), "2020-01-01", """2020-01-01"""), type text}
    ),
    AddedRecord = Table.AddColumn(FixedS, "record_from_s", each Json.Document([s]))
in
    AddedRecord
&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;However, this approach is fragile because it only covers known date values and structures. It's much better to fix this at the source using&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;to_json()&lt;/CODE&gt;.&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;3. Project Struct Fields Directly&lt;/H2&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;If you just need a field like&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;s.d&lt;/CODE&gt;, select it directly in your SQL:&lt;/P&gt;
&lt;DIV class="w-full md:max-w-[90vw]"&gt;
&lt;DIV class="codeWrapper text-light selection:text-super selection:bg-super/10 my-md relative flex flex-col rounded-lg font-mono text-sm font-normal bg-subtler"&gt;
&lt;DIV class="translate-y-xs -translate-x-xs bottom-xl mb-xl flex h-0 items-start justify-end md:sticky md:top-[calc(var(--header-height)+var(--size-xs))]"&gt;
&lt;DIV class="overflow-hidden rounded-full border-subtlest ring-subtlest divide-subtlest bg-base"&gt;
&lt;DIV class="border-subtlest ring-subtlest divide-subtlest bg-subtler"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="-mt-xl"&gt;
&lt;DIV&gt;
&lt;DIV class="text-quiet bg-subtle py-xs px-sm inline-block rounded-br rounded-tl-lg text-xs font-thin" data-testid="code-language-indicator"&gt;sql&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;CODE&gt;&lt;SPAN class="token token"&gt;SELECT&lt;/SPAN&gt; s&lt;SPAN class="token token punctuation"&gt;.&lt;/SPAN&gt;d&lt;SPAN class="token token punctuation"&gt;,&lt;/SPAN&gt; d &lt;SPAN class="token token"&gt;FROM&lt;/SPAN&gt; date_struct
&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;This gives a flat table without needing JSON conversion.&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Recommendation&lt;/H2&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;STRONG&gt;Always use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;to_json()&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in your Databricks SQL when exporting struct columns to Power BI.&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;This guarantees your data is valid JSON and savable as a string, which can then be parsed by Power BI's&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;Json.Document()&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;with no issues.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 11:51:30 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/cannot-use-delta-table-columns-containing-struct-with-date/m-p/139664#M51258</guid>
      <dc:creator>mark_ott</dc:creator>
      <dc:date>2025-11-19T11:51:30Z</dc:date>
    </item>
  </channel>
</rss>

