Skip to content

IMPALA-7618: Accept reversed comparators (> / >=) in range partition bounds#87

Open
Kino1994 wants to merge 1 commit intoapache:masterfrom
Kino1994:master
Open

IMPALA-7618: Accept reversed comparators (> / >=) in range partition bounds#87
Kino1994 wants to merge 1 commit intoapache:masterfrom
Kino1994:master

Conversation

@Kino1994
Copy link

@Kino1994 Kino1994 commented Mar 8, 2026

Summary

  • The SQL parser only accepted < and <= operators in Kudu range partition bounds, rejecting logically equivalent forms like VALUES >= X and X > VALUES. This created an inconsistency where SHOW RANGE PARTITIONS displayed bounds using >= notation that couldn't be used in DDL statements (CREATE TABLE, ALTER TABLE ADD/DROP RANGE PARTITION).
  • Adds > and >= alternatives to the opt_lower_range_val and opt_upper_range_val grammar rules, with a new RangeBound class carrying a reversed flag so bounds are normalized (swapped to the correct semantic position) during AST construction.
  • Both reversed and canonical forms now produce identical internal RangePartition representations, ensuring consistent behavior across DDL input, internal representation, and SHOW RANGE PARTITIONS display output.

Test plan

  • New parser tests in ParserTest.java verify VALUES >= expr, VALUES > expr, expr >= VALUES, expr > VALUES parse successfully for CREATE TABLE, ALTER TABLE ADD, and ALTER TABLE DROP with single and multi-column tuples.
  • New analyzer tests in AnalyzeKuduDDLTest.java verify reversed forms pass full semantic analysis against Kudu table definitions.
  • Existing parser and analyzer tests continue to pass, confirming backward compatibility.
  • Manual verification that ALTER TABLE t ADD RANGE PARTITION VALUES >= '2027-01-01' and ALTER TABLE t ADD RANGE PARTITION '2027-01-01' <= VALUES produce identical partitions.

🤖 Generated with Claude Code

…bounds

The SQL parser only accepted '<' and '<=' operators in range partition
bounds, rejecting logically equivalent forms like 'VALUES >= X' and
'X > VALUES'. This created an inconsistency where SHOW RANGE PARTITIONS
displayed bounds using '>=' notation that couldn't be used in DDL.

Fix the parser grammar to accept '>' and '>=' in both opt_lower_range_val
and opt_upper_range_val, marking them as reversed. A new RangeBound class
carries a 'reversed' flag so that createFromRangeWithNormalization() can
swap bounds into their correct semantic positions before constructing the
RangePartition. Both forms now produce identical internal representations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vankodg
Copy link
Contributor

vankodg commented Mar 9, 2026

Thank you for your contribution. Please note that we are using Gerrit Change Requests for code reviews, not Github Pull Requests.
You can find more information here about how to contribute to Impala:

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