<?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: How to execute .sql file in volume in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99731#M40076</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133340"&gt;@lauraxyz&lt;/a&gt;&amp;nbsp;, We can load the SQL file using dbutils.fs from volumes and then we can create a dataframe using spark.sql()&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;sql_query &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; dbutils.fs.&lt;/SPAN&gt;&lt;SPAN&gt;head&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"/Volumes/jahnavi/datasets/data/test.sql"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;result_df &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; spark&lt;/SPAN&gt;&lt;SPAN&gt;.sql&lt;/SPAN&gt;&lt;SPAN&gt;(sql_query)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;display&lt;/SPAN&gt;&lt;SPAN&gt;(result_df)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 22 Nov 2024 06:11:29 GMT</pubDate>
    <dc:creator>JAHNAVI</dc:creator>
    <dc:date>2024-11-22T06:11:29Z</dc:date>
    <item>
      <title>How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99702#M40064</link>
      <description>&lt;P&gt;I have giant queries (SELECT.. FROM) that i store in .sql files. I want to put those files in the Volume, and run the queries from a workflow task.&lt;/P&gt;&lt;P&gt;I can load the file content into a 'text' format string, then run the query.&amp;nbsp; My question is,&amp;nbsp; is there another option, where I don't need to load the file content, but directly execute the .sql file and store the results in a Dataframe?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2024 19:50:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99702#M40064</guid>
      <dc:creator>lauraxyz</dc:creator>
      <dc:date>2024-11-21T19:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99731#M40076</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133340"&gt;@lauraxyz&lt;/a&gt;&amp;nbsp;, We can load the SQL file using dbutils.fs from volumes and then we can create a dataframe using spark.sql()&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;sql_query &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; dbutils.fs.&lt;/SPAN&gt;&lt;SPAN&gt;head&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"/Volumes/jahnavi/datasets/data/test.sql"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;result_df &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; spark&lt;/SPAN&gt;&lt;SPAN&gt;.sql&lt;/SPAN&gt;&lt;SPAN&gt;(sql_query)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;display&lt;/SPAN&gt;&lt;SPAN&gt;(result_df)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 22 Nov 2024 06:11:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99731#M40076</guid>
      <dc:creator>JAHNAVI</dc:creator>
      <dc:date>2024-11-22T06:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99801#M40102</link>
      <description>&lt;P&gt;Thanks Jahnavi! That's what i'm doing now, was wondering if there's a way that I don't need to parse the content of the file but directly execute it.&amp;nbsp; &amp;nbsp; Another example is if i have a python notebook in Volume, and I want to directly execute this notebook without parsing the content, would I be able to do that?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 18:33:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99801#M40102</guid>
      <dc:creator>lauraxyz</dc:creator>
      <dc:date>2024-11-22T18:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99841#M40112</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133340"&gt;@lauraxyz&lt;/a&gt;&amp;nbsp;For SQL there is no direct way to run the file without parsing it. However, for Python, we can use %run to run the file from volumes.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;%python&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;%&lt;/SPAN&gt;&lt;SPAN&gt;run &lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;Volumes&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;jahnavi&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;datasets&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;test.py&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 23 Nov 2024 07:27:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/99841#M40112</guid>
      <dc:creator>JAHNAVI</dc:creator>
      <dc:date>2024-11-23T07:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100265#M40248</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/30528"&gt;@JAHNAVI&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;How about Python Notebooks? can we directly run .ipynb files?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2024 17:26:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100265#M40248</guid>
      <dc:creator>lauraxyz</dc:creator>
      <dc:date>2024-11-27T17:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100648#M40369</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133340"&gt;@lauraxyz&lt;/a&gt;&amp;nbsp;, Good Day!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We can run the below command to&amp;nbsp;&lt;SPAN&gt;un .ipynb files&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;%python&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;%&lt;/SPAN&gt;&lt;SPAN&gt;run &lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;Volumes&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;jahnavi&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;datasets&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;test12.ipynb&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 Dec 2024 16:27:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100648#M40369</guid>
      <dc:creator>JAHNAVI</dc:creator>
      <dc:date>2024-12-02T16:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100651#M40370</link>
      <description>&lt;P&gt;Thanks gonna give it a try!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 17:12:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100651#M40370</guid>
      <dc:creator>lauraxyz</dc:creator>
      <dc:date>2024-12-02T17:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100824#M40433</link>
      <description>&lt;P&gt;.ipynb cannot be applied due to ModuleNotFoundError: No module named 'nbformat'.&lt;/P&gt;&lt;P&gt;.py command seemed passed but the insertion was never executed, therefore it's a silent fail.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 20:33:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100824#M40433</guid>
      <dc:creator>lauraxyz</dc:creator>
      <dc:date>2024-12-03T20:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute .sql file in volume</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100835#M40436</link>
      <description>&lt;P&gt;issue resolved:&lt;/P&gt;&lt;P&gt;for .py, i was using spark, and I have to explicitly create the spark session so that it can be run properly and insert data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2024 01:01:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-execute-sql-file-in-volume/m-p/100835#M40436</guid>
      <dc:creator>lauraxyz</dc:creator>
      <dc:date>2024-12-04T01:01:55Z</dc:date>
    </item>
  </channel>
</rss>

