Skip to content

Commit

Permalink
use float/double when json type is number
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 committed Aug 9, 2023
1 parent 045b614 commit 2ba8bd3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion target_snowflake/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def to_sql_type(jsonschema_type: dict) -> sqlalchemy.types.TypeEngine:
TypeMap(th._jsonschema_type_check, NUMBER(), ("integer",)),
TypeMap(th._jsonschema_type_check, VARIANT(), ("object",)),
TypeMap(th._jsonschema_type_check, VARIANT(), ("array",)),
TypeMap(th._jsonschema_type_check, NUMBER(precision=num_precision, scale=num_scale), ("number",)),
TypeMap(th._jsonschema_type_check, sct.DOUBLE(), ("number",)),
]
# apply type maps
if th._jsonschema_type_check(jsonschema_type, ("string",)):
Expand Down
8 changes: 2 additions & 6 deletions tests/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def validate(self) -> None:
table_schema = connector.get_table(table)
expected_types = {
"id": sct.NUMBER,
"a1": sct.NUMBER,
"a1": sct.DOUBLE,
"a2": sct.STRING,
"a3": sqlalchemy.types.BOOLEAN,
"a4": sct.VARIANT,
Expand Down Expand Up @@ -435,7 +435,7 @@ def validate(self) -> None:
expected_types = {
"id": sct.NUMBER,
"col_max_length_str": sct.STRING,
"col_multiple_of": sct.NUMBER,
"col_multiple_of": sct.DOUBLE,
"_sdc_extracted_at": sct.TIMESTAMP_NTZ,
"_sdc_batched_at": sct.TIMESTAMP_NTZ,
"_sdc_received_at": sct.TIMESTAMP_NTZ,
Expand All @@ -446,10 +446,6 @@ def validate(self) -> None:
for column in table_schema.columns:
assert column.name in expected_types
isinstance(column.type, expected_types[column.name])
if column.name == "col_multiple_of":
assert column.type.precision == 38
assert column.type.scale == 4


target_tests = TestSuite(
kind="target",
Expand Down

0 comments on commit 2ba8bd3

Please sign in to comment.