Skip to content

Commit

Permalink
[DH-4966] Fix scanning table list index out of range error for postgr…
Browse files Browse the repository at this point in the history
…es (#242)
  • Loading branch information
jcjc712 authored and DishenWang2023 committed May 7, 2024
1 parent eb588fc commit 6bbda62
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dataherald/db_scanner/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def get_processed_column( # noqa: PLR0911
rs = db_engine.engine.execute(
f"SELECT n_distinct, most_common_vals::TEXT::TEXT[] FROM pg_catalog.pg_stats WHERE tablename = '{table}' AND attname = '{column['name']}'" # noqa: S608 E501
).fetchall()
if MIN_CATEGORY_VALUE < rs[0]["n_distinct"] <= MAX_CATEGORY_VALUE:
if (
len(rs) > 0
and MIN_CATEGORY_VALUE < rs[0]["n_distinct"] <= MAX_CATEGORY_VALUE
):
return ColumnDetail(
name=column["name"],
data_type=str(column["type"]),
Expand Down

0 comments on commit 6bbda62

Please sign in to comment.