<?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: Delta Live Tables error pivot in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21033#M14271</link>
    <description>&lt;P&gt;According to both &lt;A href="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-sql-ref.html" alt="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-sql-ref.html" target="_blank"&gt;SQL&lt;/A&gt; and &lt;A href="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-python-ref.html" alt="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-python-ref.html" target="_blank"&gt;Python&lt;/A&gt; DLT documentations, "pivot" is not supported in DLT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I wonder what are the complications of using "pivot" in such an unsupported way?&lt;/P&gt;</description>
    <pubDate>Fri, 07 Oct 2022 21:35:55 GMT</pubDate>
    <dc:creator>bozhu</dc:creator>
    <dc:date>2022-10-07T21:35:55Z</dc:date>
    <item>
      <title>Delta Live Tables error pivot</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21028#M14266</link>
      <description>&lt;P&gt;I'm facing an error in Delta Live Tables when I want to pivot a table. The error is the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1884iE9A74496A85E7E60/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the code to replicate the error is the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
import pyspark.sql.functions as F
&amp;nbsp;
pdf = pd.DataFrame({"A": ["foo", "foo", "foo", "foo", "foo",
                          "bar", "bar", "bar", "bar"],
                    "B": ["one", "one", "one", "two", "two",
                          "one", "one", "two", "two"],
                    "C": ["small", "large", "large", "small",
                          "small", "large", "small", "small",
                          "large"],
                    "D": [1, 2, 2, 3, 3, 4, 5, 6, 7],
                    "E": [2, 4, 5, 5, 6, 6, 8, 9, 9]})
df = spark.createDataFrame(pdf)
df.write.mode('overwrite').saveAsTable('test_table')
&amp;nbsp;
import dlt
&amp;nbsp;
@dlt.view
def test_table():
    return spark.read.table('test_table')
&amp;nbsp;
@dlt.table
def test_table_pivoted():
    return (
        spark.table('LIVE.test_table')
        .groupBy('A', 'B')
        .pivot('C')
        .agg(F.first('D'))
    )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Does anybody know why I can not pivot a table in Delta Live Tables Pipelines?&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 08:54:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21028#M14266</guid>
      <dc:creator>mangel</dc:creator>
      <dc:date>2022-05-10T08:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Delta Live Tables error pivot</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21029#M14267</link>
      <description>&lt;P&gt;Can you try passing in the column names as a second argument to the pivot function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;.pivot('C', ["small", "large"])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 15:41:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21029#M14267</guid>
      <dc:creator>ccary</dc:creator>
      <dc:date>2022-05-14T15:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: Delta Live Tables error pivot</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21031#M14269</link>
      <description>&lt;P&gt;Hi, this would only make the query run faster, thanks for the try. I will post below the solution I found to this issue.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 13:36:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21031#M14269</guid>
      <dc:creator>mangel</dc:creator>
      <dc:date>2022-07-07T13:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delta Live Tables error pivot</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21032#M14270</link>
      <description>&lt;P&gt;The solution seems to add the following configuration to the Delta Live Tables Pipeline:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.databricks.delta.schema.autoMerge.enabled: true&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It allows "schema evolution" in the pipeline and solves the problem.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 13:39:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21032#M14270</guid>
      <dc:creator>mangel</dc:creator>
      <dc:date>2022-07-07T13:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Delta Live Tables error pivot</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21033#M14271</link>
      <description>&lt;P&gt;According to both &lt;A href="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-sql-ref.html" alt="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-sql-ref.html" target="_blank"&gt;SQL&lt;/A&gt; and &lt;A href="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-python-ref.html" alt="https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-python-ref.html" target="_blank"&gt;Python&lt;/A&gt; DLT documentations, "pivot" is not supported in DLT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I wonder what are the complications of using "pivot" in such an unsupported way?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2022 21:35:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21033#M14271</guid>
      <dc:creator>bozhu</dc:creator>
      <dc:date>2022-10-07T21:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delta Live Tables error pivot</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21034#M14272</link>
      <description>&lt;P&gt;It's said in the DLT documentation that&amp;nbsp;"pivot" is not supported in DLT but I noticed that if you want the pivot function to work you have to do one of the the following things:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;B&gt;apply the pivot in your first a dlt.view&lt;/B&gt; + the config "&lt;B&gt;spark.databricks.delta.schema.autoMerge.enabled: true&lt;/B&gt;" .&lt;/LI&gt;&lt;LI&gt;apply pivot outside of dlt decorators then start using the output in dlt.view or dlt.table.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: I noticed that this works but you get a warning saying that `&lt;B&gt;GroupedData.pivot` function that will be deprecated soon, &lt;/B&gt;you will have the same warning if you use Collect for instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that help!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 13:36:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/21034#M14272</guid>
      <dc:creator>Khalil</dc:creator>
      <dc:date>2023-04-19T13:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Delta Live Tables error pivot</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/84423#M37192</link>
      <description>&lt;P&gt;I'm a bit of a muppet, it's implied but took be a second to figure out that you need to write it like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spark.conf.set("spark.databricks.delta.schema.autoMerge.enabled", "true")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 14:43:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/84423#M37192</guid>
      <dc:creator>JackyL</dc:creator>
      <dc:date>2024-08-27T14:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Delta Live Tables error pivot</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/100888#M40463</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Was this a specific design choice to not allow Pivots in DLT? I'm under the impression they expect fixed table structures in DLT design for a reason, but I don't understand the reason?&amp;nbsp;&lt;BR /&gt;Conceptually, I understand the fixed structures makes lineage &amp;amp; quality checks easier to maintain, but is it really a hard constraint? Does applying the above solution lead to issues in the lineage views?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2024 10:39:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-tables-error-pivot/m-p/100888#M40463</guid>
      <dc:creator>Michiel_Povre</dc:creator>
      <dc:date>2024-12-04T10:39:05Z</dc:date>
    </item>
  </channel>
</rss>

