Skip to content

Commit

Permalink
test: add another test for table variants
Browse files Browse the repository at this point in the history
  • Loading branch information
joscha committed Dec 12, 2024
1 parent 3cff1a3 commit e1cbe19
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/pipeline/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2943,3 +2943,42 @@ def my_source() -> Sequence[DltResource]:
rows = load_tables_to_dicts(pipeline, "things_c", exclude_system_cols=True)
print(rows)
assert_data_table_counts(pipeline, {"things": 2, "things_a": 2, "things_b": 2, "things_c": 2 })


@pytest.mark.parametrize("create_table_variant", (True, False))
def test_columns_do_not_linger(create_table_variant: bool) -> None:
@dlt.resource()
def my_resource():
yield dlt.mark.with_hints(
item={"hello": "..."},
hints=dlt.mark.make_hints(
table_name="a",
columns={
"hello": {
"data_type": "text"
}
}
),
create_table_variant=create_table_variant,
)
yield dlt.mark.with_hints(
item={"world": "..."},
hints=dlt.mark.make_hints(
table_name="b",
),
create_table_variant=create_table_variant,
)

@dlt.source()
def my_source() -> Sequence[DltResource]:
return [my_resource]

pipeline_name = "pipe_" + uniq_id()
pipeline = dlt.pipeline(pipeline_name=pipeline_name, destination="duckdb")
info = pipeline.run(my_source())
assert_load_info(info)
assert_data_table_counts(pipeline, {"a": 1, "b": 1})
rows = load_tables_to_dicts(pipeline, "a", "b", exclude_system_cols=True)
print(rows)
assert len(rows["a"][0]) == 1
assert len(rows["b"][0]) == 1

0 comments on commit e1cbe19

Please sign in to comment.