Skip to content

Add EXTRACT as a keyword and function in Oracle parser - #948

Merged
gaoxueyu merged 4 commits into
IvorySQL:IVORY_REL_5_STABLEfrom
NotHimmel:IVORY_REL_5_STABLE_extract
Nov 12, 2025
Merged

gaoxueyu merged 4 commits into
IvorySQL:IVORY_REL_5_STABLEfrom
NotHimmel:IVORY_REL_5_STABLE_extract

Conversation

@NotHimmel

@NotHimmel NotHimmel commented Nov 12, 2025 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added full EXTRACT function support for use in SQL expressions within the Oracle-compatible parser, consistent with standard Oracle behavior.
    • EXTRACT keyword is now recognized and usable across multiple contexts including column names, labels, and general expression positions.

@coderabbitai

coderabbitai Bot commented Nov 12, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request introduces support for the EXTRACT SQL function in the Oracle-compatible parser by adding EXTRACT as a recognized keyword in multiple contexts (reserved, column name, and bare label) and enabling it to be parsed as a function call in expressions, mirroring existing PGEXTRACT handling.

Changes

Cohort / File(s) Summary
Grammar and keyword classifications
src/backend/oracle_parser/ora_gram.y
Added EXTRACT to reserved_keyword, col_name_keyword, and bare_label_keyword lists. Introduced new grammar production EXTRACT '(' extract_list ')' in func_expr_common_subexpr to parse EXTRACT(...) as a SystemFuncName("extract") function call.
Keyword registry
src/include/oracle_parser/ora_kwlist.h
Added PG_KEYWORD entry for EXTRACT with COL_NAME_KEYWORD and BARE_LABEL classifications. Minor whitespace normalization.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Changes follow established patterns (mirroring existing PGEXTRACT implementation)
  • Keyword additions are repetitive and localized
  • Single, straightforward grammar production rule addition
  • No complex logic or control flow modifications

Possibly related PRs

Poem

🐰 A carrot parser grows so bright,
EXTRACT keywords, tagged just right—
From extract_list springs the call,
SystemFunc answers all! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding EXTRACT as both a keyword and a function in the Oracle parser, which aligns with the modifications across ora_gram.y and ora_kwlist.h.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5cc67b7 and eaca759.

⛔ Files ignored due to path filters (2)
  • contrib/ivorysql_ora/expected/ora_xml_functions.out is excluded by !**/*.out
  • src/oracle_test/regress/expected/interval_1.out is excluded by !**/*.out
📒 Files selected for processing (2)
  • src/backend/oracle_parser/ora_gram.y (4 hunks)
  • src/include/oracle_parser/ora_kwlist.h (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: oracle_pg_regression (ubuntu-latest)
  • GitHub Check: pg_regression (ubuntu-latest)
  • GitHub Check: meson_build (ubuntu-latest)
  • GitHub Check: contrib_regression
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: oracle_regression (ubuntu-latest)
🔇 Additional comments (1)
src/include/oracle_parser/ora_kwlist.h (1)

203-203: LGTM! No issues found.

Verification confirms exactly one EXTRACT keyword entry exists at line 203 with correct ASCII ordering (external < extract < false) and appropriate categorization (COL_NAME_KEYWORD, BARE_LABEL). Both EXTRACT and PGEXTRACT keywords are properly supported in the grammar rules.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gaoxueyu
gaoxueyu merged commit 9d890e9 into IvorySQL:IVORY_REL_5_STABLE Nov 12, 2025
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