Hi Boris, I think you accidentally copy-pasted the same example twice but I get the point and managed to reproduce what you observed. I made a research in the code about what syntax Impala accepts here and this is the relevant code I found: https://github.com/cloudera/Impala/blob/cdh5-trunk/fe/src/main/cup/sql-parser.cup#L1388
As I read, in the 'PARTITION BY' you can either have a: - list of HASH PARTITIONS or - RANGE PARTITIONS or - a list of HASH PARTITIONS followed by a COMMA and then by RANGE PARTITIONS. Please note the comment by this section: https://github.com/cloudera/Impala/blob/cdh5-trunk/fe/src/main/cup/sql-parser.cup#L1381 // The PARTITION BY clause contains any number of HASH() clauses followed by exactly zero // or one RANGE clauses Is it mentioned somewhere in the docs that this can be done the other way around? Note, I'm not sure which Impala version you use, I took cdh5-trunk to do this research. I hope this helps! Gabor On Tue, Oct 9, 2018 at 3:39 PM Boris Tyukin <[email protected]> wrote: > Hey guys, > > we've reviewed the docs but still not sure why query 1 works fine and > query 2 errors out with a syntax error. The only difference is that I have > Hash partition first and then a Range. > > ERROR: AnalysisException: Syntax error in line 13: > ), > ^ > Encountered: COMMA > Expected: AS, CACHED, COMMENT, LOCATION, ROW, SORT, STORED, TBLPROPERTIES, > UNCACHED, WITH > CAUSED BY: Exception: Syntax error > > > > *Query 1:* > > CREATE TABLE test2 > ( > source_system_id BIGINT, > id1 BIGINT, > id2 BIGINT, > name STRING, > PRIMARY KEY (source_system_id,id1,id2) > ) > PARTITION BY > RANGE(source_system_id) ( > PARTITION VALUE = 10000000, > PARTITION VALUE = 20000000, > PARTITION VALUE = 30000000 > ), > HASH(id1,id2) PARTITIONS 10 > STORED AS KUDU; > > *Query 2:* > > CREATE TABLE test2 > ( > source_system_id BIGINT, > id1 BIGINT, > id2 BIGINT, > name STRING, > PRIMARY KEY (source_system_id,id1,id2) > ) > PARTITION BY > RANGE(source_system_id) ( > PARTITION VALUE = 10000000, > PARTITION VALUE = 20000000, > PARTITION VALUE = 30000000 > ), > HASH(id1,id2) PARTITIONS 10 > STORED AS KUDU; >
