Skip to content

Fix BigQuery DATE_TRUNC syntax using sqlglot dialect#7

Merged
nicosuave merged 1 commit intomainfrom
fix-bigquery-date-trunc-syntax
Dec 3, 2025
Merged

Fix BigQuery DATE_TRUNC syntax using sqlglot dialect#7
nicosuave merged 1 commit intomainfrom
fix-bigquery-date-trunc-syntax

Conversation

@nicosuave
Copy link
Copy Markdown
Member

@nicosuave nicosuave commented Dec 3, 2025

Summary

  • Use sqlglot's exp.DateTrunc for dialect-aware DATE_TRUNC generation in SQLGenerator
  • Add dialect parameter to RelativeDateRange.parse() and to_range() methods
  • BigQuery: DATE_TRUNC(column, MONTH)
  • PostgreSQL/DuckDB: DATE_TRUNC('month', column)

Changes

  • Add _date_trunc() helper method to SQLGenerator
  • Replace hardcoded DATE_TRUNC strings in CTE builder, window functions, and pre-aggregation rollups
  • Update RelativeDateRange to generate dialect-specific DATE_TRUNC
  • Generator passes dialect to RelativeDateRange calls
  • CI: Skip Rust/DuckDB extension jobs when those files haven't changed

Copy link
Copy Markdown

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

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.

ℹ️ 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 thread sidemantic/sql/generator.py Outdated
@nicosuave nicosuave force-pushed the fix-bigquery-date-trunc-syntax branch from d1581bd to a62983f Compare December 3, 2025 15:44
BigQuery requires DATE_TRUNC(column, MONTH) while PostgreSQL/DuckDB use
DATE_TRUNC('month', column). Use sqlglot's DateTrunc expression with
dialect-specific generation instead of hardcoded string formatting.
@nicosuave nicosuave force-pushed the fix-bigquery-date-trunc-syntax branch from a62983f to b7645e8 Compare December 3, 2025 15:49
@nicosuave nicosuave merged commit b592a90 into main Dec 3, 2025
14 of 15 checks passed
@nicosuave nicosuave deleted the fix-bigquery-date-trunc-syntax branch December 3, 2025 16:12
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