IMPALA-7032: Disable codegen for CHAR type null literals Analogous to IMPALA-6435, we have to disable codegen for CHAR type null literals. Otherwise we will crash in impala::NullLiteral::GetCodegendComputeFn().
This change adds a test to make sure that the crash is fixed. Change-Id: I34033362263cf1292418f69c5ca1a3b84aed39a9 Reviewed-on: http://gerrit.cloudera.org:8080/10409 Reviewed-by: Lars Volker <[email protected]> Tested-by: Lars Volker <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/impala/repo Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/a64cfc52 Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/a64cfc52 Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/a64cfc52 Branch: refs/heads/master Commit: a64cfc523ecd5ee7f13c3c7ca63cafe510c4610a Parents: 13a1acd Author: Lars Volker <[email protected]> Authored: Tue May 15 11:18:48 2018 -0700 Committer: Lars Volker <[email protected]> Committed: Wed May 16 00:00:15 2018 +0000 ---------------------------------------------------------------------- be/src/exprs/null-literal.cc | 4 ++++ .../queries/QueryTest/disable-codegen.test | 14 ++++++++++++++ 2 files changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/impala/blob/a64cfc52/be/src/exprs/null-literal.cc ---------------------------------------------------------------------- diff --git a/be/src/exprs/null-literal.cc b/be/src/exprs/null-literal.cc index d2d4590..8ce3a71 100644 --- a/be/src/exprs/null-literal.cc +++ b/be/src/exprs/null-literal.cc @@ -108,6 +108,10 @@ Status NullLiteral::GetCodegendComputeFn(LlvmCodeGen* codegen, llvm::Function** return Status::OK(); } + if (type_.type == TYPE_CHAR) { + return Status::Expected("Codegen not supported for CHAR"); + } + DCHECK_EQ(GetNumChildren(), 0); llvm::Value* args[2]; *fn = CreateIrFunctionPrototype("NullLiteral", codegen, &args); http://git-wip-us.apache.org/repos/asf/impala/blob/a64cfc52/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test ---------------------------------------------------------------------- diff --git a/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test b/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test index 9f609d4..600ca45 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test +++ b/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test @@ -32,6 +32,7 @@ row_regex: .*Codegen Disabled: disabled due to optimization hints.* # IMPALA-6435: We do not codegen char columns. This fix checks for a # CHAR type literal in the expr and disables codegen. This query will crash # impala without the fix. +set disable_codegen_rows_threshold=0; select count(*) from ( select cast('a' as char(4)) as s from functional.alltypestiny union all @@ -44,3 +45,16 @@ select count(*) from ( ---- TYPES bigint ==== +---- QUERY +# IMPALA-7032: Test that codegen gets disabled for CHAR type null literals in +# the backend. We force codegen to be on in order to exercise the codegen code +# for null literals. +set disable_codegen_rows_threshold=0; +select NULL from functional.alltypestiny + union select cast('a' as char(4)) from functional.alltypestiny +---- RESULTS +'a ' +'NULL' +---- TYPES +char +====
