<?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: Declare a constant value in a Databricks noteboook to be used in futher SQL code in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/declare-a-constant-value-in-a-databricks-noteboook-to-be-used-in/m-p/20073#M13550</link>
    <description>&lt;P&gt;@Thomas Lehmann​&amp;nbsp;, SQL widgets are a way to go in Databricks &lt;A href="https://docs.databricks.com/notebooks/widgets.html" alt="https://docs.databricks.com/notebooks/widgets.html" target="_blank"&gt;https://docs.databricks.com/notebooks/widgets.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 21 May 2022 10:25:37 GMT</pubDate>
    <dc:creator>Hubert-Dudek</dc:creator>
    <dc:date>2022-05-21T10:25:37Z</dc:date>
    <item>
      <title>Declare a constant value in a Databricks noteboook to be used in futher SQL code</title>
      <link>https://community.databricks.com/t5/data-engineering/declare-a-constant-value-in-a-databricks-noteboook-to-be-used-in/m-p/20072#M13549</link>
      <description>&lt;P&gt;I'm new to databricks and try to migrate some former SQL code used so far, in a DB notebook.&lt;/P&gt;&lt;P&gt;I have some constants declared and I can't find the right way to similarly declare those in my notebook.&lt;/P&gt;&lt;P&gt;I tried &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%sql
DECLARE label_language CONSTANT VARCHAR(2) := 'FR'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but it is not 'understood' by BD SQL&lt;/P&gt;&lt;P&gt;so I tried&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;label_language='FR'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which creates the constant and its value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I want to use the value of this constant in my SQL code .... or it fails, or it returns 0 records in &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%sql
&amp;nbsp;
CREATE OR REPLACE TEMPORARY VIEW label_sku_table
AS
	SELECT plt.unv_num_univers,
		plt.fam_num_family,
		ltf.lat_long_label AS fam_name_family,
        plt.dsm_code,
		plt.sku_date_end
	FROM pre_label_sku_table plt
	INNER JOIN datalake_cds.d_label_translation ltf ON plt.lab_idr_label_fam = ltf.lab_idr_label
	WHERE ltf.lan_code_langue_lan = 'label_language'
		AND	plt.ranking = 1 
	GROUP BY plt.unv_num_univers,
		   plt.fam_num_family,
		   ltf.lat_long_label,
           plt.dsm_code,
		   plt.sku_date_end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried this syntax as well :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WHERE ltf.lan_code_langue_lan = '{{label_language}}'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But again ... no resulting content. As if the SQL code did not recognize the [label_language] as a variable to which the value 'FR' has been assigned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for any relevant support.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 12:07:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/declare-a-constant-value-in-a-databricks-noteboook-to-be-used-in/m-p/20072#M13549</guid>
      <dc:creator>Thomas_Lehmann</dc:creator>
      <dc:date>2022-05-20T12:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Declare a constant value in a Databricks noteboook to be used in futher SQL code</title>
      <link>https://community.databricks.com/t5/data-engineering/declare-a-constant-value-in-a-databricks-noteboook-to-be-used-in/m-p/20073#M13550</link>
      <description>&lt;P&gt;@Thomas Lehmann​&amp;nbsp;, SQL widgets are a way to go in Databricks &lt;A href="https://docs.databricks.com/notebooks/widgets.html" alt="https://docs.databricks.com/notebooks/widgets.html" target="_blank"&gt;https://docs.databricks.com/notebooks/widgets.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2022 10:25:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/declare-a-constant-value-in-a-databricks-noteboook-to-be-used-in/m-p/20073#M13550</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2022-05-21T10:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Declare a constant value in a Databricks noteboook to be used in futher SQL code</title>
      <link>https://community.databricks.com/t5/data-engineering/declare-a-constant-value-in-a-databricks-noteboook-to-be-used-in/m-p/20074#M13551</link>
      <description>&lt;P&gt;Thank you @Hubert Dudek​&amp;nbsp;, gave it a try and it does the job, both in SQL and in Python btw. When the time will come to industrialize this, I'll have to figure out how to create/use/deal with some configuration files (json, yaml or so). But for exploratory purpose, widgets are enough thanks again&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 07:38:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/declare-a-constant-value-in-a-databricks-noteboook-to-be-used-in/m-p/20074#M13551</guid>
      <dc:creator>Thomas_Lehmann</dc:creator>
      <dc:date>2022-05-23T07:38:13Z</dc:date>
    </item>
  </channel>
</rss>

