==== # 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 ==== ---- QUERY select udf_test.var_sum(NULL, NULL, NULL) ---- TYPES int ---- RESULT NULL ==== ---- QUERY select udf_test.var_sum(1, 2, 3, 4, 5, 6) ---- TYPES int ---- RESULT 21 ==== ---- 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 ====