Skip to content

Add UNION ALL to the unified query SQL path#5506

Merged
dai-chen merged 1 commit into
opensearch-project:mainfrom
dai-chen:feature/sql-v2-union-minus
Jun 3, 2026
Merged

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

Conversation

@dai-chen

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

Copy link
Copy Markdown
Collaborator

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>
@dai-chen dai-chen merged commit ea39ffd into opensearch-project:main Jun 3, 2026
49 of 50 checks passed
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.

3 participants