Skip to content

Commit dc08ba3

Browse files
authored
Merge branch 'main' into feat-bigquery-reservations
2 parents 30bab50 + c62cac1 commit dc08ba3

File tree

5 files changed

+36
-29
lines changed

5 files changed

+36
-29
lines changed

sqlmesh/dbt/model.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ def to_sqlmesh(
567567
self.name,
568568
"views" if isinstance(kind, ViewKind) else "ephemeral models",
569569
)
570+
elif context.target.dialect == "snowflake":
571+
logger.warning(
572+
"Ignoring partition_by config for model '%s' targeting %s. The partition_by config is not supported for Snowflake.",
573+
self.name,
574+
context.target.dialect,
575+
)
570576
else:
571577
partitioned_by = []
572578
if isinstance(self.partition_by, list):

tests/cli/test_cli.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import json
2-
import logging
32
import os
43
import pytest
54
import string
65
import time_machine
7-
from contextlib import contextmanager
86
from os import getcwd, path, remove
97
from pathlib import Path
108
from shutil import rmtree
@@ -35,15 +33,6 @@ def runner() -> CliRunner:
3533
return CliRunner(env={"COLUMNS": "80"})
3634

3735

38-
@contextmanager
39-
def disable_logging():
40-
logging.disable(logging.CRITICAL)
41-
try:
42-
yield
43-
finally:
44-
logging.disable(logging.NOTSET)
45-
46-
4736
def create_example_project(temp_dir, template=ProjectTemplate.DEFAULT) -> None:
4837
"""
4938
Sets up CLI tests requiring a real SQLMesh project by:
@@ -795,8 +784,7 @@ def test_run_cron_not_elapsed(runner, tmp_path, caplog):
795784
init_prod_and_backfill(runner, tmp_path)
796785

797786
# No error if `prod` environment exists and cron has not elapsed
798-
with disable_logging():
799-
result = runner.invoke(cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "run"])
787+
result = runner.invoke(cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "run"])
800788
assert result.exit_code == 0
801789

802790
assert (
@@ -843,18 +831,17 @@ def test_table_name(runner, tmp_path):
843831
# Create and backfill `prod` environment
844832
create_example_project(tmp_path)
845833
init_prod_and_backfill(runner, tmp_path)
846-
with disable_logging():
847-
result = runner.invoke(
848-
cli,
849-
[
850-
"--log-file-dir",
851-
tmp_path,
852-
"--paths",
853-
tmp_path,
854-
"table_name",
855-
"sqlmesh_example.full_model",
856-
],
857-
)
834+
result = runner.invoke(
835+
cli,
836+
[
837+
"--log-file-dir",
838+
tmp_path,
839+
"--paths",
840+
tmp_path,
841+
"table_name",
842+
"sqlmesh_example.full_model",
843+
],
844+
)
858845
assert result.exit_code == 0
859846
assert result.output.startswith("db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__")
860847

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def rescope_duckdb_classvar(request):
247247
yield
248248

249249

250-
@pytest.fixture(scope="module", autouse=True)
250+
@pytest.fixture(scope="function", autouse=True)
251251
def rescope_log_handlers():
252252
logging.getLogger().handlers.clear()
253253
yield

tests/dbt/test_model.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import datetime
2+
import logging
3+
24
import pytest
35

46
from pathlib import Path
@@ -274,7 +276,9 @@ def test_load_invalid_ref_audit_constraints(
274276
with open(model_schema_file, "w", encoding="utf-8") as f:
275277
yaml.dump(model_schema, f)
276278

277-
context = Context(paths=project_dir)
279+
assert isinstance(get_console(), NoopConsole)
280+
with caplog.at_level(logging.DEBUG):
281+
context = Context(paths=project_dir)
278282
assert (
279283
"Skipping audit 'relationships_full_model_cola__cola__ref_not_real_model_' because model 'not_real_model' is not a valid ref"
280284
in caplog.text
@@ -539,7 +543,8 @@ def test_load_deprecated_incremental_time_column(
539543

540544
snapshot_fqn = '"local"."main"."incremental_time_range"'
541545
assert isinstance(get_console(), NoopConsole)
542-
context = Context(paths=project_dir)
546+
with caplog.at_level(logging.DEBUG):
547+
context = Context(paths=project_dir)
543548
model = context.snapshots[snapshot_fqn].model
544549
# Validate model-level attributes
545550
assert to_ds(model.start or "") == "2025-01-01"

tests/dbt/test_transformation.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ def test_parsetime_adapter_call(
18851885

18861886

18871887
@pytest.mark.xdist_group("dbt_manifest")
1888-
def test_partition_by(sushi_test_project: Project):
1888+
def test_partition_by(sushi_test_project: Project, caplog):
18891889
context = sushi_test_project.context
18901890
context.target = BigQueryConfig(name="production", database="main", schema="sushi")
18911891
model_config = ModelConfig(
@@ -1928,6 +1928,15 @@ def test_partition_by(sushi_test_project: Project):
19281928
context.target = DuckDbConfig(name="target", schema="foo")
19291929
assert model_config.to_sqlmesh(context).partitioned_by == []
19301930

1931+
context.target = SnowflakeConfig(
1932+
name="target", schema="test", database="test", account="foo", user="bar", password="baz"
1933+
)
1934+
assert model_config.to_sqlmesh(context).partitioned_by == []
1935+
assert (
1936+
"Ignoring partition_by config for model 'model' targeting snowflake. The partition_by config is not supported for Snowflake."
1937+
in caplog.text
1938+
)
1939+
19311940
model_config = ModelConfig(
19321941
name="model",
19331942
alias="model",

0 commit comments

Comments
 (0)