Skip to content
Merged
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
23 changes: 21 additions & 2 deletions pkg-py/src/querychat/_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ def discover_semantic_views(
if os.environ.get("QUERYCHAT_DISABLE_SEMANTIC_VIEWS"):
return []

rows = execute_raw_sql("SHOW SEMANTIC VIEWS", backend)
try:
rows = execute_raw_sql("SHOW SEMANTIC VIEWS", backend)
except Exception:
logger.warning(
"Failed to discover semantic views. "
"This usually means the current role lacks the required privileges. "
"Semantic view context will not be included in the system prompt.",
exc_info=True,
)
return []
Comment thread
cpsievert marked this conversation as resolved.

if not rows:
logger.debug("No semantic views found in current schema")
Expand Down Expand Up @@ -83,7 +92,17 @@ def get_semantic_view_ddl(
) -> str | None:
"""Get DDL for a semantic view by fully qualified name."""
safe_name = fq_name.replace("'", "''")
rows = execute_raw_sql(f"SELECT GET_DDL('SEMANTIC_VIEW', '{safe_name}')", backend)
try:
rows = execute_raw_sql(
f"SELECT GET_DDL('SEMANTIC_VIEW', '{safe_name}')", backend
)
except Exception:
logger.warning(
"Failed to get DDL for semantic view '%s'. Skipping this view.",
fq_name,
exc_info=True,
)
return None
Comment thread
cpsievert marked this conversation as resolved.
if rows:
return str(next(iter(rows[0].values())))
return None
Expand Down
Loading