<?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 Passing parameters (variables?) in DAGs in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/passing-parameters-variables-in-dags/m-p/106825#M42605</link>
    <description>&lt;P&gt;Regarding DAGs and tasks in them - can I pass a parameter/variable in a task?&lt;BR /&gt;&lt;BR /&gt;I have the same structure like here:&amp;nbsp;&lt;A href="https://github.com/databricks/bundle-examples/blob/main/default_sql/resources/default_sql_sql_job.yml" target="_blank" rel="noopener"&gt;https://github.com/databricks/bundle-examples/blob/main/default_sql/resources/default_sql_sql_job.yml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and I want to pass variables to .sql file from tasks. It works when I put that as a parameter in parameters section like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;resources:
  jobs:
    some_workflow:
      name: some_workflow

      trigger:
        .....

      parameters:
        - name: catalog
          default: ${var.catalog}
        - name: schema
          default: ${var.schema}
        - name: bundle_target
          default: ${bundle.target}
        - name: table_to_drop
          default: name_of_table_to_drop

      tasks:
        - task_key: drop_table
          sql_task:
            warehouse_id: ${var.warehouse_id}
            file:
              path: ../src/drop_table.sql&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but if I want to specify that as a parameter/variable within task like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      tasks:
        - task_key: process_data
          parameters:
            input_table: ${parameters.source_table}
          variables: 
            environment: ${var.env}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it doesn't work.&lt;BR /&gt;Am I missing something? I've gone through all docs possible but didn't find an answer to that.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jan 2025 15:47:12 GMT</pubDate>
    <dc:creator>Greg_c</dc:creator>
    <dc:date>2025-01-23T15:47:12Z</dc:date>
    <item>
      <title>Passing parameters (variables?) in DAGs</title>
      <link>https://community.databricks.com/t5/data-engineering/passing-parameters-variables-in-dags/m-p/106825#M42605</link>
      <description>&lt;P&gt;Regarding DAGs and tasks in them - can I pass a parameter/variable in a task?&lt;BR /&gt;&lt;BR /&gt;I have the same structure like here:&amp;nbsp;&lt;A href="https://github.com/databricks/bundle-examples/blob/main/default_sql/resources/default_sql_sql_job.yml" target="_blank" rel="noopener"&gt;https://github.com/databricks/bundle-examples/blob/main/default_sql/resources/default_sql_sql_job.yml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and I want to pass variables to .sql file from tasks. It works when I put that as a parameter in parameters section like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;resources:
  jobs:
    some_workflow:
      name: some_workflow

      trigger:
        .....

      parameters:
        - name: catalog
          default: ${var.catalog}
        - name: schema
          default: ${var.schema}
        - name: bundle_target
          default: ${bundle.target}
        - name: table_to_drop
          default: name_of_table_to_drop

      tasks:
        - task_key: drop_table
          sql_task:
            warehouse_id: ${var.warehouse_id}
            file:
              path: ../src/drop_table.sql&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but if I want to specify that as a parameter/variable within task like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      tasks:
        - task_key: process_data
          parameters:
            input_table: ${parameters.source_table}
          variables: 
            environment: ${var.env}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it doesn't work.&lt;BR /&gt;Am I missing something? I've gone through all docs possible but didn't find an answer to that.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 15:47:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/passing-parameters-variables-in-dags/m-p/106825#M42605</guid>
      <dc:creator>Greg_c</dc:creator>
      <dc:date>2025-01-23T15:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Passing parameters (variables?) in DAGs</title>
      <link>https://community.databricks.com/t5/data-engineering/passing-parameters-variables-in-dags/m-p/107023#M42676</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/143771"&gt;@Greg_c&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;In Databricks Asset Bundles you have a possibility to pass parameter to SQL File Task.&lt;BR /&gt;&lt;BR /&gt;Here is end to end example:&lt;BR /&gt;&lt;BR /&gt;1. My SQL File (with :id parameter):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filipniziol_0-1737824991732.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/14329iB4DBD1E06312651F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="filipniziol_0-1737824991732.png" alt="filipniziol_0-1737824991732.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2. The job YAML:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;resources:
  jobs:
    run_sql_file_job:
      name: run_sql_file_job
      tasks:
        - task_key: run_sql_file_task
          sql_task:
            parameters:
              id: "1"
            file:
              path: /Workspace/Shared/sql_file_with_parameter.sql
              source: WORKSPACE
            warehouse_id: b277bba4a65e4c55
      queue:
        enabled: true&lt;/LI-CODE&gt;&lt;P&gt;3. The result:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filipniziol_1-1737825144470.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/14330i7F7ECCA79F3623B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="filipniziol_1-1737825144470.png" alt="filipniziol_1-1737825144470.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;4. The difference between your code and the example is you define parameters one level up compared to what is the working yaml:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      tasks:
        - task_key: process_data
          parameters:
            input_table: ${parameters.source_table}&lt;/LI-CODE&gt;&lt;P&gt;vs.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      tasks:
        - task_key: run_sql_file_task
          sql_task:
            parameters:
              id: "1"&lt;/LI-CODE&gt;&lt;P&gt;Let me know if that helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jan 2025 17:14:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/passing-parameters-variables-in-dags/m-p/107023#M42676</guid>
      <dc:creator>filipniziol</dc:creator>
      <dc:date>2025-01-25T17:14:43Z</dc:date>
    </item>
  </channel>
</rss>

