Skip to content

[Bug]:Non-ASCII / # table names discovered from Snowflake cannot be queried from Playground, and the UI hides the real error #197

Description

@segashu-aws

Description

A Snowflake table whose name contains Japanese characters or # scans, approves (via Approve source) and induces fine, but any Playground question that targets it fails. Depending on how the LLM quotes the identifier, the failure happens at three different places — none of which is surfaced to the user. Playground always answers with a generic "the provided context does not contain information about …", so the user cannot tell that a query was generated and rejected.

Environment

  • Commit ID: Observed on 42b5c6b (tag v0.2.2). sql_generator.py / sql_firewall.py / the discovery path are unchanged on e265573 (tag v0.3.1 = main).
  • Environment: ap-northeast-1 deployment, Snowflake JDBC source, Athena federation (coadevds_* catalog)

Step to reproduce

  • In Snowflake create SALES.ORDERS, SALES."T_売上集計"(ID, "対象年月", AMOUNT) and SALES."売上#2024"("集計ID", "合計金額")
  • Register the source, scan, approve the tables (use Approve source — per-table Approve fails for these names, see [Bug]: Table detail navigation fails for table names containing "#" or non-ASCII characters (i18n) #194), run Induction, Accept
  • Playground: "ORDERS テーブルの件数を教えて" → succeeds (SELECT COUNT(*) … FROM ORDERS, Athena SUCCEEDED) — control case
  • Playground: "売上#2024 の 2024 年の合計金額は?" → generic no-context answer
  • Playground: "T_売上集計 の 合計金額 の合計は?" → generic no-context answer
  • Playground: '"T_売上集計" テーブル (double-quote the identifier) の AMOUNT の合計は?' → generic no-context answer
  • Check the context-manager log group and the Athena workgroup history — the failures below are only visible there

A root cause

Same root, three failure points:

Generated SQL Where it dies Evidence
… FROM 売上#2024 (unquoted, #) COA's own SQL firewall: sqlglot.parse_one() raises ParseError → sql_firewall_parse_error → treated as unsafe_sql_attempt and discarded. Athena is never called. packages/context-manager/src/coa_serve/tier2/sql_firewall.py L386-389
… FROM T_売上集計 (unquoted, non-ASCII) Athena rejects at StartQueryExecution: InvalidRequestException … line 1:36: mismatched input '売' … AthenaErrorCode: MALFORMED_QUERY (≈90 ms, 2 shots, then strategy_all_failed) context-manager log nl_to_sql_execute_failed error=InvalidRequestException
… FROM "T_売上集計" (quoted) Athena federation → Glue: HIVE_METASTORE_ERROR: Unsupported Federation Resource - Invalid table or column names. (Service: AWSGlue; Status Code: 400; Error Code: ValidationException) Athena query-execution record (see below); this is the exact message the customer reported

Athena query-execution record for the third case:

Query: SELECT COALESCE(SUM(AMOUNT), 0) AS total_amount FROM "T_売上集計" LIMIT 10000
State: FAILED
StateChangeReason: HIVE_METASTORE_ERROR: Unsupported Federation Resource - Invalid table or column names. (Service: AWSGlue; Status Code: 400; Error Code: ValidationException; Request ID: 9802675a-8170-4267-aaf3-290f087afa14; Proxy: null)

Contributing code:

  • packages/context-manager/src/coa_serve/tier2/nl_to_sql/sql_generator.py L137-145 — the Athena dialect rules tell the model about Trino functions and date literals but say nothing about quoting identifiers, so quoting is left to chance.
  • Discovery (packages/sources/src/coa_sources/database/…) accepts every table name the JDBC driver returns and never checks it against what Athena federation can address; the unusable name is only discovered at query time.
  • Playground UI: nl_to_sql_execute_failed / sql_firewall_parse_error fall through to the SPARQL/Ontop path and the final answer is the LLM's "no information in context" — the Athena/Glue error text never reaches the user.

Fix (proposal)

  1. Detect at scan time: flag tables/columns whose identifiers Athena federation cannot address (non-ASCII, #, other reserved characters) with a visible warning on the table row, and exclude them from the queryable surface (or document the limitation) instead of failing silently later.
  2. Quote identifiers deterministically in the SQL post-processing step (the firewall already parses the SQL with sqlglot; re-emitting with identify=True would quote every identifier) rather than relying on the model.
  3. Surface the error: when every strategy fails, show the underlying engine error (or at least "query generated but rejected by Athena: …") instead of the generic no-context text.

Context

Reported by a customer evaluating v0.2.2 on ap-northeast-1 with a Snowflake source ("Playground cannot read Snowflake table data: AthenaQueryError … HIVE_METASTORE_ERROR: Unsupported Federation Resource - Invalid table or column names"). Related: #194 (the same names break the table detail page and per-table Approve).

Additional Information / References

Control case (ASCII table name, same path, succeeds):

Image

Quoted Japanese identifier — Athena rejected it (record above) but the UI shows a generic no-context answer:

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions