Skip to content

Add unified query parser API#5274

Draft
dai-chen wants to merge 1 commit intoopensearch-project:mainfrom
dai-chen:feature/unified-query-parser
Draft

Add unified query parser API#5274
dai-chen wants to merge 1 commit intoopensearch-project:mainfrom
dai-chen:feature/unified-query-parser

Conversation

@dai-chen
Copy link
Collaborator

@dai-chen dai-chen commented Mar 26, 2026

Description

Extract parsing logic from UnifiedQueryPlanner into a UnifiedQueryParser<R> interface with language-specific implementations: PPLQueryParser (returns UnresolvedPlan) and CalciteSqlQueryParser (returns SqlNode).

Implementation Notes

  • Context-owned parser: Following the Spark/Flink pattern, UnifiedQueryContext creates and owns the parser, ensuring consistent configuration across all components.
  • No parse with visitor API yet: A language-neutral parse(query, visitor) was explored but deferred. PPL's custom AST and Calcite's SqlNode tree have fundamentally different node structures. Until this tension resolves, callers use native visitors on the typed parse(query) result.

Related Issues

Part of #5248

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dai-chen dai-chen self-assigned this Mar 26, 2026
@dai-chen dai-chen added the enhancement New feature or request label Mar 26, 2026
@github-actions
Copy link
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen force-pushed the feature/unified-query-parser branch from 0676f32 to 9ed26fe Compare March 26, 2026 22:29
@github-actions
Copy link
Contributor

Failed to generate code suggestions for PR

@dai-chen dai-chen force-pushed the feature/unified-query-parser branch from 9ed26fe to eb41b88 Compare March 26, 2026 22:45
@github-actions
Copy link
Contributor

Failed to generate code suggestions for PR

Extract parsing logic from UnifiedQueryPlanner into a UnifiedQueryParser
interface with language-specific implementations: PPLQueryParser (returns
UnresolvedPlan) and CalciteSqlQueryParser (returns SqlNode).

UnifiedQueryContext owns the parser instance, created eagerly by the
builder which has direct access to query type and future SQL config.
Each implementation receives only its required dependencies:
PPLQueryParser takes Settings, CalciteSqlQueryParser takes
CalcitePlanContext. UnifiedQueryPlanner.CustomVisitorStrategy now obtains
the parser from the context via the interface type.

Signed-off-by: Chen Dai <daichen@amazon.com>
@dai-chen dai-chen force-pushed the feature/unified-query-parser branch from eb41b88 to 0fc6009 Compare March 26, 2026 22:48
@github-actions
Copy link
Contributor

Failed to generate code suggestions for PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant