Skip to content

Commit

Permalink
fix(ingest/snowflake): fix regression in approx count distinct (datah…
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored and Eric Yomi committed Feb 8, 2023
1 parent 2b4ff94 commit bb1eb41
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def get_column_unique_count_patch(self: SqlAlchemyDataset, column: str) -> int:
).select_from(self._table)
)
return convert_to_json_serializable(element_values.fetchone()[0])
elif self.engine.dialect.name.lower() in {"bigquery", "snowflake"}:
elif self.engine.dialect.name.lower() == "bigquery":
element_values = self.engine.execute(
sa.select(
[
Expand All @@ -130,6 +130,13 @@ def get_column_unique_count_patch(self: SqlAlchemyDataset, column: str) -> int:
).select_from(self._table)
)
return convert_to_json_serializable(element_values.fetchone()[0])
elif self.engine.dialect.name.lower() == "snowflake":
element_values = self.engine.execute(
sa.select(
sa.func.APPROX_COUNT_DISTINCT(sa.column(column))
).select_from(self._table)
)
return convert_to_json_serializable(element_values.fetchone()[0])
return convert_to_json_serializable(
self.engine.execute(
sa.select([sa.func.count(sa.func.distinct(sa.column(column)))]).select_from(
Expand Down

0 comments on commit bb1eb41

Please sign in to comment.