Skip to content

Commit

Permalink
Increase testing of generic types storage (#282)
Browse files Browse the repository at this point in the history
- add list of structs
 - rename for clarity

Co-authored-by: Eric Vergnaud <eric.vergnaud@databricks.com>
  • Loading branch information
ericvergnaud and ericvergnaud authored Sep 13, 2024
1 parent 37fc787 commit 3b567d7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/integration/test_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@


@dataclass
class Foo:
class Nested:
first: str
second: bool | None


@dataclass
class Nested:
foo: Foo
class NestedWithDict:
name: str
other: dict[str, str] | None


@dataclass
class Nesting:
nested: Nested
since: datetime.date
created: datetime.datetime
mapping: dict[str, int]
array: list[int]
int_array: list[int]
struct_array: list[NestedWithDict]


def test_appends_complex_types(ws, env_or_skip, make_random) -> None:
Expand All @@ -27,10 +34,10 @@ def test_appends_complex_types(ws, env_or_skip, make_random) -> None:
sql_backend.save_table(
full_name,
[
Nested(Foo("a", True), today, now, {"a": 1, "b": 2}, [1, 2, 3]),
Nested(Foo("b", False), today, now, {"c": 3, "d": 4}, [4, 5, 6]),
Nesting(Nested("a", True), today, now, {"a": 1, "b": 2}, [1, 2, 3], [NestedWithDict("s", {"f1": "v1", "f2": "v2"})]),
Nesting(Nested("b", False), today, now, {"c": 3, "d": 4}, [4, 5, 6], []),
],
Nested,
Nesting,
)
rows = list(sql_backend.fetch(f"SELECT * FROM {full_name}"))
assert len(rows) == 2

0 comments on commit 3b567d7

Please sign in to comment.