Skip to content

Commit 663a0a2

Browse files
simen-strandclaude
andcommitted
Test all Redshift sortkey forms in model physical_properties
Parametrize the model-definition test over bare, quoted, parenthesized single-column, tuple, and array sortkey values, restoring coverage for the bare single-column form. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Simen Strand <simen.strand@netcheck.de>
1 parent 33f88eb commit 663a0a2

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

‎tests/core/engine_adapter/test_redshift.py‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,33 @@ def test_create_table_physical_properties_with_string_columns(
152152
]
153153

154154

155+
@pytest.mark.parametrize(
156+
"sortkey, expected_sortkey",
157+
[
158+
('"batch_time"', 'SORTKEY("batch_time")'),
159+
("batch_time", 'SORTKEY("batch_time")'),
160+
('("batch_time")', 'SORTKEY("batch_time")'),
161+
("(batch_time)", 'SORTKEY("batch_time")'),
162+
('("batch_time", "id_file")', 'SORTKEY("batch_time", "id_file")'),
163+
('["batch_time", "id_file"]', 'SORTKEY("batch_time", "id_file")'),
164+
],
165+
)
155166
def test_create_table_physical_properties_from_model_definition(
156-
make_mocked_engine_adapter: t.Callable,
167+
make_mocked_engine_adapter: t.Callable, sortkey: str, expected_sortkey: str
157168
):
158169
adapter = make_mocked_engine_adapter(RedshiftEngineAdapter)
159170
model: SqlModel = t.cast(
160171
SqlModel,
161172
load_sql_based_model(
162173
d.parse(
163-
"""
174+
f"""
164175
MODEL (
165176
name test_schema.test_table,
166177
kind full,
167178
physical_properties (
168179
diststyle = key,
169180
distkey = "id_file",
170-
sortkey = ("batch_time")
181+
sortkey = {sortkey}
171182
)
172183
);
173184
SELECT id_file::INT, batch_time::TIMESTAMP;
@@ -183,7 +194,7 @@ def test_create_table_physical_properties_from_model_definition(
183194
)
184195

185196
assert to_sql_calls(adapter) == [
186-
'CREATE TABLE IF NOT EXISTS "test_schema"."test_table" ("id_file" INTEGER, "batch_time" TIMESTAMP) DISTSTYLE KEY DISTKEY("id_file") SORTKEY("batch_time")',
197+
f'CREATE TABLE IF NOT EXISTS "test_schema"."test_table" ("id_file" INTEGER, "batch_time" TIMESTAMP) DISTSTYLE KEY DISTKEY("id_file") {expected_sortkey}',
187198
]
188199

189200

0 commit comments

Comments
 (0)