Files
impala/testdata/workloads/functional-query/queries/QueryTest/udf.test
Skye Wanderman-Milne b7f83bcd73 Add support for LLVM IR UDFs.
This patch also adds a number of improvements to NativeUdfExpr. Highlights include:

* Correctly handling the lowering of AnyVal struct types (required for ABI compatibility)
* A rudimentary library cache for reusing handles produced by dlopen
* More complicated test cases

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

187 lines
3.2 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(NULL);
---- TYPES
boolean
---- RESULTS
NULL
====
# 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 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
====