Skip to content

Commit 65efeb5

Browse files
committed
fix(athena): forward kwargs in SparkdbtObj and force table materialization in Spark Connect tests
- SparkdbtObj.ref/source lambdas dropped **kwargs, breaking versioned refs (dbt.ref(..., v=1)) - TestSparkConnectPythonModel forces +materialized: table because Spark's HiveExternalCatalog can't resolve Athena views - Document setuptools rationale (PEP 632 distutils shim for pyspark 3.5 on Python 3.12)
1 parent 0610701 commit 65efeb5

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

dbt-athena/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ dependencies=[
3939
"tenacity>=8.2,<10.0",
4040
]
4141
[project.optional-dependencies]
42+
# setuptools provides the distutils shim that pyspark 3.5 still imports
43+
# (removed from stdlib in Python 3.12, PEP 632).
4244
spark_connect = ["pyspark[connect]>=3.5.6,<3.6", "setuptools"]
4345

4446
[project.urls]

dbt-athena/src/dbt/include/athena/macros/adapters/python_submissions.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def get_spark_df(identifier):
9595
class SparkdbtObj(dbtObj):
9696
def __init__(self):
9797
super().__init__(load_df_function=get_spark_df)
98-
self.source = lambda *args: source(*args, dbt_load_df_function=get_spark_df)
99-
self.ref = lambda *args: ref(*args, dbt_load_df_function=get_spark_df)
98+
self.source = lambda *args, **kwargs: source(*args, dbt_load_df_function=get_spark_df, **kwargs)
99+
self.ref = lambda *args, **kwargs: ref(*args, dbt_load_df_function=get_spark_df, **kwargs)
100100

101101
{%- endmacro -%}

dbt-athena/tests/functional/adapter/test_python_submissions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ def model(dbt, _):
3434
reason="DBT_TEST_ATHENA_SPARK_WORK_GROUP must point to a Spark 3.5 workgroup.",
3535
)
3636
class TestSparkConnectPythonModel(BasePythonModelTests):
37+
@pytest.fixture(scope="class")
38+
def project_config_update(self):
39+
# Athena defaults SQL models to views, but Spark's HiveExternalCatalog
40+
# cannot resolve Athena views (no S3 location), so dbt.ref() blows up
41+
# with "Can not create a Path from an empty string". Force tables.
42+
return {"models": {"+materialized": "table"}}
43+
3744
@pytest.fixture(scope="class")
3845
def models(self):
3946
return {

0 commit comments

Comments
 (0)