mirror of
https://github.com/apache/impala.git
synced 2025-12-31 06:02:51 -05:00
This patch is mostly mechanical move of codegen related logic from each exec node's Prepare() to its Codegen() function. After this change, code generation will no longer happen in Prepare(). Instead, it will happen after Prepare() completes in PlanFragmentExecutor. This is an intermediate step towards the final goal of sharing compiled code among fragment instances in multi-threading. As part of the clean up, this change also removes the logic for lazy codegen object creation. In other words, if codegen is enabled, the codegen object will always be created. This simplifies some of the logic in ScalarFnCall::Prepare() and various Codegen() functions by reducing error checking needed. This change also removes the logic added for tackling IMPALA-1755 as it's not needed anymore after the clean up. The clean up also rectifies a not so well documented situation. Previously, even if a user explicitly sets DISABLE_CODEGEN to true, we may still codegen a UDF if it was written in LLVM IR or if it has more than 8 arguments. This patch enforces the query option by failing the query in both cases. To run the query, the user must enable codegen. This change also extends the number of arguments supported in the interpretation path of ScalarFn to 20. Change-Id: I207566bc9f4c6a159271ecdbc4bbdba3d78c6651 Reviewed-on: http://gerrit.cloudera.org:8080/4651 Reviewed-by: Michael Ho <kwho@cloudera.com> Tested-by: Internal Jenkins
84 lines
3.1 KiB
Plaintext
84 lines
3.1 KiB
Plaintext
====
|
|
---- QUERY
|
|
create database if not exists udf_test_errors;
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
create function if not exists udf_test_errors.hive_pi() returns double
|
|
location '$FILESYSTEM_PREFIX/test-warehouse/hive-exec.jar'
|
|
symbol='org.apache.hadoop.hive.ql.udf.UDFPI';
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
create function if not exists udf_test_errors.foo() returns double
|
|
location '$FILESYSTEM_PREFIX/test-warehouse/not-a-real-file.so'
|
|
symbol='FnDoesNotExist';
|
|
---- CATCH
|
|
Could not load binary: $FILESYSTEM_PREFIX/test-warehouse/not-a-real-file.so
|
|
====
|
|
---- QUERY
|
|
create function if not exists udf_test_errors.foo() returns double
|
|
location '$FILESYSTEM_PREFIX/test-warehouse/not-a-real-file.so'
|
|
symbol='FnDoesNotExist';
|
|
---- CATCH
|
|
Could not load binary: $FILESYSTEM_PREFIX/test-warehouse/not-a-real-file.so
|
|
====
|
|
---- QUERY
|
|
# This test is run with codegen disabled. Interpretation only handles up to 20 arguments.
|
|
create function if not exists udf_test_errors.twenty_args(int, int, int, int, int, int,
|
|
int, int, int, int, int, int, int, int, int, int, int, int, int, int) returns int
|
|
location '$FILESYSTEM_PREFIX/test-warehouse/libTestUdfs.so'
|
|
symbol='TwentyArgs';
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Verifies that interpretation can support up to 20 arguments
|
|
select udf_test_errors.twenty_args(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
|
|
---- TYPES
|
|
INT
|
|
---- RESULTS
|
|
210
|
|
====
|
|
---- QUERY
|
|
# This test is run with codegen disabled. Interpretation only handles up to 20 arguments.
|
|
create function if not exists udf_test_errors.twenty_one_args(int, int, int, int, int, int,
|
|
int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) returns int
|
|
location '$FILESYSTEM_PREFIX/test-warehouse/libTestUdfs.so'
|
|
symbol='TwentyOneArgs';
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Verifies that interpretation fails with more than 20 arguments.
|
|
select udf_test_errors.twenty_one_args(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21);
|
|
---- CATCH
|
|
Cannot interpret native UDF 'twenty_one_args': number of arguments is more than 20. Codegen is needed. Please set DISABLE_CODEGEN to false.
|
|
====
|
|
---- QUERY
|
|
# This test is run with codegen disabled. IR UDF will fail.
|
|
create function if not exists udf_test_errors.nine_args_ir(int, int, int, int, int, int,
|
|
int, int, int) returns int
|
|
location '$FILESYSTEM_PREFIX/test-warehouse/test-udfs.ll'
|
|
symbol='NineArgs';
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
select udf_test_errors.nine_args_ir(1,2,3,4,5,6,7,8,9);
|
|
---- CATCH
|
|
Cannot interpret LLVM IR UDF 'nine_args_ir': Codegen is needed. Please set DISABLE_CODEGEN to false.
|
|
====
|
|
---- QUERY
|
|
drop database udf_test_errors;
|
|
---- CATCH
|
|
Cannot drop non-empty database: udf_test_errors
|
|
====
|
|
---- QUERY
|
|
drop function udf_test_errors.hive_pi();
|
|
drop function udf_test_errors.twenty_args(int, int, int, int, int, int, int, int,
|
|
int, int, int, int, int, int, int, int, int, int, int, int);
|
|
drop function udf_test_errors.twenty_one_args(int, int, int, int, int, int, int, int,
|
|
int, int, int, int, int, int, int, int, int, int, int, int, int);
|
|
drop function udf_test_errors.nine_args_ir(int, int, int, int, int, int, int, int, int);
|
|
drop database udf_test_errors;
|
|
---- RESULTS
|
|
====
|