title: How to use widgets to pass dynamic column names in Dataframe select statement
body: <p>I have a Dataframe and I want to dynamically pass the columns names through widgets in a select statement in my Databricks Notebook. How can I do it?</p>
  <p>I am using the below code</p>
  <pre><code>df1 = spark.sql(&quot;select * from tableraw&quot;)
  </code></pre>
  <p>where <code>df1</code> has columns &quot;tablename&quot; and &quot;layer&quot;</p>
  <pre><code>df = df1.select(&quot;tablename&quot;, &quot;layer&quot;)
  </code></pre>
  <p>Now, our requirement is to use the values of the widgets to select those columns, something like:</p>
  <pre><code>df = df1.select(dbutils.widget.get(&quot;tablename&quot;), dbutils.widget.get(&quot;datalayer&quot;))
  </code></pre>