<?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>question pass parameters to file with sql statement using Scala to be used  sqlContext.sql(string) in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/87105#M17482</link>
    <description>&lt;P&gt;I am using Scala on data science workbench and&amp;nbsp;I have file with sql stataement would like to make it dynamic sql by passing argument to parameters. I then would like to pass it&amp;nbsp;&amp;nbsp;sqlContext.sql(string) .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have tried but does not work.&lt;/P&gt;&lt;P&gt;val FromDate = "2019-02-25"&lt;/P&gt;&lt;P&gt;val sqlfile = fromFile("&lt;A href="http://sql3.py/" target="_blank" rel="nofollow"&gt;sql3.py&lt;/A&gt;").getLines.mkString&lt;/P&gt;&lt;P&gt;val result = sqlContext.sql(sqlfile)&lt;/P&gt;&lt;P&gt;On the file I have:&lt;/P&gt;&lt;P&gt;Select col1, col2 from table1 where transdate = '${FromDate}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be &lt;SPAN&gt;appreciated&lt;/SPAN&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 21 Apr 2026 11:38:12 GMT</pubDate>
    <dc:creator>TF123</dc:creator>
    <dc:date>2026-04-21T11:38:12Z</dc:date>
    <item>
      <title>pass parameters to file with sql statement using Scala to be used  sqlContext.sql(string)</title>
      <link>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/87105#M17482</link>
      <description>&lt;P&gt;I am using Scala on data science workbench and&amp;nbsp;I have file with sql stataement would like to make it dynamic sql by passing argument to parameters. I then would like to pass it&amp;nbsp;&amp;nbsp;sqlContext.sql(string) .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have tried but does not work.&lt;/P&gt;&lt;P&gt;val FromDate = "2019-02-25"&lt;/P&gt;&lt;P&gt;val sqlfile = fromFile("&lt;A href="http://sql3.py/" target="_blank" rel="nofollow"&gt;sql3.py&lt;/A&gt;").getLines.mkString&lt;/P&gt;&lt;P&gt;val result = sqlContext.sql(sqlfile)&lt;/P&gt;&lt;P&gt;On the file I have:&lt;/P&gt;&lt;P&gt;Select col1, col2 from table1 where transdate = '${FromDate}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be &lt;SPAN&gt;appreciated&lt;/SPAN&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 11:38:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/87105#M17482</guid>
      <dc:creator>TF123</dc:creator>
      <dc:date>2026-04-21T11:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: pass parameters to file with sql statement using Scala to be used  sqlContext.sql(string)</title>
      <link>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/87421#M17483</link>
      <description>&lt;P&gt;Did you try CDSW environment variables?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A href="https://www.cloudera.com/documentation/data-science-workbench/latest/topics/cdsw_environment_variables.html#access_env_variables" target="_blank"&gt;https://www.cloudera.com/documentation/data-science-workbench/latest/topics/cdsw_environment_variables.html#access_env_variables&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 12:17:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/87421#M17483</guid>
      <dc:creator>Gopinath</dc:creator>
      <dc:date>2019-03-07T12:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: pass parameters to file with sql statement using Scala to be used  sqlContext.sql(string)</title>
      <link>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/87424#M17484</link>
      <description>&lt;P&gt;This worked at the end..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;val FromDate = "2019-02-25"&lt;/P&gt;&lt;P&gt;val sqlfile = fromFile("&lt;A href="http://sql3.py/" target="_blank" rel="nofollow noopener noreferrer"&gt;sql3.py&lt;/A&gt;").getLines.mkString&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;val sqlfil2=&amp;nbsp;sqlfile.replace("${From_timeStamp}",From_timeStamp)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;val result = sqlContext.sql(sqlfile2)&lt;/P&gt;&lt;P&gt;On the file I have:&lt;/P&gt;&lt;P&gt;Select col1, col2 from table1 where transdate = '${FromDate}'&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 13:55:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/87424#M17484</guid>
      <dc:creator>TF123</dc:creator>
      <dc:date>2019-03-07T13:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: pass parameters to file with sql statement using Scala to be used  sqlContext.sql(string)</title>
      <link>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/327147#M229985</link>
      <description>&lt;P&gt;Only one question I have the line which you made bold in that you are trying to replace "from_timestamp" but you are using "fromdate" in your sql file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any reason behind it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Oct 2021 18:56:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/pass-parameters-to-file-with-sql-statement-using-Scala-to-be/m-p/327147#M229985</guid>
      <dc:creator>rohit19</dc:creator>
      <dc:date>2021-10-09T18:56:40Z</dc:date>
    </item>
  </channel>
</rss>

