<?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: Running SQL Data File through Notebook Python in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/running-sql-data-file-through-notebook-python/m-p/25825#M18026</link>
    <description>&lt;P&gt;Hi @Marco Perez​,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to share the following doc &lt;A href="https://docs.databricks.com/external-data/snowflake.html#query-a-snowflake-table-in-databricks" target="test_blank"&gt;https://docs.databricks.com/external-data/snowflake.html#query-a-snowflake-table-in-databricks&lt;/A&gt; in here you will be able to find example code on how to read data using databricks&lt;/P&gt;</description>
    <pubDate>Fri, 28 Oct 2022 21:58:45 GMT</pubDate>
    <dc:creator>jose_gonzalez</dc:creator>
    <dc:date>2022-10-28T21:58:45Z</dc:date>
    <item>
      <title>Running SQL Data File through Notebook Python</title>
      <link>https://community.databricks.com/t5/data-engineering/running-sql-data-file-through-notebook-python/m-p/25824#M18025</link>
      <description>&lt;P&gt;I am attempting to run larger sql scripts through Databricks Notbook and export data to a file. For the most part the Notebook works when the sql script is a single SELECT statement. However, if the sql file is more complicated such as involving the use of creating a temporary/volatile table, inserting data to it, updating it, and then exporting the results it fails as shown below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am able to run the SQL script without any issues on Snowflake, but when establishing a connection though Databricks it just doesn't want to run and I do not understand the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%python
&amp;nbsp;
#Full SQL script runs on Snowflake, but seems to have issues here
&amp;nbsp;
with open('/dbfs/FileStore/myid/prjX_sf.sql', 'r') as sqlFile:  #ERROR, create temp table, insert data, update temp table, select statement
&amp;nbsp;
#with open('/dbfs/FileStore/myid/prjX_simple.sql', 'r') as sqlFile: #WORKS, select statement only
&amp;nbsp;
  sql_script = sqlFile.read()
&amp;nbsp;
&amp;nbsp;
#Read data from Snowflake table
df = spark.read \
 .format("snowflake") \
 .options(**conn) \
 .option("query", sql_script) \
 .load()
display(df)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:&lt;/P&gt;&lt;P&gt;Py4JJavaError: An error occurred while calling o3645.load.&lt;/P&gt;&lt;P&gt;: net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:&lt;/P&gt;&lt;P&gt;syntax error line 1 at position 15 unexpected 'DROP'.&lt;/P&gt;&lt;P&gt;syntax error line 285 at position 63 unexpected ')'.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 22:08:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/running-sql-data-file-through-notebook-python/m-p/25824#M18025</guid>
      <dc:creator>Marco9898</dc:creator>
      <dc:date>2022-10-25T22:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Running SQL Data File through Notebook Python</title>
      <link>https://community.databricks.com/t5/data-engineering/running-sql-data-file-through-notebook-python/m-p/25825#M18026</link>
      <description>&lt;P&gt;Hi @Marco Perez​,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to share the following doc &lt;A href="https://docs.databricks.com/external-data/snowflake.html#query-a-snowflake-table-in-databricks" target="test_blank"&gt;https://docs.databricks.com/external-data/snowflake.html#query-a-snowflake-table-in-databricks&lt;/A&gt; in here you will be able to find example code on how to read data using databricks&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 21:58:45 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/running-sql-data-file-through-notebook-python/m-p/25825#M18026</guid>
      <dc:creator>jose_gonzalez</dc:creator>
      <dc:date>2022-10-28T21:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Running SQL Data File through Notebook Python</title>
      <link>https://community.databricks.com/t5/data-engineering/running-sql-data-file-through-notebook-python/m-p/25826#M18027</link>
      <description>&lt;P&gt;Hi @Marco Perez​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does @Jose Gonzalez​&amp;nbsp;response answer your question? If yes, would you be happy to &lt;B&gt;mark it as best&lt;/B&gt; so that other members can find the solution more quickly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We'd love to hear from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&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>Mon, 28 Nov 2022 04:23:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/running-sql-data-file-through-notebook-python/m-p/25826#M18027</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-11-28T04:23:31Z</dc:date>
    </item>
  </channel>
</rss>

