<?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: Upgrading from Spark 2.4 to 3.2: Recursive view errors when using in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12398#M7213</link>
    <description>&lt;P&gt;This is a breaking change introduced in Spark 3.1 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From &lt;A href="https://spark.apache.org/docs/3.1.1/sql-migration-guide.html" alt="https://spark.apache.org/docs/3.1.1/sql-migration-guide.html" target="_blank"&gt;Migration Guide: SQL, Datasets and DataFrame - Spark 3.1.1 Documentation (apache.org)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Spark 3.1, the temporary view will have same behaviors with the permanent view, i.e. capture and store runtime SQL configs, SQL text, catalog and namespace. The capatured view properties will be applied during the parsing and analysis phases of the view resolution. To restore the behavior before Spark 3.1, &lt;B&gt;you can set spark.sql.legacy.storeAnalyzedPlanForView to true&lt;/B&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried setting &lt;B&gt;spark.sql.legacy.storeAnalyzedPlanForView to true &lt;/B&gt;and was able to restore the old behaviour.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Dec 2021 14:32:37 GMT</pubDate>
    <dc:creator>arkrish</dc:creator>
    <dc:date>2021-12-22T14:32:37Z</dc:date>
    <item>
      <title>Upgrading from Spark 2.4 to 3.2: Recursive view errors when using</title>
      <link>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12394#M7209</link>
      <description>&lt;P&gt;We get errors like this,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Recursive view `x` detected (cycle: `x` -&amp;gt; `x`)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.. in our long-term working code, that has worked just fine in Spark 2.4.5 (Runtime 6.4), when we run it on a Spark 3.2 cluster (Runtime 10.0).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It happens whenever we have,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;x is a Dataframe&amp;gt;&lt;/P&gt;&lt;P&gt;x.createOrReplaceTempView('x')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... in order to use Spark SQL such as,&lt;/P&gt;&lt;P&gt;y = spark.sql("""&lt;/P&gt;&lt;P&gt;    select ...&lt;/P&gt;&lt;P&gt;    from x&lt;/P&gt;&lt;P&gt;   ...&lt;/P&gt;&lt;P&gt;""")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems that the ('x') name of the &lt;/P&gt;&lt;P&gt;x.createOrReplaceTempView('x')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... needs to be globally unique and cannot be overwritten (even if the function "createOrReplaceTempView" has the word "replace" in it).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a fix for this issue in general without setting the global "spark.&amp;lt;something&amp;gt;.legacy" option? (We prefer to avoid that)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is no fix, our current cumbersome re-write would be to rewrite every   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x.createOrReplaceTempView('x')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;z = f'x_{timestamp_as_text_with_underscores}'&lt;/P&gt;&lt;P&gt;x.createOrReplaceTempView(z)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... and then ofc use it as,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;y = spark.sql("""&lt;/P&gt;&lt;P&gt;select ...&lt;/P&gt;&lt;P&gt;from z&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;""")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... such, but we would prefer a more elegant solution, if there is one?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 13:10:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12394#M7209</guid>
      <dc:creator>RasmusOlesen</dc:creator>
      <dc:date>2021-10-26T13:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Upgrading from Spark 2.4 to 3.2: Recursive view errors when using</title>
      <link>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12395#M7210</link>
      <description>&lt;P&gt;strange it should work as it is. Only other idea which I have is to check createOrReplaceGlobalTempView to use global database. createOrReplaceTempView is using "default" database maybe there were some issues with that during migration? You can create new spark database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;below functions can be also useful to diagnose problem:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;spark.catalog.listDatabases() 
spark.catalog.currentDatabase() 
spark.catalog.listTables('default')&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 13:28:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12395#M7210</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2021-10-26T13:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Upgrading from Spark 2.4 to 3.2: Recursive view errors when using</title>
      <link>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12396#M7211</link>
      <description>&lt;P&gt;Thanks a lot Hubert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could it be a bug where Spark 3.2's  createOrReplaceTempView&amp;nbsp;is accidentally calling/using the global database and not the/a "default" one?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We implemented a temp makeshift system where the names we register are unique via timestamps in the names and then used these dynamic names in the Spark SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again thanks for the expressions to check the registered names in the DB's! &lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 09:40:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12396#M7211</guid>
      <dc:creator>RasmusOlesen</dc:creator>
      <dc:date>2021-10-27T09:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Upgrading from Spark 2.4 to 3.2: Recursive view errors when using</title>
      <link>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12397#M7212</link>
      <description>&lt;P&gt;I'm experiencing the same problem on Spark 3.2.0 (not databricks). This was the only other reference to this problem I've found online. I've raised an issue in the main Spark project here: &lt;A href="https://issues.apache.org/jira/browse/SPARK-37690" alt="https://issues.apache.org/jira/browse/SPARK-37690" target="_blank"&gt;https://issues.apache.org/jira/browse/SPARK-37690&lt;/A&gt;.  There's a reproducible example that works in 2.x and 3.2.1 so I'm fairly confident this is an bug introduced in 3.2.0&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2021 07:54:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12397#M7212</guid>
      <dc:creator>RobinL</dc:creator>
      <dc:date>2021-12-20T07:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Upgrading from Spark 2.4 to 3.2: Recursive view errors when using</title>
      <link>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12398#M7213</link>
      <description>&lt;P&gt;This is a breaking change introduced in Spark 3.1 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From &lt;A href="https://spark.apache.org/docs/3.1.1/sql-migration-guide.html" alt="https://spark.apache.org/docs/3.1.1/sql-migration-guide.html" target="_blank"&gt;Migration Guide: SQL, Datasets and DataFrame - Spark 3.1.1 Documentation (apache.org)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Spark 3.1, the temporary view will have same behaviors with the permanent view, i.e. capture and store runtime SQL configs, SQL text, catalog and namespace. The capatured view properties will be applied during the parsing and analysis phases of the view resolution. To restore the behavior before Spark 3.1, &lt;B&gt;you can set spark.sql.legacy.storeAnalyzedPlanForView to true&lt;/B&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried setting &lt;B&gt;spark.sql.legacy.storeAnalyzedPlanForView to true &lt;/B&gt;and was able to restore the old behaviour.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 14:32:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/upgrading-from-spark-2-4-to-3-2-recursive-view-errors-when-using/m-p/12398#M7213</guid>
      <dc:creator>arkrish</dc:creator>
      <dc:date>2021-12-22T14:32:37Z</dc:date>
    </item>
  </channel>
</rss>

