mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-04 10:52:13 +02:00
fix(sl): correct reserved-word/week-grain SQL and classify sl_query errors (#340)
Reserved-word columns (like, default, ...) referenced as source.col were quoted with postgres double quotes even on BigQuery/MySQL, where a double-quoted token is a string literal, not an identifier -- the "Unexpected string literal" semantic-layer errors. quote_reserved_identifiers now uses the identifier quote char of the dialect it will be parsed in (backtick for BigQuery/MySQL), threaded through the planner and generator parse sites; week_<weekday> granularity now emits WEEK(<weekday>) on BigQuery instead of the invalid WEEK_MONDAY. On the telemetry side, warehouse rejections from the sl_query execution path are classified as expected (KtxQueryError) via a new shared markExpected() helper, so routine agent/warehouse query failures stop reaching PostHog Error Tracking as ktx faults; the sql_execution catch is refactored onto the same helper. The daemon-compile boundary is deliberately left unclassified here so genuine daemon crashes stay visible.
This commit is contained in:
parent
a0d19ba26f
commit
4ebce75449
6 changed files with 156 additions and 21 deletions
|
|
@ -694,7 +694,8 @@ class QueryPlanner:
|
|||
all_dep_names.add(dep_name)
|
||||
named.add(dep_name)
|
||||
tree = sqlglot.parse_one(
|
||||
f"SELECT {quote_reserved_identifiers(expr)}", dialect=self.dialect
|
||||
f"SELECT {quote_reserved_identifiers(expr, self.dialect)}",
|
||||
dialect=self.dialect,
|
||||
)
|
||||
|
||||
def _replace(node):
|
||||
|
|
@ -738,7 +739,8 @@ class QueryPlanner:
|
|||
"""Reject expressions with nested aggregate functions (e.g., avg(sum(x)))."""
|
||||
try:
|
||||
tree = sqlglot.parse_one(
|
||||
f"SELECT {quote_reserved_identifiers(expr)}", dialect=self.dialect
|
||||
f"SELECT {quote_reserved_identifiers(expr, self.dialect)}",
|
||||
dialect=self.dialect,
|
||||
)
|
||||
for agg_node in tree.find_all(exp.AggFunc):
|
||||
# Check if this aggregate contains another aggregate inside
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue