Skip to content

Commit

Permalink
Metadata query speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
edurdevic committed Sep 29, 2023
1 parent 5f4ba17 commit abdb87d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions discoverx/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,20 @@ def _get_table_list_sql(self, catalogs: str, schemas: str, tables: str, columns:
string: The SQL expression
"""

catalog_sql = f"""AND regexp_like(table_catalog, "^{catalogs.replace("*", ".*")}$")"""
schema_sql = f"""AND regexp_like(table_schema, "^{schemas.replace("*", ".*")}$")"""
table_sql = f"""AND regexp_like(table_name, "^{tables.replace("*", ".*")}$")"""
if "*" in catalogs:
catalog_sql = f"""AND regexp_like(table_catalog, "^{catalogs.replace("*", ".*")}$")"""
else:
catalog_sql = f"""AND table_catalog = "{catalogs}" """

Check warning on line 62 in discoverx/explorer.py

View check run for this annotation

Codecov / codecov/patch

discoverx/explorer.py#L62

Added line #L62 was not covered by tests

if "*" in schemas:
schema_sql = f"""AND regexp_like(table_schema, "^{schemas.replace("*", ".*")}$")"""
else:
schema_sql = f"""AND table_schema = "{schemas}" """

Check warning on line 67 in discoverx/explorer.py

View check run for this annotation

Codecov / codecov/patch

discoverx/explorer.py#L67

Added line #L67 was not covered by tests

if "*" in tables:
table_sql = f"""AND regexp_like(table_name, "^{tables.replace("*", ".*")}$")"""
else:
table_sql = f"""AND table_name = "{tables}" """

if columns:
match_any_col = "|".join([f'({c.replace("*", ".*")})' for c in columns])
Expand Down

0 comments on commit abdb87d

Please sign in to comment.