[ 
https://issues.apache.org/jira/browse/IMPALA-7618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18095493#comment-18095493
 ] 

ASF subversion and git services commented on IMPALA-7618:
---------------------------------------------------------

Commit 4c497d62c6d30884a6b00fd24058ff7c5fd1820c in impala's branch 
refs/heads/master from Kino1994
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=4c497d62c ]

IMPALA-7618: Accept reversed comparators (> / >=) in range partition 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 the range bound rules
(renamed to expr_cmp_range_val and cmp_expr_range_val, since either can
denote a lower or an upper bound). Each rule normalizes its comparator to
the canonical 'bound <cmp> VALUES' form, so a RangeBound with a '<' / '<='
comparator always denotes a lower bound and a '>' / '>=' comparator an
upper bound. RangeBound exposes this via a BoundType enum (LOWER_BOUND,
UPPER_BOUND) and a boundType() method.

createFromRangeWithNormalization() uses boundType() to place each bound on
its correct side regardless of syntactic position, so canonical and
reversed forms produce identical internal representations. It now also
rejects specifications where both bounds constrain the same side, e.g.
'4 > VALUES < 2' or '4 < VALUES > 1'.

Testing:
- ParserTest: added reversed-comparator forms for CREATE TABLE and
  ALTER TABLE ADD/DROP RANGE PARTITION.
- AnalyzeKuduDDLTest: added reversed-comparator forms (including both
  bounds reversed) and error cases for same-side bounds.

Change-Id: Ia12668537bfc72cc9399a60f68ca7608422b35c2
Generated-by: Claude Opus 4.8
Reviewed-on: http://gerrit.cloudera.org:8080/24095
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>


> Kudu table Create/Alter syntax should accept 'VALUES <= <lit>'
> --------------------------------------------------------------
>
>                 Key: IMPALA-7618
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7618
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Frontend
>    Affects Versions: Impala 2.2.0
>            Reporter: Dan Burkert
>            Assignee: Joaquín Antonio De Vicente López
>            Priority: Major
>             Fix For: Impala 5.0.0
>
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> Currently Impala allows the {{PARTITION 200 <= VALUES}} syntax to specify an 
> unbounded-above range partition in a Kudu table, but not {{PARTITION VALUES 
> >= 200}}.  Since these expressions are equivalent it would be nice if both 
> were accepted.
>  
> I would normally consider this an improvement and not a bug, however there is 
> currently a mismatch between how Kudu pretty-prints these partitions and how 
> Impala parses them.  This mismatch makes it very likely that users will hit 
> this issue and be stumped.  For example:
>  
> {code:java}
> > CREATE TABLE dan_test (a int, PRIMARY KEY (a))
>   PARTITION BY RANGE (a) (
>     PARTITION 0 <= VALUES < 100,
>     PARTITION VALUES >= 200
>   ) STORED AS KUDU;
>     ERROR: AnalysisException: Syntax error in line 4:
>         PARTITION VALUES >= 200
>                         ^
>     Encountered: >
>     Expected: COMMA
>     CAUSED BY: Exception: Syntax error
> > CREATE TABLE dan_test (a int, PRIMARY KEY (a))
>   PARTITION BY RANGE (a) (
>     PARTITION 0 <= VALUES < 100,
>     PARTITION 200 <= VALUES
>   ) STORED AS KUDU;
>     +-------------------------+
>     | summary                 |
>     +-------------------------+
>     | Table has been created. |
>     +-------------------------+
>     Fetched 1 row(s) in 1.65s
> > SHOW RANGE PARTITIONS dan_test;
>     +-------------------+
>     | RANGE (a)         |
>     +-------------------+
>     | 0 <= VALUES < 100 |
>     | VALUES >= 200     |
>     +-------------------+
>     Fetched 2 row(s) in 3.73s
> > ALTER TABLE dan_test DROP RANGE PARTITION VALUES >= 100;
>     Query: ALTER TABLE dan_test DROP RANGE PARTITION VALUES >= 100
>     ERROR: AnalysisException: Syntax error in line 1:
>     ALTER TABLE dan_test DROP RANGE PARTITION VALUES >= 100
>                                                     ^
>     Encountered: >
>     Expected: COMMA
>     CAUSED BY: Exception: Syntax error
> > ALTER TABLE dan_test DROP RANGE PARTITION 100 <= VALUES;
>     Query: ALTER TABLE dan_test DROP RANGE PARTITION 100 <= VALUES
>     ERROR: ImpalaRuntimeException: Error dropping range partition in table 
> dan_test
>     CAUSED BY: NonRecoverableException: No range partition found for drop 
> range partition step: VALUES >= 100
> > ALTER TABLE dan_test DROP RANGE PARTITION 200 <= VALUES;
>     Query: ALTER TABLE dan_test DROP RANGE PARTITION 200 <= VALUES
>     +-----------------------------------+
>     | summary                           |
>     +-----------------------------------+
>     | Range partition has been dropped. |
>     +-----------------------------------+
>     Fetched 1 row(s) in 0.10s
> > SHOW PARTITIONS dan_test;
>     Query: SHOW PARTITIONS dan_test
>     
> +--------+-----------+----------+-----------------------------------+------------+
>     | # Rows | Start Key | Stop Key | Leader Replica                    | # 
> Replicas |
>     
> +--------+-----------+----------+-----------------------------------+------------+
>     | -1     | 80000000  | 80000064 | nightly6x-4.vpc.cloudera.com:7050 | 3   
>        |
>     
> +--------+-----------+----------+-----------------------------------+------------+
>     Fetched 1 row(s) in 0.04s{code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to