Files
impala/testdata/workloads/functional-query/queries/QueryTest/java-udf.test
Skye Wanderman-Milne 9f366645ab IMPALA-3378/IMPALA-3379: fix various JNI issues
This patch:

1) Removes JniUtil::Cleanup() and JniUtil::global_refs_. We never
called Cleanup(), and all the jobjects in global_refs_ are meant to
have the lifetime of the impalad process. This makes
JniUtil::GetGlobalClassRef() and JniUtil::LocalToGlobalRef()
thread-safe (which fixes IMPALA-3379).

2) Introduces a new JniUtil::FreeGlobalRef() method, which is a
wrapper around the JNI DeleteGlobalRef() method.

3) Change JNI users to use the JniUtil methods instead of the JNI
methods directly where appropriate. This makes error checking more
consistent, and makes it easier to find all JNI uses. This is possible
since GetGlobalClassRef() and LocalToGlobalRef() are now thread-safe
and don't leak jobjects.

4) Removes HiveUdfCall::JniContext::cl, as well as other JNI
constants, and replaces them with process-wide static singletons. It
then moves the initialization to a new HiveUdfCall::Init() method
which is once called in the main thread at the beginning of the
process. This fixes IMPALA-3378.

5) Deletes the JniContext created for each HiveUdfCall

Unfortunately I am not able to repro IMPALA-3378 so there is no test
case (I didn't attempt IMPALA-3379 but it's similar).

Change-Id: I8cd089e355d2ee2d5ace81f05b214272c05cf941
Reviewed-on: http://gerrit.cloudera.org:8080/2820
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: Internal Jenkins
2016-05-12 14:17:41 -07:00

293 lines
5.7 KiB
Plaintext

====
---- QUERY
select udf_test.hive_pi()
---- RESULTS
3.141592653589793
---- TYPES
DOUBLE
====
---- QUERY
select udf_test.hive_bin(100)
---- RESULTS
'1100100'
---- TYPES
STRING
====
---- QUERY
select min(udf_test.hive_pi()) from functional.alltypesagg
---- RESULTS
3.141592653589793
---- TYPES
DOUBLE
====
---- QUERY
# Test identity functions
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
# IMPALA-1456. Each "identity" call below tests a different type (BytesWritable, Text,
# and String).
select udf_test.identity("why hello there"),
udf_test.identity("why", " hello there"),
udf_test.identity("why", " hello", " there");
---- TYPES
string, string, string
---- RESULTS
'why hello there','why hello there','why hello there'
====
---- QUERY
select udf_test.identity(NULL);
---- TYPES
boolean
---- RESULTS
NULL
====
---- QUERY
# IMPALA-1134. Each "identity" call below tests a different type (BytesWritable, Text,
# and String). The different types are handled slightly differently.
select length(udf_test.identity("0123456789")),
length(udf_test.identity("0123456789", "0123456789")),
length(udf_test.identity("0123456789", "0123456789", "0123456789"));
---- TYPES
int, int, int
---- RESULTS
10,20,30
====
---- QUERY
# IMPALA-1392: Hive UDFs that throw exceptions should return NULL
select udf_test.throws_exception();
---- TYPES
boolean
---- RESULTS
NULL
====
---- QUERY
select udf_test.throws_exception() from functional.alltypestiny;
---- TYPES
boolean
---- RESULTS
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
====
---- QUERY
select udf_test.hive_add(cast(1 as int), cast(2 as int));
---- TYPES
int
---- RESULTS
3
====
---- QUERY
select udf_test.hive_add(udf_test.hive_add(cast(1 as int), cast(2 as int)), cast(2 as int));
---- TYPES
int
---- RESULTS
5
====
---- QUERY
select udf_test.hive_add(cast(udf_test.hive_add(cast(1 as int), cast(2 as int)) - udf_test.hive_add(cast(2 as int), cast(1 as int)) as int), cast(2 as int));
---- TYPES
int
---- RESULTS
2
====
---- QUERY
select udf_test.hive_add(cast(1 as smallint), cast(2 as smallint));
---- TYPES
smallint
---- RESULTS
3
====
---- QUERY
select udf_test.hive_add(cast(1.0 as float), cast(2.0 as float));
---- TYPES
float
---- RESULTS
3.0
====
---- QUERY
select udf_test.hive_add(cast(1.0 as double), cast(2.0 as double));
---- TYPES
double
---- RESULTS
3.0
====
---- QUERY
select udf_test.hive_add(cast(1 as boolean), cast(0 as boolean));
---- TYPES
boolean
---- RESULTS
false
====
---- QUERY
# Testing whether all of persistent Java udfs are accessible.
select java_udfs_test.identity(true);
---- TYPES
boolean
---- RESULTS
true
====
---- QUERY
select java_udfs_test.identity(cast(10 as tinyint));
---- TYPES
tinyint
---- RESULTS
10
====
---- QUERY
select java_udfs_test.identity(cast(10 as smallint));
---- TYPES
smallint
---- RESULTS
10
====
---- QUERY
select java_udfs_test.identity(cast(10 as int));
---- TYPES
int
---- RESULTS
10
====
---- QUERY
select java_udfs_test.identity(cast(10 as bigint));
---- TYPES
bigint
---- RESULTS
10
====
---- QUERY
select java_udfs_test.identity(cast(10.0 as float));
---- TYPES
float
---- RESULTS
10
====
---- QUERY
select java_udfs_test.identity(cast(10.0 as double));
---- TYPES
double
---- RESULTS
10
====
---- QUERY
select java_udfs_test.identity("a", "b");
---- TYPES
string
---- RESULTS
'ab'
====
---- QUERY
select java_udfs_test.identity("a", "b", "c");
---- TYPES
string
---- RESULTS
'abc'
====
---- QUERY
# IMPALA-3378: test many Java UDFs being opened and run concurrently
select * from
(select max(int_col) from functional.alltypesagg
where udf_test.identity(bool_col) union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(tinyint_col) > 1 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(smallint_col) > 1 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(int_col) > 1 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(bigint_col) > 1 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(float_col) > 1.0 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(double_col) > 1.0 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(string_col) > '1' union all
(select max(int_col) from functional.alltypesagg
where not udf_test.identity(bool_col) union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(tinyint_col) > 2 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(smallint_col) > 2 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(int_col) > 2 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(bigint_col) > 2 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(float_col) > 2.0 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(double_col) > 2.0 union all
(select max(int_col) from functional.alltypesagg
where udf_test.identity(string_col) > '2'
)))))))))))))))) v
---- TYPES
INT
---- RESULTS
998
999
999
999
999
999
999
999
999
999
999
999
999
999
999
999
====