Skip to content

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

Merged
gaoxueyu merged 4 commits into
IvorySQL:masterfrom
NotHimmel:datagrip-extract-support
Nov 12, 2025
Merged

gaoxueyu merged 4 commits into
IvorySQL:masterfrom
NotHimmel:datagrip-extract-support

Conversation

@NotHimmel

@NotHimmel NotHimmel commented Nov 11, 2025 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • EXTRACT function is now fully supported in Oracle-compatible SQL parsing
    • EXTRACT can be used as a column identifier and label in queries

@coderabbitai

coderabbitai Bot commented Nov 11, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ 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

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The Oracle parser grammar has been extended to recognize and parse the EXTRACT keyword as a built-in function. Two files were modified: the grammar rules now include EXTRACT with function-call syntax, and the keyword list declares EXTRACT with appropriate classifications for usage in non-keyword contexts.

Changes

Cohort / File(s) Summary
Oracle Parser Grammar
src/backend/oracle_parser/ora_gram.y
Added EXTRACT to unreserved keywords and new grammar rule enabling EXTRACT '(' extract_list ')' syntax to be parsed as SystemFuncName("extract") function call; classified EXTRACT in col_name_keyword and bare_label_keyword sets
Oracle Parser Keywords
src/include/oracle_parser/ora_kwlist.h
Added extract keyword entry with token EXTRACT, categorized as COL_NAME_KEYWORD and BARE_LABEL; minor whitespace cleanup

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Homogeneous changes following established patterns (mirroring PGEXTRACT support)
  • Keyword addition is straightforward with minimal logic density
  • No complex structural or behavioral modifications

Poem

🐰 A keyword hopped into the parser's domain,
EXTRACT now functions without any strain!
Like PGEXTRACT before it did dance,
The grammar gives each little SELECT a chance.
Thump-thump goes the lexer, hooray goes the tree! 🌟

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 'Add EXTRACT as a keyword and function in Oracle parser' directly and accurately reflects the main changes in the pull request, which adds EXTRACT keyword support and enables it as a callable function in the Oracle parser grammar.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 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 010aa9c and f416382.

📒 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: pg_regression (ubuntu-latest)
  • GitHub Check: oracle_regression (ubuntu-latest)
  • GitHub Check: meson_build (ubuntu-latest)
  • GitHub Check: contrib_regression
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: oracle_pg_regression (ubuntu-latest)
🔇 Additional comments (4)
src/include/oracle_parser/ora_kwlist.h (1)

203-203: Code changes are correct—no issues found.

The EXTRACT keyword addition complements the existing PGEXTRACT keyword, not conflicts with it. Both keywords are intentionally supported in the Oracle parser grammar as synonymous variants: each parses an extract_list and invokes the same SystemFuncName("extract") system function (src/backend/oracle_parser/ora_gram.y lines 18007, 18014). This dual support allows both standard SQL EXTRACT() syntax and Oracle-compatible PGEXTRACT() syntax to work.

src/backend/oracle_parser/ora_gram.y (3)

20870-20874: Bare label inclusion is fine; keep lists alphabetized.

EXTRACT appears in the E-section in bare_label_keyword; ordering looks correct. No further action.


18014-18020: Code structure verified as correct; manual build verification required for parser conflicts.

The EXTRACT grammar arm (lines 18014–18019) is confirmed to mirror PGEXTRACT identically:

  • Both use SystemFuncName("extract")
  • Both reuse extract_list parameter
  • Both apply COERCE_SQL_SYNTAX consistently

However, bison is unavailable in this environment, preventing automated conflict detection. You must run bison -v src/backend/oracle_parser/ora_gram.y locally and verify that ora_gram.output contains no new shift/reduce or reduce/reduce conflicts before merging.


20509-20515: Verification complete: EXTRACT mapping already exists in kwlist.h with correct configuration.

The review comment's concern is already satisfied. The kwlist.h file contains the entry: PG_KEYWORD("extract", EXTRACT, COL_NAME_KEYWORD, BARE_LABEL) with the correct token (EXTRACT), keyword category (COL_NAME_KEYWORD), and bare label status (BARE_LABEL). The scanner will properly emit the EXTRACT token as intended. No further action needed.

Comment on lines +783 to 784
EXTRACT PGEXTRACT PLACING PLAN PLANS POLICY
POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix token ordering: EXTRACT placed in the P-block breaks “alphabetical order” contract.

Move EXTRACT to the E-block (near EXTERNAL) and keep PGEXTRACT in the P-block. This preserves the documented ordering and avoids future merge pain.

Apply:

-    PARALLEL PARAMETER PARSER PARTIAL PARTITION PASSING PASSWORD PATH
-    EXTRACT PGEXTRACT PLACING PLAN PLANS POLICY
+    PARALLEL PARAMETER PARSER PARTIAL PARTITION PASSING PASSWORD PATH
+    PGEXTRACT PLACING PLAN PLANS POLICY

and in the E-block (around the other EX* tokens):

-    EXTENSION EXTERNAL
+    EXTENSION EXTERNAL EXTRACT

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/backend/oracle_parser/ora_gram.y around lines 783-784, the token list
places EXTRACT in the P-block which breaks the alphabetical ordering; move
EXTRACT out of the P-block (leave PGEXTRACT in P-block) and insert EXTRACT into
the E-block near the other EX* tokens (e.g., next to EXTERNAL) so both blocks
remain alphabetically ordered and future merges won't reorder tokens.

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