mirror of
https://github.com/apache/impala.git
synced 2026-01-09 06:05:09 -05:00
crashes impala Impala crashes on creating a UDF from a shared library (.so file) which was renamed to have .ll extension. CreateFile() call in GetSymbols() fails and returns on error and does not close the codegen object. This patch closes the codegen object on failure. This avoids hitting a DCHECK later up in the stack. The chain of failures also invokes the DiagnosticHandlerFn. RuntimeState object is NULL when the DiagnosticHandlerFn gets called in this case. This change also adds a check before accessing it for logging. [localhost:21000] > create function foo4 (string, string) returns string location '/tmp/bad_udf.ll' symbol='MyAwesomeUdf'; Query: create function foo4 (string, string) returns string location '/tmp/bad_udf.ll' symbol='MyAwesomeUdf' ERROR: AnalysisException: Could not load binary: /tmp/bad_udf.ll LLVM diagnostic error: Invalid bitcode signature Change-Id: Id060668802ca9c80367cdc0e8a823b968d549bbb Reviewed-on: http://gerrit.cloudera.org:8080/9154 Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com> Tested-by: Impala Public Jenkins
123 lines
4.1 KiB
Plaintext
123 lines
4.1 KiB
Plaintext
====
|
|
---- QUERY
|
|
create function if not exists 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 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 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 foo (string, string) returns string location
|
|
'$FILESYSTEM_PREFIX/test-warehouse/$DATABASE_bad_udf.ll' symbol='MyAwesomeUdf';
|
|
---- CATCH
|
|
Could not load binary: $FILESYSTEM_PREFIX/test-warehouse/$DATABASE_bad_udf.ll
|
|
====
|
|
---- QUERY
|
|
# This test is run with codegen disabled. Interpretation only handles up to 20 arguments.
|
|
create function if not exists 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 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 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 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 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 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
|
|
create function if not exists bad_expr(double) returns boolean
|
|
location '$FILESYSTEM_PREFIX/test-warehouse/libTestUdfs.so'
|
|
symbol='BadExpr' prepare_fn='BadExprPrepare' close_fn='BadExprClose';
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
create function if not exists bad_expr2(double) returns boolean
|
|
location '$FILESYSTEM_PREFIX/test-warehouse/libTestUdfs.so'
|
|
symbol='BadExpr' prepare_fn='BadExpr2Prepare' close_fn='BadExprClose';
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
select count(t1.int_col) from functional.alltypes t1 join functional.alltypes t2
|
|
on (bad_expr(rand()) = (t2.bool_col && t1.bool_col));
|
|
---- CATCH
|
|
BadExpr prepare error
|
|
====
|
|
---- QUERY
|
|
select count(t1.int_col) from functional.alltypes t1 join functional.alltypes t2
|
|
on (bad_expr2(rand()) = (t2.bool_col && t1.bool_col));
|
|
---- CATCH
|
|
BadExpr error
|
|
====
|
|
---- QUERY
|
|
select count(int_col) from functional.alltypes where bad_expr(rand());
|
|
---- CATCH
|
|
BadExpr prepare error
|
|
====
|
|
---- QUERY
|
|
select count(int_col) from functional.alltypes where bad_expr2(rand());
|
|
---- CATCH
|
|
BadExpr2 prepare error
|
|
====
|
|
---- QUERY
|
|
use default;
|
|
drop database $DATABASE;
|
|
---- CATCH
|
|
Cannot drop non-empty database:
|
|
====
|
|
---- QUERY
|
|
use $DATABASE;
|
|
drop function hive_pi();
|
|
drop function twenty_args(int, int, int, int, int, int, int, int,
|
|
int, int, int, int, int, int, int, int, int, int, int, int);
|
|
drop function 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 nine_args_ir(int, int, int, int, int, int, int, int, int);
|
|
drop function bad_expr(double);
|
|
drop function bad_expr2(double);
|
|
---- RESULTS
|
|
====
|