Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/system/data_sources/test_db2.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,11 @@ def test_custom_query_row_validation_core_types_to_bigquery():
)
def test_custom_query_row_concat_validation_core_types_to_bigquery():
"""Db2 to BigQuery dvt_core_types custom-query row concat validation"""
# TODO Add col_dec_10_2 when working on issue-1706.
custom_query_validation_test(
validation_type="row",
source_query="select id,col_int64,col_dec_10_2,COL_VARCHAR_30,col_date from pso_data_validator.dvt_core_types",
target_query="select id,col_int64,col_dec_10_2,col_varchar_30,COL_DATE from pso_data_validator.dvt_core_types",
concat="col_int64,col_varchar_30,col_date",
concat="col_int64,col_dec_10_2,col_varchar_30,col_date",
)


Expand Down
3 changes: 1 addition & 2 deletions third_party/ibis/ibis_db2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def _metadata(self, query) -> Iterable[Tuple[str, dt.DataType]]:
result = con.exec_driver_sql(f"SELECT * FROM {query} t0 LIMIT 1")
cursor = result.cursor
yield from (
(column[0].lower(), _get_type(column[1]))
for column in cursor.description
(column[0].lower(), _get_type(column)) for column in cursor.description
)

def list_primary_key_columns(self, database: str, table: str) -> list:
Expand Down
10 changes: 9 additions & 1 deletion third_party/ibis/ibis_db2/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ def sa_sf_binary(_, satype, nullable=True):
return dt.Binary(nullable=nullable)


def _get_type(typename) -> dt.DataType:
def _get_type(col) -> dt.DataType:
typename = col[1]
typ = _type_mapping.get(typename)
if typ is None:
raise NotImplementedError(f"DB2 type {typename} is not supported")

if typ == dt.Decimal:
precision = col[4]
scale = col[5]
if precision is not None and scale is not None:
return dt.Decimal(precision, scale)

return typ