Skip to content

Use polyglot-sql in Rust query generation#175

Merged
nicosuave merged 2 commits into
mainfrom
rust-polyglot-sql
May 23, 2026
Merged

Use polyglot-sql in Rust query generation#175
nicosuave merged 2 commits into
mainfrom
rust-polyglot-sql

Conversation

@nicosuave

@nicosuave nicosuave commented May 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a target dialect to the pure Rust SQL generator and uses it for symmetric aggregate SQL instead of hardcoding DuckDB.
  • Routes Rust filter expression rewriting through polyglot-sql when parsing succeeds, with the existing string rewrite as fallback for legacy filter forms.
  • Broadens Rust SQL metric parsing so known top-level aggregates preserve complex arguments, MEDIAN() maps correctly, COUNT(DISTINCT ...) normalizes, and unknown function calls stay expression metrics.
  • Keeps the related SQL correctness fixes for relative-date intervals, DuckDB symmetric hash casting, and running-total window frames.

@nicosuave nicosuave force-pushed the rust-polyglot-sql branch from 15c979b to c46035e Compare May 23, 2026 19:32
@nicosuave nicosuave marked this pull request as ready for review May 23, 2026 19:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c46035eff3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +677 to +679
if !rest.chars().next()?.is_whitespace() {
return None;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Parse COUNT(DISTINCT(...)) as count_distinct

The new top-level metric parser only treats COUNT as distinct when DISTINCT is followed by whitespace, so inputs like COUNT(DISTINCT(customer_id)) now fall through as plain count with sql = "DISTINCT(customer_id)". In practice this generates invalid/incorrect SQL (DISTINCT(customer_id) as a projected expression plus COUNT(...)) instead of COUNT(DISTINCT ...), which regresses valid metric definitions that use the parenthesized DISTINCT form.

Useful? React with 👍 / 👎.

@nicosuave nicosuave merged commit e31216c into main May 23, 2026
16 checks passed
@nicosuave nicosuave deleted the rust-polyglot-sql branch May 23, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant