Skip to content

fix(presto): respect date part boundary semantics in DATE_DIFF transpilation - #7911

Merged
georgesittas merged 1 commit into
mainfrom
jo/date_diff_boundary_fix
Jul 20, 2026
Merged

fix(presto): respect date part boundary semantics in DATE_DIFF transpilation#7911
georgesittas merged 1 commit into
mainfrom
jo/date_diff_boundary_fix

Conversation

@georgesittas

Copy link
Copy Markdown
Collaborator

Fixes BigQuery DATETIME_DIFF (and improves DATE_DIFF Snowflake, MySQL diffs) transpilation to Presto/Trino. Presto's DATE_DIFF counts complete units while BigQuery, Snowflake, MySQL count boundary crossings, so the Presto generator now truncates both operands to the unit when date_part_boundary is set, with a day-shift to realign Presto's Monday-based DATE_TRUNC('WEEK') to the requested week start.

…ilation

Fixes BigQuery `DATETIME_DIFF` (and improves `DATE_DIFF` Snowflake, MySQL diffs) transpilation to Presto/Trino. Presto's `DATE_DIFF` counts complete units while BigQuery, Snowflake, MySQL count boundary crossings, so the Presto generator now truncates both operands to the unit when `date_part_boundary` is set, with a day-shift to realign Presto's Monday-based `DATE_TRUNC('WEEK')` to the requested week start.

This comment was marked as resolved.

@github-actions

Copy link
Copy Markdown
Contributor

SQLGlot Integration Test Results

✅ All tests passed

Comparing:

  • this branch (sqlglot:jo/date_diff_boundary_fix @ sqlglot e0e399f)
  • baseline (main @ sqlglot a85eeff)

Overall

main: 192414 total, 153544 passed (pass rate: 79.8%)

sqlglot:jo/date_diff_boundary_fix: 188352 total, 150240 passed (pass rate: 79.8%)

Transitions:
No change

Dialect pair changes: 0 previous results not found, 1 current results not found

✅ All tests passed

@georgesittas
georgesittas merged commit 24d6d73 into main Jul 20, 2026
9 checks passed
@georgesittas
georgesittas deleted the jo/date_diff_boundary_fix branch July 20, 2026 13:52
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.

3 participants