From efc68e4c32b58536f174e18ec28550bd9f88d629 Mon Sep 17 00:00:00 2001 From: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:17:05 -0500 Subject: [PATCH] Update default python version for python models (#1273) * update the default python version for python models; add a configuration file to collect future settings --- .changes/unreleased/Under the Hood-20241211-170831.yaml | 6 ++++++ dbt/adapters/snowflake/constants.py | 1 + dbt/adapters/snowflake/impl.py | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Under the Hood-20241211-170831.yaml create mode 100644 dbt/adapters/snowflake/constants.py diff --git a/.changes/unreleased/Under the Hood-20241211-170831.yaml b/.changes/unreleased/Under the Hood-20241211-170831.yaml new file mode 100644 index 000000000..17bf42c1f --- /dev/null +++ b/.changes/unreleased/Under the Hood-20241211-170831.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Update default Python version for python models +time: 2024-12-11T17:08:31.842063-05:00 +custom: + Author: mikealfare + Issue: "1203" diff --git a/dbt/adapters/snowflake/constants.py b/dbt/adapters/snowflake/constants.py new file mode 100644 index 000000000..9c475dcd9 --- /dev/null +++ b/dbt/adapters/snowflake/constants.py @@ -0,0 +1 @@ +DEFAULT_PYTHON_VERSION_FOR_PYTHON_MODELS = "3.9" diff --git a/dbt/adapters/snowflake/impl.py b/dbt/adapters/snowflake/impl.py index 10ad2a8a1..7ccff9f8a 100644 --- a/dbt/adapters/snowflake/impl.py +++ b/dbt/adapters/snowflake/impl.py @@ -22,6 +22,7 @@ from dbt_common.exceptions import CompilationError, DbtDatabaseError, DbtRuntimeError from dbt_common.utils import filter_null_values +from dbt.adapters.snowflake import constants from dbt.adapters.snowflake.relation_configs import ( SnowflakeRelationType, TableFormat, @@ -345,7 +346,9 @@ def submit_python_job(self, parsed_model: dict, compiled_code: str): schema = parsed_model["schema"] database = parsed_model["database"] identifier = parsed_model["alias"] - python_version = parsed_model["config"].get("python_version", "3.8") + python_version = parsed_model["config"].get( + "python_version", constants.DEFAULT_PYTHON_VERSION_FOR_PYTHON_MODELS + ) packages = parsed_model["config"].get("packages", []) imports = parsed_model["config"].get("imports", [])