Skip to content

fix(oracle): map ISO week-numbering year IYYY to %G [CLAUDE] - #8675

Merged
georgesittas merged 1 commit into
tobymao:mainfrom
vidigoat:fix/oracle-iso-week-format
Oct 19, 2026
Merged

georgesittas merged 1 commit into
tobymao:mainfrom
vidigoat:fix/oracle-iso-week-format

Conversation

@vidigoat

Copy link
Copy Markdown
Contributor

Oracle's TIME_MAPPING already maps IW (ISO 8601 week) to %V, but not IYYY (the ISO 8601 week-numbering year), so %G coming from another dialect is emitted into Oracle's TO_CHAR as a literal:

sqlglot.transpile("SELECT STRFTIME(x, '%G-%V')", read="duckdb", write="oracle")
# before: SELECT TO_CHAR(x, '%G-IW')
# after:  SELECT TO_CHAR(x, 'IYYY-IW')

sqlglot.transpile("SELECT FORMAT_DATE('%G-%V', x)", read="bigquery", write="oracle")
# before: SELECT TO_CHAR(CAST(x AS DATE), '%G-IW')
# after:  SELECT TO_CHAR(CAST(x AS DATE), 'IYYY-IW')

Oracle documents IYYY as the "4-digit year of the year containing the calendar week, as defined by the ISO 8601 standard" (https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Format-Models.html), which is what %G means. Per the same table, IW and IYYY are valid in TO_CHAR but not in the TO_* conversion functions, so the new tests only cover the TO_CHAR direction. This is the Oracle counterpart of #8672 (Postgres, merged).

Tests: two validate_all cases in tests/dialects/test_oracle.py (DuckDB and BigQuery into Oracle). Both fail on main and pass with this change; the full unittest suite (1477 tests) and pre-commit run --all-files (ruff, ruff-format, mypy) pass locally.

Developed with Claude Code (AI) on my behalf.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@georgesittas
georgesittas merged commit 9e57e44 into tobymao:main Oct 19, 2026
9 checks passed
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.

2 participants