Files
impala/testdata/workloads/functional-query/queries/QueryTest/udf.test
Skye Wanderman-Milne b41ff0c8cd Modify test-udfs.cc so there are no undefined symbols in shared library.
AnalyzeDDLTest was failing because the fesupport binary couldn't
resolve a function used in libTestUdfs.so (the function was defined in
udf.cc, rather than udf.h). I couldn't figure out how to cleanly build
udf.cc into the libTestUdfs.so, so instead I removed the use of the
function in test-udfs.cc.

Change-Id: I81243547584a5b49a5f9265d0d17e035e18d6110
Reviewed-on: http://gerrit.ent.cloudera.com:8080/694
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: Skye Wanderman-Milne <skye@cloudera.com>
2014-01-08 10:53:27 -08:00

318 lines
5.7 KiB
Plaintext

====
# Test identity functions
---- QUERY
select udf_test.identity(true);
---- TYPES
boolean
---- RESULTS
true
====
---- QUERY
select udf_test.identity(cast(10 as tinyint));
---- TYPES
tinyint
---- RESULTS
10
====
---- QUERY
select udf_test.identity(cast(10 as smallint));
---- TYPES
smallint
---- RESULTS
10
====
---- QUERY
select udf_test.identity(cast(10 as int));
---- TYPES
int
---- RESULTS
10
====
---- QUERY
select udf_test.identity(cast(10 as bigint));
---- TYPES
bigint
---- RESULTS
10
====
---- QUERY
select udf_test.identity(cast(10.0 as float));
---- TYPES
float
---- RESULTS
10
====
---- QUERY
select udf_test.identity(cast(10.0 as double));
---- TYPES
double
---- RESULTS
10
====
---- QUERY
select udf_test.identity("why hello there");
---- TYPES
string
---- RESULTS
'why hello there'
====
---- QUERY
select udf_test.identity(now());
---- TYPES
timestamp
====
---- QUERY
select udf_test.identity(NULL);
---- TYPES
boolean
---- RESULTS
NULL
====
---- QUERY
select udf_test.constant_timestamp();
---- TYPES
timestamp
---- RESULTS
2013-10-09 00:00:00.000000001
====
---- QUERY
select from_utc_timestamp(udf_test.constant_timestamp(), "UTC");
---- TYPES
timestamp
---- RESULTS
2013-10-09 00:00:00.000000001
====
# Test UDFs with different arguments
---- QUERY
select udf_test.all_types_fn("1", true, 2, 3, 4, 5, 6.0, 7.0);
---- TYPES
int
---- RESULTS
29
====
---- QUERY
select udf_test.no_args();
---- TYPES
string
---- RESULTS
'string'
====
# Test UDFs over tables
---- QUERY
select sum(udf_test.identity(bigint_col)) from functional.alltypes
---- TYPES
bigint
---- RESULTS
328500
====
---- QUERY
select udf_test.identity(a) from functional.tinytable;
---- TYPES
string
---- RESULTS
'aaaaaaa'
'ccccc'
'eeeeeeee'
====
---- QUERY
select udf_test.identity(bool_col), udf_test.identity(tinyint_col),
udf_test.identity(smallint_col), udf_test.identity(int_col),
udf_test.identity(bigint_col), udf_test.identity(float_col),
udf_test.identity(double_col), udf_test.identity(string_col),
udf_test.identity(timestamp_col), udf_test.identity(year)
from alltypestiny;
---- TYPES
boolean, tinyint, smallint, int, bigint, float, double, string, timestamp, int
---- RESULTS
true,0,0,0,0,0,0,'0',2009-02-01 00:00:00,2009
false,1,1,1,10,1.100000023841858,10.1,'1',2009-02-01 00:01:00,2009
true,0,0,0,0,0,0,'0',2009-04-01 00:00:00,2009
false,1,1,1,10,1.100000023841858,10.1,'1',2009-04-01 00:01:00,2009
true,0,0,0,0,0,0,'0',2009-01-01 00:00:00,2009
false,1,1,1,10,1.100000023841858,10.1,'1',2009-01-01 00:01:00,2009
true,0,0,0,0,0,0,'0',2009-03-01 00:00:00,2009
false,1,1,1,10,1.100000023841858,10.1,'1',2009-03-01 00:01:00,2009
====
---- QUERY
select sum(udf_test.all_types_fn(
string_col, bool_col, tinyint_col, smallint_col,
int_col, bigint_col, float_col, double_col))
from functional.alltypes;
---- TYPES
bigint
---- RESULTS
# Verify with 'select sum(length(string_col)) + sum(cast(bool_col as int))
# + sum(tinyint_col) + sum(smallint_col) + sum(int_col) + sum(bigint_col)
# + sum(cast(float_col as bigint)) + sum(cast(double_col as bigint))
# from functional.alltypes;'
799350
====
---- QUERY
select udf_test.no_args() from alltypes limit 1;
---- TYPES
string
---- RESULTS
'string'
====
# Chain UDFs/exprs together to test glue
---- QUERY
select udf_test.identity(udf_test.no_args());
---- TYPES
string
---- RESULTS
'string'
====
---- QUERY
select udf_test.identity(cast(udf_test.identity(3.0) as bigint));
---- TYPES
bigint
---- RESULTS
3
====
---- QUERY
select count(*) from alltypessmall having udf_test.identity(count(*)) > 1
---- TYPES
bigint
---- RESULTS
100
====
---- QUERY
select count(udf_test.identity(id)) from functional.alltypessmall
having udf_test.identity(count(*)) > 1
---- TYPES
bigint
---- RESULTS
100
====
---- QUERY
select count(udf_test.identity(id)) from functional.alltypessmall
group by udf_test.identity(int_col)
having udf_test.identity(count(*)) > 10
---- TYPES
bigint
---- RESULTS
12
12
12
12
12
====
---- QUERY
select udf_test.identity(a.tinyint_col),
udf_test.identity(b.id),
udf_test.identity(a.string_col)
from alltypesagg a join alltypessmall b on
(udf_test.identity(a.tinyint_col) = udf_test.identity(b.id))
and udf_test.identity(a.tinyint_col + b.tinyint_col) < 5
order by udf_test.identity(a.string_col)
limit 5
---- TYPES
tinyint, int, string
---- RESULTS
1,1,'1'
1,1,'1'
1,1,'1'
1,1,'1'
1,1,'1'
====
---- QUERY
select min(udf_test.identity(int_col)) from alltypesagg where int_col is null;
---- TYPES
int
---- RESULT
NULL
====
---- QUERY
select udf_test.var_sum(NULL, NULL, NULL)
---- TYPES
int
---- RESULT
NULL
====
---- QUERY
select udf_test.var_and(true, false, true)
---- TYPES
boolean
---- RESULT
false
====
---- QUERY
select udf_test.var_and(true, true, true, true, true)
---- TYPES
boolean
---- RESULT
true
====
---- QUERY
select udf_test.var_sum(1, 2, 3, 4, 5, 6)
---- TYPES
int
---- RESULT
21
====
---- QUERY
select udf_test.var_sum(1.0, 2.0, 3.0)
---- TYPES
double
---- RESULT
6
====
---- QUERY
select udf_test.var_sum("Hello", "World", "Foo", "Bar")
---- TYPES
int
---- RESULT
16
====
---- QUERY
select tinyint_col, int_col, udf_test.var_sum(tinyint_col, int_col)
from functional.alltypestiny
---- TYPES
tinyint, int, int
---- RESULT
0,0,0
1,1,2
0,0,0
1,1,2
0,0,0
1,1,2
0,0,0
1,1,2
====
---- QUERY
select udf_test.var_sum_multiply(NULL, 1, 2)
---- TYPES
double
---- RESULT
NULL
====
---- QUERY
select udf_test.var_sum_multiply(1.0, 1, 2, NULL, 3)
---- TYPES
double
---- RESULT
NULL
====
---- QUERY
select udf_test.var_sum_multiply(5.0, 1, 2, 3, 4, 5, 6)
---- TYPES
double
---- RESULT
105
====
---- QUERY
select tinyint_col, int_col, udf_test.var_sum_multiply(2, tinyint_col, int_col)
from functional.alltypestiny
---- TYPES
tinyint, int, double
---- RESULT
0,0,0
1,1,4
0,0,0
1,1,4
0,0,0
1,1,4
0,0,0
1,1,4
====