Skip to content

fix(optimizer)!: T-SQL Sunday week start, connector grouping and DPipe safe flag in simplify - #8017

Merged
georgesittas merged 1 commit into
mainfrom
jo/paren-tsql
Aug 3, 2026
Merged

fix(optimizer)!: T-SQL Sunday week start, connector grouping and DPipe safe flag in simplify#8017
georgesittas merged 1 commit into
mainfrom
jo/paren-tsql

Conversation

@georgesittas

Copy link
Copy Markdown
Collaborator
  • Set WEEK_OFFSET = -1 for T-SQL: DATETRUNC(week, ...) follows @@DATEFIRST, which defaults to 7 (Sunday)
  • Parenthesize the NOT NULL -> NULL AND TRUE rewrite when it lands under NOT or a different connector, so the generated SQL reparses with the same grouping
  • Preserve the safe flag when simplify_concat rebuilds || chains, keeping the coercing CONCAT(CAST(...)) form on transpilation to strict dialects

…e safe flag in simplify

- Set `WEEK_OFFSET = -1` for T-SQL: `DATETRUNC(week, ...)` follows `@@DATEFIRST`, which defaults to 7 (Sunday)
- Parenthesize the `NOT NULL` -> `NULL AND TRUE` rewrite when it lands under `NOT` or a different connector, so the generated SQL reparses with the same grouping
- Preserve the `safe` flag when `simplify_concat` rebuilds `||` chains, keeping the coercing `CONCAT(CAST(...))` form on transpilation to strict dialects

This comment was marked as resolved.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

SQLGlot Integration Test Results

✅ All tests passed

Comparing:

  • this branch (sqlglot:jo/paren-tsql @ sqlglot 08b5cb2)
  • baseline (main @ sqlglot ea95f80)

Overall

main: 192411 total, 153555 passed (pass rate: 79.8%)

sqlglot:jo/paren-tsql: 180217 total, 142403 passed (pass rate: 79.0%)

Transitions:
No change

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

✅ All tests passed

@geooo109 geooo109 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice!

@georgesittas
georgesittas merged commit 29432ba into main Aug 3, 2026
9 checks passed
@georgesittas
georgesittas deleted the jo/paren-tsql branch August 3, 2026 13:06
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