Files
impala/testdata/workloads/functional-query/queries/QueryTest/chars.test
Victor Bittorf 9939c9d009 Bugfix and tests for CHAR(N) and VARCHAR(N)
Fixed a bug when setting the length in reading/write text files for CHAR(N).
Also added chars_tiny table for testing CHAR(N) and VARCHAR(N).

Change-Id: If5d5db30afa4b00cf03c68c6a845f182970329f4
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4415
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
2014-09-23 07:30:07 -07:00

176 lines
3.8 KiB
Plaintext

====
---- QUERY
# TODO: string literals should start as CHAR(N) and analysis should promote as necessary
# TODO: Test min/max aggregates on CHAR(N)
# TODO: Test hash joins on varchar to char
insert into test_char_tmp select cast("hello" as char(5))
====
---- QUERY
select * from test_char_tmp
---- TYPES
char
---- RESULTS
'hello'
====
---- QUERY
# Regression test for IMPALA-1248
insert into test_char_tmp values (cast("hel" as char(5)))
====
---- QUERY
insert into test_char_tmp select cast(cast("hello000" as VARCHAR(8)) as char(5))
====
---- QUERY
select * from test_char_tmp where c = cast('hel' as char(5))
---- TYPES
char
---- RESULTS
'hel '
====
---- QUERY
insert into test_char_tmp values (NULL)
====
---- QUERY
select * from test_char_tmp as A CROSS JOIN test_char_tmp as B
where B.c = cast('hel' as CHAR(5))
ORDER BY A.c
---- TYPES
char, char
---- RESULTS
'hel ','hel '
'hello','hel '
'hello','hel '
'NULL','hel '
====
---- QUERY
select * from test_char_tmp as A, test_char_tmp as B
where A.c = B.c AND A.c != 'hello'
---- TYPES
char, char
---- RESULTS
'hel ','hel '
====
---- QUERY
select lower(c) from test_char_tmp ORDER BY c
---- TYPES
string
---- RESULTS
'hel '
'hello'
'hello'
'NULL'
====
---- QUERY
insert into test_varchar_tmp values (cast("hello" as varchar(5)))
====
---- QUERY
select * from test_varchar_tmp
---- TYPES
string
---- RESULTS
'hello'
====
---- QUERY
insert into test_varchar_tmp values (cast("xyzzzzz12" as varchar(7)))
---- CATCH
would need to be cast to VARCHAR(5)
====
---- QUERY
insert into test_varchar_tmp values (cast("hel" as varchar(4)))
====
---- QUERY
select * from test_varchar_tmp
---- TYPES
string
---- RESULTS
'hello'
'hel'
====
---- QUERY
insert into allchars values (cast("123456" as char(5)), cast("123456" as char(140)),
cast("123456" as varchar(5)))
====
---- QUERY
select cshort, clong, vc from allchars
---- TYPES
char,char,string
---- RESULTS
'12345','123456 ','12345'
====
---- QUERY
insert into allchars_par values (cast("123456" as char(5)), cast("123456" as char(140)),
cast("123456" as varchar(5)))
====
---- QUERY
select cshort, clong, vc from allchars_par
---- TYPES
char,char,string
---- RESULTS
'12345','123456 ','12345'
=======
---- QUERY
select count(*), count(cs), count(cl), count(vc) from chars_tiny
---- TYPES
bigint,bigint,bigint,bigint
---- RESULTS
9,8,8,8
====
---- QUERY
select * from chars_tiny where cs = cast('6a' as CHAR(2))
---- TYPES
char,char,string
---- RESULTS
'6a ','6b ','6c'
'6a ','6b ','6c'
====
---- QUERY
select count(*) from chars_tiny where vc != cast('5c' as varchar(3))
---- TYPES
bigint
---- RESULTS
7
====
---- QUERY
select count(*) from chars_tiny where cs != cast('a' as char(3))
---- TYPES
bigint
---- RESULTS
7
====
---- QUERY
select count(DISTINCT cs) from chars_tiny where vc = cast('5c' as varchar(10))
---- TYPES
bigint
---- RESULTS
1
====
---- QUERY
select count(DISTINCT cs) from chars_tiny where cs = cast('5a' as char(10))
---- TYPES
bigint
---- RESULTS
1
====
---- QUERY
select cs, count(cl) from functional.chars_tiny group by cs having count(vc) > 1
---- TYPES
char, bigint
---- RESULTS
'6a ',2
====
---- QUERY
select A.cs from functional.chars_tiny as A, functional.chars_tiny as B where
cast(A.cs as char(1)) = cast(B.cl as char(1)) order by A.cs
---- TYPES
char
---- RESULTS
'1aaaa'
'2aaaa'
'3aaa '
'4aa '
'5a '
'6a '
'6a '
'6a '
'6a '
====