Files
impala/testdata/workloads/functional-query/queries/QueryTest/date-partitioning.test
Zoltan Borok-Nagy eb8b118db5 IMPALA-10384: Make partition names consistent between BE and FE
In the BE we build partition names with the trailing char '/'. In the FE
we build partition names without a trailing char. We should make this
consistent because this causes some annoying string adjustments in
the FE and can cause hidden bugs.

This patch creates partition names without the trailing '/' both in
the BE and the FE. This follows Hive's behavior that also prints
partition names without the trailing '/'.

Testing:
 * Ran exhaustive tests

Change-Id: I7e40111e2d1148aeb01ebc985bbb15db7d6a6012
Reviewed-on: http://gerrit.cloudera.org:8080/16850
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2020-12-11 19:51:28 +00:00

124 lines
3.4 KiB
Plaintext

====
---- QUERY
# Create a table partitioned by DATE.
create table $DATABASE.dtbl (c date) partitioned by (p date);
---- RESULTS
'Table has been created.'
====
---- QUERY
# Partition value is an invalid DATE literal
alter table $DATABASE.dtbl add partition (p='1300-1-');
---- CATCH
AnalysisException: Invalid date literal: '1300-1-'
====
---- QUERY
alter table $DATABASE.dtbl add partition (p='1300-1-1');
---- RESULTS
'New partition has been added to the table.'
====
---- QUERY
# Date formatted differently referring to the same partition.
alter table $DATABASE.dtbl add partition (p='1300-01-1');
---- CATCH
AnalysisException: Partition spec already exists: (p=DATE '1300-01-01').
====
---- QUERY
# Date partition formatted differently in insert
insert into $DATABASE.dtbl partition (p='1300-1-01') values ('1300-1-1');
---- RESULTS
p=1300-01-01: 1
====
---- QUERY
insert into $DATABASE.dtbl partition (p='1300-01-1') values ('1300-1-02');
---- RESULTS
p=1300-01-01: 1
====
---- QUERY
insert into $DATABASE.dtbl partition (p=DATE '1300-1-1') values ('1300-1-03');
---- RESULTS
p=1300-01-01: 1
====
---- QUERY
# Insert into a new partition
insert into $DATABASE.dtbl partition (p=DATE '1400-01-1') values ('1400-1-1');
---- RESULTS
p=1400-01-01: 1
====
---- QUERY
insert into $DATABASE.dtbl partition (p='1400-1-01') values ('1400-1-2');
---- RESULTS
p=1400-01-01: 1
====
---- QUERY
select p, c from $DATABASE.dtbl;
---- RESULTS
1300-01-01,1300-01-01
1300-01-01,1300-01-02
1300-01-01,1300-01-03
1400-01-01,1400-01-01
1400-01-01,1400-01-02
---- TYPES
DATE,DATE
====
---- QUERY
# Create a table partitioned by STRING and fill up with date-like values.
create table $DATABASE.stbl (c string) partitioned by (p string);
insert into $DATABASE.stbl partition (p='1400-1-1') values ('1400-1-3');
insert into $DATABASE.stbl partition (p='1400-1-01') values ('1400-01-4');
insert into $DATABASE.stbl partition (p='1400-01-01') values ('400-01-4');
insert into $DATABASE.stbl partition (p='1400-01-') values ('1400-01-5');
insert into $DATABASE.stbl partition (p='1500-01-1') values ('1500-01-1');
====
---- QUERY
# Use dynamic partition specification in insert.
# When the implicit cast fails, insert fails with error
insert into $DATABASE.dtbl partition(p) select * from $DATABASE.stbl where p='1400-01-01';
---- CATCH
UDF ERROR: String to Date parse failed. Invalid string val: '400-01-4'
====
---- QUERY
insert into $DATABASE.dtbl partition(p) select * from $DATABASE.stbl where p='1400-01-';
---- CATCH
UDF ERROR: String to Date parse failed. Invalid string val: '1400-01-'
====
---- QUERY
# Use dynamic partition specification in insert.
# Test that STRING is implicitly cast to DATE.
insert into $DATABASE.dtbl partition(p) select * from $DATABASE.stbl
where p in ('1400-1-1', '1400-1-01', '1500-01-1');
---- RESULTS
p=1400-01-01: 2
p=1500-01-01: 1
====
---- QUERY
select p, c from $DATABASE.dtbl;
---- RESULTS
1300-01-01,1300-01-01
1300-01-01,1300-01-02
1300-01-01,1300-01-03
1400-01-01,1400-01-01
1400-01-01,1400-01-02
1400-01-01,1400-01-03
1400-01-01,1400-01-04
1500-01-01,1500-01-01
---- TYPES
DATE,DATE
====
---- QUERY
# Test dropping partitions
alter table $DATABASE.dtbl drop partition(p < '1400-1-1');
---- RESULTS
'Dropped 1 partition(s).'
====
---- QUERY
select p, c from $DATABASE.dtbl;
---- RESULTS
1400-01-01,1400-01-01
1400-01-01,1400-01-02
1400-01-01,1400-01-03
1400-01-01,1400-01-04
1500-01-01,1500-01-01
---- TYPES
DATE,DATE
====