<?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: CREATE TEMP TABLE FROM CTE in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/create-temp-table-from-cte/m-p/64318#M32534</link>
    <description>&lt;P&gt;Just want to say that you for replying to this. Just spent hours trying to figure out why my query wasn't working and this did the trick.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2024 17:55:29 GMT</pubDate>
    <dc:creator>jmorris</dc:creator>
    <dc:date>2024-03-21T17:55:29Z</dc:date>
    <item>
      <title>CREATE TEMP TABLE FROM CTE</title>
      <link>https://community.databricks.com/t5/data-engineering/create-temp-table-from-cte/m-p/11747#M6681</link>
      <description>&lt;P&gt;I have written a CTE in Spark SQL &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WITH temp_data AS (
&amp;nbsp;
......
&amp;nbsp;
)
&amp;nbsp;
CREATE VIEW AS temp_view FROM SELECT * FROM temp_view; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get a cryptic error. Is there a way to create a temp view from CTE using Spark SQL in databricks? &lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 02:46:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/create-temp-table-from-cte/m-p/11747#M6681</guid>
      <dc:creator>Constantine</dc:creator>
      <dc:date>2021-11-03T02:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TEMP TABLE FROM CTE</title>
      <link>https://community.databricks.com/t5/data-engineering/create-temp-table-from-cte/m-p/11749#M6683</link>
      <description>&lt;P&gt;In the CTE you can't do a CREATE.  &lt;/P&gt;&lt;P&gt;It expects an expression in the form of &lt;I&gt;expression_name [ ( column_name [ , ... ] ) ] [ AS ] ( query )&lt;/I&gt;&lt;/P&gt;&lt;P&gt;where expression_name specifies a name for the common table expression.&lt;/P&gt;&lt;P&gt;If you want to create a view from a CTE, you can do this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;-- CTE in CREATE VIEW statement
CREATE VIEW v AS
    WITH t(a, b, c, d) AS (SELECT 1, 2, 3, 4)
    SELECT * FROM t;
SELECT * FROM v;
+---+---+---+---+
|  a|  b|  c|  d|
+---+---+---+---+
|  1|  2|  3|  4|
+---+---+---+---+&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS. snippet from the &lt;A href="http://spark.apache.org/docs/latest/sql-ref-syntax-qry-select-cte.html" alt="http://spark.apache.org/docs/latest/sql-ref-syntax-qry-select-cte.html" target="_blank"&gt;Spark documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Nov 2021 07:08:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/create-temp-table-from-cte/m-p/11749#M6683</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2021-11-03T07:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: CREATE TEMP TABLE FROM CTE</title>
      <link>https://community.databricks.com/t5/data-engineering/create-temp-table-from-cte/m-p/64318#M32534</link>
      <description>&lt;P&gt;Just want to say that you for replying to this. Just spent hours trying to figure out why my query wasn't working and this did the trick.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 17:55:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/create-temp-table-from-cte/m-p/64318#M32534</guid>
      <dc:creator>jmorris</dc:creator>
      <dc:date>2024-03-21T17:55:29Z</dc:date>
    </item>
  </channel>
</rss>

