<?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: Facing issue while using widget values in sql script in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/facing-issue-while-using-widget-values-in-sql-script/m-p/16930#M11021</link>
    <description>&lt;P&gt;Hi @Kaniz Fatma​&amp;nbsp;, I tried executing notebook using runtime 9.1 LTS and 10.4 LTS. &lt;/P&gt;&lt;P&gt;The problem is, I am using this sql scripts in python notebook. I can able to read widget values and able to print the widget values using python print statement. I am getting value as expected. &lt;/P&gt;&lt;P&gt;When I use same variable in a SQL script in the same notebook, this value is not reflecting there instead it is taking empty value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed all my sql scripts to spark.sql() statements and now notebooks are running fine. But still I am not getting, why sql scripts are not working here.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Jan 2023 04:38:25 GMT</pubDate>
    <dc:creator>Ashwathy</dc:creator>
    <dc:date>2023-01-02T04:38:25Z</dc:date>
    <item>
      <title>Facing issue while using widget values in sql script</title>
      <link>https://community.databricks.com/t5/data-engineering/facing-issue-while-using-widget-values-in-sql-script/m-p/16928#M11019</link>
      <description>&lt;P&gt;I am using below code to create and read widgets. I am assigning default value.&lt;/P&gt;&lt;P&gt;dbutils.widgets.text("pname", "default","parameter_name")&lt;/P&gt;&lt;P&gt;pname=dbutils.widgets.get("pname")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using this widget parameter in some sql scripts. one example is given below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sql&lt;/P&gt;&lt;P&gt;CREATE database if not exists ${pname}_test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am executing this notebook from an ADF. I am not passing any value to this parameter, so it will take default value.&lt;/P&gt;&lt;P&gt;Problem I am facing is, sometimes this widget value is reflecting and sometimes it is not reflecting in the sql script so it is creating "_test" database. This is happening in my dev environment. I am using exactly same code in my production environment, and there it is working fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes it is working all fine and sometimes I am facing this issue. Can anyone please help me to identify the issue?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 13:04:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/facing-issue-while-using-widget-values-in-sql-script/m-p/16928#M11019</guid>
      <dc:creator>Ashwathy</dc:creator>
      <dc:date>2022-12-14T13:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Facing issue while using widget values in sql script</title>
      <link>https://community.databricks.com/t5/data-engineering/facing-issue-while-using-widget-values-in-sql-script/m-p/16930#M11021</link>
      <description>&lt;P&gt;Hi @Kaniz Fatma​&amp;nbsp;, I tried executing notebook using runtime 9.1 LTS and 10.4 LTS. &lt;/P&gt;&lt;P&gt;The problem is, I am using this sql scripts in python notebook. I can able to read widget values and able to print the widget values using python print statement. I am getting value as expected. &lt;/P&gt;&lt;P&gt;When I use same variable in a SQL script in the same notebook, this value is not reflecting there instead it is taking empty value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed all my sql scripts to spark.sql() statements and now notebooks are running fine. But still I am not getting, why sql scripts are not working here.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2023 04:38:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/facing-issue-while-using-widget-values-in-sql-script/m-p/16930#M11021</guid>
      <dc:creator>Ashwathy</dc:creator>
      <dc:date>2023-01-02T04:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Facing issue while using widget values in sql script</title>
      <link>https://community.databricks.com/t5/data-engineering/facing-issue-while-using-widget-values-in-sql-script/m-p/16931#M11022</link>
      <description>&lt;P&gt;&lt;A href="https://docs.databricks.com/notebooks/widgets.html" target="test_blank"&gt;https://docs.databricks.com/notebooks/widgets.html&lt;/A&gt; states&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general, you &lt;B&gt;cannot&lt;/B&gt; use widgets to pass arguments between different languages within a notebook. You can create a widget arg1 in a Python cell and use it in a SQL or Scala cell if you run one cell at a time. However, this &lt;B&gt;does not work&lt;/B&gt; if you use Run All or run the notebook &lt;B&gt;as a job&lt;/B&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 12:32:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/facing-issue-while-using-widget-values-in-sql-script/m-p/16931#M11022</guid>
      <dc:creator>takomyr</dc:creator>
      <dc:date>2023-05-18T12:32:03Z</dc:date>
    </item>
  </channel>
</rss>

