diff --git a/be/src/exprs/literal.cc b/be/src/exprs/literal.cc index 92bc0c175..3b7caf8af 100644 --- a/be/src/exprs/literal.cc +++ b/be/src/exprs/literal.cc @@ -356,6 +356,10 @@ Status Literal::GetCodegendComputeFn(LlvmCodeGen* codegen, llvm::Function** fn) 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("Literal", codegen, &args); @@ -388,7 +392,6 @@ Status Literal::GetCodegendComputeFn(LlvmCodeGen* codegen, llvm::Function** fn) break; case TYPE_STRING: case TYPE_VARCHAR: - case TYPE_CHAR: v.SetLen(builder.getInt32(value_.string_val.len)); v.SetPtr(codegen->GetStringConstant( &builder, value_.string_val.ptr, value_.string_val.len)); diff --git a/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test b/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test index dee0126c1..9f609d45f 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test +++ b/testdata/workloads/functional-query/queries/QueryTest/disable-codegen.test @@ -28,3 +28,19 @@ bigint # Verify that codegen was disabled row_regex: .*Codegen Disabled: disabled due to optimization hints.* ==== +---- QUERY +# 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. +select count(*) from ( + select cast('a' as char(4)) as s from functional.alltypestiny + union all + select cast('a' as char(4)) as s from functional.alltypestiny + union all + select cast(NULL as char(4)) as s from functional.alltypestiny +) t +---- RESULTS +24 +---- TYPES +bigint +====