<?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 Pass date value as parameter in Databricks SQL notebook in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11782#M6704</link>
    <description>&lt;P&gt;I want to pass yesterday date (In the example 20230115*.csv) in the csv file. Don't know how to create parameter and use it here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OR REPLACE TEMPORARY VIEW abc_delivery_log&lt;/P&gt;&lt;P&gt;USING CSV&lt;/P&gt;&lt;P&gt;OPTIONS (&lt;/P&gt;&lt;P&gt;&amp;nbsp;header="true",&lt;/P&gt;&lt;P&gt;&amp;nbsp;delimiter=",",&lt;/P&gt;&lt;P&gt;&amp;nbsp;inferSchema="true",&lt;/P&gt;&lt;P&gt;&amp;nbsp;path="abfss://selfserv-xxxxx@xxxxx/xxxxx/abc_delivery_log_20230115080013.csv"&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;</description>
    <pubDate>Mon, 16 Jan 2023 06:02:07 GMT</pubDate>
    <dc:creator>sp1</dc:creator>
    <dc:date>2023-01-16T06:02:07Z</dc:date>
    <item>
      <title>Pass date value as parameter in Databricks SQL notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11782#M6704</link>
      <description>&lt;P&gt;I want to pass yesterday date (In the example 20230115*.csv) in the csv file. Don't know how to create parameter and use it here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OR REPLACE TEMPORARY VIEW abc_delivery_log&lt;/P&gt;&lt;P&gt;USING CSV&lt;/P&gt;&lt;P&gt;OPTIONS (&lt;/P&gt;&lt;P&gt;&amp;nbsp;header="true",&lt;/P&gt;&lt;P&gt;&amp;nbsp;delimiter=",",&lt;/P&gt;&lt;P&gt;&amp;nbsp;inferSchema="true",&lt;/P&gt;&lt;P&gt;&amp;nbsp;path="abfss://selfserv-xxxxx@xxxxx/xxxxx/abc_delivery_log_20230115080013.csv"&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 06:02:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11782#M6704</guid>
      <dc:creator>sp1</dc:creator>
      <dc:date>2023-01-16T06:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pass date value as parameter in Databricks SQL notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11783#M6705</link>
      <description>&lt;P&gt;You can use dbutils.widgets to pass a parameter to your notebook (https://docs.databricks.com/notebooks/widgets.html) then use Python to create and execute your parametrized sql code.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 06:34:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11783#M6705</guid>
      <dc:creator>daniel_sahal</dc:creator>
      <dc:date>2023-01-16T06:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Pass date value as parameter in Databricks SQL notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11785#M6707</link>
      <description>&lt;P&gt;Hi @Sujatha Pillai​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try using the below SQL code using widgets &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CREATE WIDGET TEXT pathname DEFAULT "pathvalue"
&amp;nbsp;
CREATE OR REPLACE TEMPORARY VIEW abc_delivery_log
USING CSV
OPTIONS (
 header="true",
 delimiter=",",
 inferSchema="true",
 path = getArgument('pathname')
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and using widgets you can pass the variable value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Happy Learning!!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 12:55:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11785#M6707</guid>
      <dc:creator>Chaitanya_Raju</dc:creator>
      <dc:date>2023-01-16T12:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Pass date value as parameter in Databricks SQL notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11786#M6708</link>
      <description>&lt;P&gt;SQL has a function for current_timestamp, which you can cast as a date to get todays date.  You don't need to pass anything to the notebook for this logic to work.  &lt;span class="lia-inline-image-display-wrapper" image-alt="Image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2555iAC19A9BFBC4B034E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image" alt="Image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 18:41:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11786#M6708</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-16T18:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Pass date value as parameter in Databricks SQL notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11787#M6709</link>
      <description>&lt;P&gt;Thanks for all your replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used widget using date and it's working as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop view if exists inputdate1;&lt;/P&gt;&lt;P&gt;create view inputdate1 as select&amp;nbsp;date_format(current_date()-1, 'yyyyMMdd') AS date UNION ALL select&amp;nbsp;date_format(current_date(), 'yyyyMMdd') AS date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%python&lt;/P&gt;&lt;P&gt;dataframe = sqlContext.sql('select * from inputdate1')&amp;nbsp;&lt;/P&gt;&lt;P&gt;values = [row.date for row in dataframe.select('date').collect()]&lt;/P&gt;&lt;P&gt;default_value = str(min(values))&lt;/P&gt;&lt;P&gt;values_str = [str(value) for value in values]&lt;/P&gt;&lt;P&gt;dbutils.widgets.dropdown("date", default_value, values_str)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OR REPLACE TEMPORARY VIEW abc_delivery_log&lt;/P&gt;&lt;P&gt;USING CSV&lt;/P&gt;&lt;P&gt;OPTIONS (&lt;/P&gt;&lt;P&gt;&amp;nbsp;header="true",&lt;/P&gt;&lt;P&gt;&amp;nbsp;delimiter=",",&lt;/P&gt;&lt;P&gt;&amp;nbsp;inferSchema="true",&lt;/P&gt;&lt;P&gt;&amp;nbsp;path="abfss://selfserv-xxxxx@xxxxx/xxxxx/abc_delivery_log_delivery_log_${date}*.csv"&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2023 22:11:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/11787#M6709</guid>
      <dc:creator>sp1</dc:creator>
      <dc:date>2023-01-16T22:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Pass date value as parameter in Databricks SQL notebook</title>
      <link>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/67442#M33342</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/30493"&gt;@sp1&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/79047"&gt;@Chaitanya_Raju&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/79106"&gt;@daniel_sahal&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I need the same scenario on SQL code, because my DBR cluster not allowed me to run python code&lt;/P&gt;&lt;P&gt;Error:&amp;nbsp;&lt;SPAN&gt;Unsupported cell during execution. SQL warehouses only support executing SQL cells.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I appreciate your help&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 20:58:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pass-date-value-as-parameter-in-databricks-sql-notebook/m-p/67442#M33342</guid>
      <dc:creator>Asifpanjwani</dc:creator>
      <dc:date>2024-04-26T20:58:25Z</dc:date>
    </item>
  </channel>
</rss>

