<?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: Extract Snowflake data based on environment in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/142015#M51863</link>
    <description>&lt;P&gt;Create a single job that runs your migration notebook.&lt;BR /&gt;In the job settings, under Parameters, add a key like env with a default value (e.g., dev).&lt;BR /&gt;When you create different job runs (or schedule them), override the parameter:&lt;/P&gt;&lt;P&gt;For development runs, set env = dev.&lt;BR /&gt;For production runs, set env = prod.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;env = dbutils.widgets.get("env")
source_db = "VP_DWH" if env == "prod" else "VD_DWH"
source_table_fqn = f"{source_db}.SALES.SALES_DETAIL"&lt;/LI-CODE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;Yes, DABs are a great option if:&lt;/P&gt;&lt;P&gt;You want environment-specific configurations (dev, staging, prod) in a single deployment artifact.&lt;BR /&gt;You need CI/CD integration for Databricks Jobs.&lt;/P&gt;&lt;P&gt;With DABs:&lt;/P&gt;&lt;P&gt;Define job parameters per environment in bundle.yml:&lt;/P&gt;&lt;/DIV&gt;&lt;LI-CODE lang="python"&gt;environments:
  dev:
    jobs:
      migrate-job:
        parameters:
          env: "dev"
  prod:
    jobs:
      migrate-job      migrate-job:
        parameters:
           env: "prod"&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 16 Dec 2025 18:01:37 GMT</pubDate>
    <dc:creator>nayan_wylde</dc:creator>
    <dc:date>2025-12-16T18:01:37Z</dc:date>
    <item>
      <title>Extract Snowflake data based on environment</title>
      <link>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141889#M51843</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the development workspace, I need to extract data from a table/view in Snowflake development environment. Example table is called as VD_DWH.SALES.SALES_DETAIL&lt;/P&gt;&lt;P&gt;When we deploy the code into production, it needs to extract data from a table/view in Snowflake production environment. Example table is called as VP_DWH.SALES.SALES_DETAIL&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;On brief, for dev database name is VD_DWH&lt;/P&gt;&lt;P&gt;for production database name is VP_&lt;SPAN&gt;DWH&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How to implement this in Databricks?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2025 17:41:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141889#M51843</guid>
      <dc:creator>ndw</dc:creator>
      <dc:date>2025-12-15T17:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Snowflake data based on environment</title>
      <link>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141890#M51844</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/198274"&gt;@ndw&lt;/a&gt;&amp;nbsp;Can you please share more details on the request. Are you trying to extract data from snowflake in databricks?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2025 18:02:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141890#M51844</guid>
      <dc:creator>nayan_wylde</dc:creator>
      <dc:date>2025-12-15T18:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Snowflake data based on environment</title>
      <link>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141895#M51846</link>
      <description>&lt;P&gt;There is a migration from the legacy data warehouse Snowflake to the lakehouse in the Databricks. Until the migration has completed, I need to transfer Snowflake data into Databricks. but dev and prod snowflake databases have different names.&lt;/P&gt;&lt;P&gt;In the development environment, data migration source is&amp;nbsp;&lt;SPAN&gt;VD_DWH.SALES.SALES_DETAIL; in the production environment the source is&amp;nbsp;VP_DWH.SALES.SALES_DETAIL&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;According to the environment I need to replace source table in the select statement&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2025 19:19:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141895#M51846</guid>
      <dc:creator>ndw</dc:creator>
      <dc:date>2025-12-15T19:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Snowflake data based on environment</title>
      <link>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141900#M51847</link>
      <description>&lt;P&gt;&lt;!--  StartFragment   --&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Option 1 &lt;/SPAN&gt;&lt;SPAN class=""&gt;— Notebook widgets (simple &amp;amp; reliable)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Use a Databricks widget to pass the environment (e.g., via Jobs/Workflows parameter), then build the table name dynamically.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Databricks notebook
dbutils.widgets.dropdown("env", "dev", ["dev", "prod"], "Environment")
env = dbutils.widgets.get("env")

# Map env → Snowflake database
db_map = {"dev": "VD_DWH", "prod": "VP_DWH"}
source_db = db_map.get(env, "VD_DWH")  # default to dev

source_table_fqn = f"{source_db}.SALES.SALES_DETAIL"

# Snowflake connection options (store secrets in Databricks Secrets)
sfOptions = {
    "sfUrl": dbutils.secrets.get("scope", "sfUrl"),
    "sfUser": dbutils.secrets.get("scope", "sfUser"),
    "sfPassword": dbutils.secrets.get("scope", "sfPassword"),
    "sfWarehouse": dbutils.secrets.get("scope", "sfWarehouse"),
    "sfRole": dbutils.secrets.get("scope", "sfRole"),
}

# Read from Snowflake table into Spark DataFrame
df = (spark.read
      .format("snowflake")
      .options(**sfOptions)
      .option("dbtable", source_table_fqn)
      .load())

# Do your transforms, then write to Delta/UC
df.write.mode("overwrite").saveAsTable("lakehouse.sales_detail")
``&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;!--  StartFragment   --&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Option 2 — Jobs/Workflows parameters (no widgets in code)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;If you’re scheduling via Databricks Jobs (or your orchestrator like ADF/Airflow), pass env as a parameter and read it with &lt;/SPAN&gt;&lt;SPAN class=""&gt;dbutils.widgets.get&lt;/SPAN&gt;&lt;SPAN class=""&gt;. You can also pass the database name directly as a parameter to avoid mapping.&lt;/SPAN&gt;&lt;!--  EndFragment   --&gt;&lt;/P&gt;&lt;P&gt;&lt;!--  StartFragment   --&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Option 3 — Configuration-driven (robust for many tables)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Centralize environment settings (e.g., in a UC Volume/Delta table or notebook-scoped JSON) and look them up&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;!--  EndFragment   --&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import json

config_json = """
{
  "dev": {"source_db": "VD_DWH"},
  "prod": {"source_db": "VP_DWH"}
}
"""
cfg = json.loads(config_json)
env = dbutils.widgets.get("env")  # or default 'dev'
source_db = cfg[env]["source_db"]

source_table_fqn = f"{source_db}.SALES.SALES_DETAIL"
# ... proceed to read from Snowflake&lt;/LI-CODE&gt;&lt;P&gt;&lt;!--  EndFragment   --&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2025 19:56:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141900#M51847</guid>
      <dc:creator>nayan_wylde</dc:creator>
      <dc:date>2025-12-15T19:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Snowflake data based on environment</title>
      <link>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141901#M51848</link>
      <description>&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;I&amp;nbsp;&lt;SPAN class=""&gt;will schedule via Databricks Job. I need to pass env as dev in the development and prod in the production. How can I pass different values with the same job in different environments? Should I use DABs for passing env?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Dec 2025 20:23:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/141901#M51848</guid>
      <dc:creator>ndw</dc:creator>
      <dc:date>2025-12-15T20:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Snowflake data based on environment</title>
      <link>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/142015#M51863</link>
      <description>&lt;P&gt;Create a single job that runs your migration notebook.&lt;BR /&gt;In the job settings, under Parameters, add a key like env with a default value (e.g., dev).&lt;BR /&gt;When you create different job runs (or schedule them), override the parameter:&lt;/P&gt;&lt;P&gt;For development runs, set env = dev.&lt;BR /&gt;For production runs, set env = prod.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;env = dbutils.widgets.get("env")
source_db = "VP_DWH" if env == "prod" else "VD_DWH"
source_table_fqn = f"{source_db}.SALES.SALES_DETAIL"&lt;/LI-CODE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;Yes, DABs are a great option if:&lt;/P&gt;&lt;P&gt;You want environment-specific configurations (dev, staging, prod) in a single deployment artifact.&lt;BR /&gt;You need CI/CD integration for Databricks Jobs.&lt;/P&gt;&lt;P&gt;With DABs:&lt;/P&gt;&lt;P&gt;Define job parameters per environment in bundle.yml:&lt;/P&gt;&lt;/DIV&gt;&lt;LI-CODE lang="python"&gt;environments:
  dev:
    jobs:
      migrate-job:
        parameters:
          env: "dev"
  prod:
    jobs:
      migrate-job      migrate-job:
        parameters:
           env: "prod"&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 16 Dec 2025 18:01:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/extract-snowflake-data-based-on-environment/m-p/142015#M51863</guid>
      <dc:creator>nayan_wylde</dc:creator>
      <dc:date>2025-12-16T18:01:37Z</dc:date>
    </item>
  </channel>
</rss>

