Skip to content

Commit

Permalink
add failing test when columns are unordered
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 committed Sep 12, 2023
1 parent f560958 commit 0b3d6c5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,29 @@ def validate(self) -> None:
assert column.name in expected_types
isinstance(column.type, expected_types[column.name])



class SnowflakeTargetUnorderedColumns(TargetFileTestTemplate):

name = "unordered_columns"

def setup(self) -> None:
connector = self.target.default_sink_class.connector_class(self.target.config)
table = f"{self.target.config['database']}.{self.target.config['default_target_schema']}.{self.name}".upper()
connector.connection.execute(
f"""
CREATE OR REPLACE TABLE {table} (
COL1 VARCHAR(16777216),
COL2 BOOLEAN
)
"""
)

@property
def singer_filepath(self) -> Path:
current_dir = Path(__file__).resolve().parent
return current_dir / "target_test_streams" / f"{self.name}.singer"

target_tests = TestSuite(
kind="target",
tests=[
Expand Down Expand Up @@ -475,5 +498,6 @@ def validate(self) -> None:
SnowflakeTargetExistingTable,
SnowflakeTargetExistingTableAlter,
SnowflakeTargetTypeEdgeCasesTest,
SnowflakeTargetUnorderedColumns,
],
)
2 changes: 2 additions & 0 deletions tests/target_test_streams/unordered_columns.singer
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"type": "SCHEMA", "stream": "unordered_columns", "schema": {"properties": {"COL2": {"type": "boolean"}, "COL1": {"type": ["string", "null"]}}}, "key_properties": [], "bookmark_properties": []}
{"type": "RECORD", "stream": "unordered_columns", "record": {"COL2": true, "COL1": "foo"}}

0 comments on commit 0b3d6c5

Please sign in to comment.