Skip to content

Add UNION ALL to the unified query SQL path#5506

Open
dai-chen wants to merge 1 commit into
opensearch-project:mainfrom
dai-chen:feature/sql-v2-union-minus
Open

Add UNION ALL to the unified query SQL path#5506
dai-chen wants to merge 1 commit into
opensearch-project:mainfrom
dai-chen:feature/sql-v2-union-minus

Conversation

@dai-chen
Copy link
Copy Markdown
Collaborator

@dai-chen dai-chen commented Jun 2, 2026

Description

Adds SQL UNION ALL support to the unified query path; the legacy V2 engine continues to reject UNION and fall back. UNION (DISTINCT) and MINUS are deferred because the Analytics Engine currently supports only UNION ALL (PPL-only).

  • Known limitation: a trailing ORDER BY/LIMIT binds to the last SELECT branch instead of the entire unioned result; fixing it would require major changes to the querySpecification grammar that could impact all V2 SQL queries.

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.

Add UNION and UNION ALL set operations to the Calcite-based unified
query path. Extend the SQL grammar with a unionSelect rule, add a
distinct-aware Union AST node and DSL factory, and translate to a
Calcite LogicalUnion (all=true for UNION ALL, all=false for UNION).

The legacy V2 SQL engine rejects UNION with a SyntaxCheckException so
queries fall back to the legacy engine appropriately.

Signed-off-by: Chen Dai <daichen@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request SQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant