Files
impala/testdata/workloads/functional-query/queries/QueryTest/kudu_insert.test
Dimitris Tsirogiannis 3db5ced4ce IMPALA-3726: Add support for Kudu-specific column options
This commit adds support for Kudu-specific column options in CREATE
TABLE statements. The syntax is:
CREATE TABLE tbl_name ([col_name type [PRIMARY KEY] [option [...]]] [, ....])
where option is:
| NULL
| NOT NULL
| ENCODING encoding_val
| COMPRESSION compression_algorithm
| DEFAULT expr
| BLOCK_SIZE num

The output of the SHOW CREATE TABLE statement was altered to include all the specified
column options for Kudu tables.

Change-Id: I727b9ae1b7b2387db752b58081398dd3f3449c02
Reviewed-on: http://gerrit.cloudera.org:8080/5026
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Tested-by: Internal Jenkins
2016-11-18 11:41:01 +00:00

334 lines
9.1 KiB
Plaintext

====
---- QUERY
create table tdata
(id int primary key, valf float null, vali bigint null, valv string null,
valb boolean null, valt tinyint null, vals smallint null, vald double null)
DISTRIBUTE BY RANGE (PARTITION VALUES < 10, PARTITION 10 <= VALUES < 30,
PARTITION 30 <= VALUES) STORED AS KUDU
---- RESULTS
====
---- QUERY
# VALUES, single row, all target cols, no errors
insert into tdata values (1, 1, 1, 'one', true, 1, 1, 1)
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
1,1,1,'one',true,1,1,1
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# VALUES, single row, all target cols, NULL
insert into tdata values (2, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
1,1,1,'one',true,1,1,1
2,NULL,NULL,'NULL',NULL,NULL,NULL,NULL
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# VALUES, single row, all target cols, bounday values
insert into tdata values
(3, cast('nan' as float), max_bigint(), '', true, min_tinyint(), max_smallint(),
cast('-inf' as double))
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
1,1,1,'one',true,1,1,1
2,NULL,NULL,'NULL',NULL,NULL,NULL,NULL
3,NaN,9223372036854775807,'',true,-128,32767,-Infinity
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# VALUES, single row, subset of target cols
insert into tdata (valb, vald, id) values (true, 0, 4)
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
1,1,1,'one',true,1,1,1
2,NULL,NULL,'NULL',NULL,NULL,NULL,NULL
3,NaN,9223372036854775807,'',true,-128,32767,-Infinity
4,NULL,NULL,'NULL',true,NULL,NULL,0
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# VALUES, multiple rows, all target cols
insert into tdata values
(5, 5.0, 5, 'five', false, NULL, NULL, NULL),
(6, 16, 60, '', true, 0, -1, -6),
(7, NULL, 10, NULL, false, max_tinyint(), -7, 2)
---- RUNTIME_PROFILE
NumModifiedRows: 3
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
1,1,1,'one',true,1,1,1
2,NULL,NULL,'NULL',NULL,NULL,NULL,NULL
3,NaN,9223372036854775807,'',true,-128,32767,-Infinity
4,NULL,NULL,'NULL',true,NULL,NULL,0
5,5.0,5,'five',false,NULL,NULL,NULL
6,16,60,'',true,0,-1,-6
7,NULL,10,'NULL',false,127,-7,2
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# VALUES, multiple rows, subset of cols
insert into tdata (valv, valf, vali, id) values
('eight', 88, 888, 8),
(NULL, -9, -99, 9)
---- RUNTIME_PROFILE
NumModifiedRows: 2
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
1,1,1,'one',true,1,1,1
2,NULL,NULL,'NULL',NULL,NULL,NULL,NULL
3,NaN,9223372036854775807,'',true,-128,32767,-Infinity
4,NULL,NULL,'NULL',true,NULL,NULL,0
5,5.0,5,'five',false,NULL,NULL,NULL
6,16,60,'',true,0,-1,-6
7,NULL,10,'NULL',false,127,-7,2
8,88,888,'eight',NULL,NULL,NULL,NULL
9,-9,-99,'NULL',NULL,NULL,NULL,NULL
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# SELECT, single row, all target cols
insert into tdata
select id, float_col, bigint_col, string_col, bool_col, tinyint_col, smallint_col, double_col
from functional.alltypes where id = 10
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
1,1,1,'one',true,1,1,1
2,NULL,NULL,'NULL',NULL,NULL,NULL,NULL
3,NaN,9223372036854775807,'',true,-128,32767,-Infinity
4,NULL,NULL,'NULL',true,NULL,NULL,0
5,5.0,5,'five',false,NULL,NULL,NULL
6,16,60,'',true,0,-1,-6
7,NULL,10,'NULL',false,127,-7,2
8,88,888,'eight',NULL,NULL,NULL,NULL
9,-9,-99,'NULL',NULL,NULL,NULL,NULL
10,0,0,'0',true,0,0,0
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# SELECT, single row, subset of cols
insert into tdata (id, vald, valb, vali)
select id, double_col, bool_col, bigint_col
from functional.alltypes where id = 11
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
1,1,1,'one',true,1,1,1
2,NULL,NULL,'NULL',NULL,NULL,NULL,NULL
3,NaN,9223372036854775807,'',true,-128,32767,-Infinity
4,NULL,NULL,'NULL',true,NULL,NULL,0
5,5.0,5,'five',false,NULL,NULL,NULL
6,16,60,'',true,0,-1,-6
7,NULL,10,'NULL',false,127,-7,2
8,88,888,'eight',NULL,NULL,NULL,NULL
9,-9,-99,'NULL',NULL,NULL,NULL,NULL
10,0,0,'0',true,0,0,0
11,NULL,10,'NULL',false,NULL,NULL,10.1
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
delete tdata
---- DML_RESULTS: tdata
====
---- QUERY
# SELECT, multiple rows, all target cols
insert into tdata
select id, float_col, bigint_col, string_col, bool_col, tinyint_col, smallint_col, double_col
from functional.alltypes where id < 2
---- RUNTIME_PROFILE
NumModifiedRows: 2
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
0,0,0,'0',true,0,0,0
1,1.100000023841858,10,'1',false,1,1,10.1
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# SELECT, multiple rows, subset of cols
insert into tdata (vals, id, valt, vald)
select smallint_col, id, tinyint_col, double_col
from functional.alltypes where id > 2 and id < 6
---- RUNTIME_PROFILE
NumModifiedRows: 3
NumRowErrors: 0
---- LABELS
ID, VALF, VALI, VALV, VALB, VALT, VALS, VALD
---- DML_RESULTS: tdata
0,0,0,'0',true,0,0,0
1,1.100000023841858,10,'1',false,1,1,10.1
3,NULL,NULL,'NULL',NULL,3,3,30.3
4,NULL,NULL,'NULL',NULL,4,4,40.4
5,NULL,NULL,'NULL',NULL,5,5,50.5
---- TYPES
INT,FLOAT,BIGINT,STRING,BOOLEAN,TINYINT,SMALLINT,DOUBLE
====
---- QUERY
# Make sure we can insert empty strings into string columns and that we can scan them
# back.
insert into tdata values (320, 2.0, 932, cast('' as string), false, 0, 0, 0)
---- RESULTS
: 1
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 0
====
---- QUERY
select id, valv, valb from tdata where id = 320;
---- RESULTS
320,'',false
---- TYPES
INT,STRING,BOOLEAN
====
---- QUERY
insert into tdata values
(666, cast(1.2 as float), 43, cast('z' as string), true, 0, 0, 0)
---- RESULTS
: 1
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 0
====
---- QUERY
# insert row with primary key that already exists
insert into tdata values
(666, cast(1.2 as float), 43, cast('z' as VARCHAR(20)), true, 0, 0, 0)
---- RESULTS
: 0
---- RUNTIME_PROFILE
NumModifiedRows: 0
NumRowErrors: 1
====
---- QUERY
create table kudu_test_tbl primary key(id)
distribute by range(id) (partition values < 100, partition 100 <= values <= 10000)
stored as kudu as
select * from functional_kudu.alltypes where id < 100;
---- RESULTS
'Inserted 100 row(s)'
---- RUNTIME_PROFILE
NumModifiedRows: 100
NumRowErrors: 0
====
---- QUERY
insert into kudu_test_tbl
select * from functional_kudu.alltypes where id < 100;
---- RESULTS
: 0
---- RUNTIME_PROFILE
NumModifiedRows: 0
NumRowErrors: 100
====
---- QUERY
# large insert - 100 rows were already inserted above and result in errors
insert into kudu_test_tbl
select * from functional_kudu.alltypes;
---- RESULTS
: 7200
---- RUNTIME_PROFILE
NumModifiedRows: 7200
NumRowErrors: 100
====
---- QUERY
# Insert rows that are not covered by any of the existing range partitions
# Only the row at 10000 is inserted.
insert into kudu_test_tbl SELECT cast(id + 10000 as int), bool_col, tinyint_col,
smallint_col, int_col, bigint_col, float_col, double_col, date_string_col, string_col,
timestamp_col, year, month
from functional_kudu.alltypes
---- RUNTIME_PROFILE
NumModifiedRows: 1
NumRowErrors: 7299
====
---- QUERY
# IMPALA-2521: clustered insert into table.
create table impala_2521
(id bigint primary key, name string, zip int)
distribute by hash into 3 buckets stored as kudu
---- RESULTS
====
---- QUERY
insert into impala_2521 /*+ clustered */
select id, name, maxzip as zip
from (
select tinyint_col as id, cast(max(int_col) + 1 as int) as maxzip, string_col as name
from functional_kudu.alltypessmall group by id, name
) as sub;
---- RESULTS
: 10
---- RUNTIME_PROFILE
NumModifiedRows: 10
NumRowErrors: 0
====
---- QUERY
select * from impala_2521
---- RESULTS
0,'0',1
1,'1',2
2,'2',3
3,'3',4
4,'4',5
5,'5',6
6,'6',7
7,'7',8
8,'8',9
9,'9',10
---- TYPES
BIGINT,STRING,INT
====
---- QUERY
# Table with all supported types as primary key and distribution columns
create table allkeytypes (i1 tinyint, i2 smallint, i3 int, i4 bigint, name string,
valf float, vald double, primary key (i1, i2, i3, i4, name)) distribute by
hash into 3 buckets, range (partition value = (1,1,1,1,'1'),
partition value = (2,2,2,2,'2'), partition value = (3,3,3,3,'3')) stored as kudu
---- RESULTS
====
---- QUERY
insert into allkeytypes select cast(id as tinyint), smallint_col, int_col,
cast (bigint_col/10 as bigint), string_col, float_col, double_col
from functional.alltypes where id > 0 and id < 10
---- RESULTS
: 3
---- RUNTIME_PROFILE
NumModifiedRows: 3
NumRowErrors: 6
====