<?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 create a drop-down widget in Databricks notebook with choices retrieved using subquery over a table in SQL, python? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-create-a-drop-down-widget-in-databricks-notebook-with/m-p/14096#M8647</link>
    <description>&lt;P&gt;Please refer to the below widget example  using SQL &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%sql 
DROP VIEW IF EXISTS tempTable;
CREATE temporary view tempTable AS SELECT 'APPLE' as a UNION ALL SELECT 'ORANGE' as a UNION ALL SELECT 'BANANA' as a;
CREATE WIDGET DROPDOWN fruits DEFAULT 'ORANGE' CHOICES SELECT a from tempTable&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;python example for dropdown with values passed from the table. pass the values from the temp table (in the above example) through data frame df.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df = spark.sql("""select a from tempTable""")
dbutils.widgets.dropdown("fruits3", "ORANGE", [row[0] for row in df.collect()])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 03 Oct 2021 05:17:27 GMT</pubDate>
    <dc:creator>shan_chandra</dc:creator>
    <dc:date>2021-10-03T05:17:27Z</dc:date>
    <item>
      <title>How to create a drop-down widget in Databricks notebook with choices retrieved using subquery over a table in SQL, python?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-create-a-drop-down-widget-in-databricks-notebook-with/m-p/14095#M8646</link>
      <description />
      <pubDate>Sun, 03 Oct 2021 05:11:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-create-a-drop-down-widget-in-databricks-notebook-with/m-p/14095#M8646</guid>
      <dc:creator>shan_chandra</dc:creator>
      <dc:date>2021-10-03T05:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a drop-down widget in Databricks notebook with choices retrieved using subquery over a table in SQL, python?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-create-a-drop-down-widget-in-databricks-notebook-with/m-p/14096#M8647</link>
      <description>&lt;P&gt;Please refer to the below widget example  using SQL &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%sql 
DROP VIEW IF EXISTS tempTable;
CREATE temporary view tempTable AS SELECT 'APPLE' as a UNION ALL SELECT 'ORANGE' as a UNION ALL SELECT 'BANANA' as a;
CREATE WIDGET DROPDOWN fruits DEFAULT 'ORANGE' CHOICES SELECT a from tempTable&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;python example for dropdown with values passed from the table. pass the values from the temp table (in the above example) through data frame df.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df = spark.sql("""select a from tempTable""")
dbutils.widgets.dropdown("fruits3", "ORANGE", [row[0] for row in df.collect()])&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Oct 2021 05:17:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-create-a-drop-down-widget-in-databricks-notebook-with/m-p/14096#M8647</guid>
      <dc:creator>shan_chandra</dc:creator>
      <dc:date>2021-10-03T05:17:27Z</dc:date>
    </item>
  </channel>
</rss>

