Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Fix BigQuery code; Upgrade dependencies to latest versions. #339

Merged
merged 2 commits into from
Dec 7, 2022
Merged
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
7 changes: 6 additions & 1 deletion data_diff/sqeleton/databases/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,12 @@ def query(self, sql_ast: Union[Expr, Generator], res_type: type = list):

res = self._query(sql_code)
if res_type is int:
res = _one(_one(res))
if not res:
raise ValueError("Query returned 0 rows, expected 1")
row = _one(res)
if not row:
raise ValueError("Row is empty, expected 1 column")
res = _one(row)
if res is None: # May happen due to sum() of 0 items
return None
return int(res)
Expand Down
2 changes: 1 addition & 1 deletion data_diff/sqeleton/databases/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:
return f"FORMAT_TIMESTAMP('%F %H:%M:%E6S', {timestamp})"

if coltype.precision == 0:
return f"FORMAT_TIMESTAMP('%F %H:%M:%S.000000, {value})"
return f"FORMAT_TIMESTAMP('%F %H:%M:%S.000000', {value})"
elif coltype.precision == 6:
return f"FORMAT_TIMESTAMP('%F %H:%M:%E6S', {value})"

Expand Down
Loading