You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2018/01/25 21:46:28 UTC
[10/11] impala git commit: IMPALA-6435: Disable codegen for CHAR
literals.
IMPALA-6435: Disable codegen for CHAR literals.
Currently we do not codegen CHAR types. This change checks
for CHAR literals in a expr and disables codegen.
Change-Id: I7e4e27350c53bc69ce412a004e392e7480214f73
Reviewed-on: http://gerrit.cloudera.org:8080/9102
Reviewed-by: Tim Armstrong <ta...@cloudera.com>
Tested-by: Impala Public Jenkins
Project: http://git-wip-us.apache.org/repos/asf/impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/f4b6818d
Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/f4b6818d
Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/f4b6818d
Branch: refs/heads/2.x
Commit: f4b6818df7e06c609e072f5d2b1afa329b1e1bd0
Parents: 14e170a
Author: aphadke <ap...@cloudera.com>
Authored: Tue Jan 23 09:58:44 2018 -0800
Committer: Philip Zeyliger <ph...@cloudera.com>
Committed: Wed Jan 24 10:17:57 2018 -0800
----------------------------------------------------------------------
be/src/exprs/literal.cc | 5 ++++-
.../queries/QueryTest/disable-codegen.test | 16 ++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/impala/blob/f4b6818d/be/src/exprs/literal.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/literal.cc b/be/src/exprs/literal.cc
index 92bc0c1..3b7caf8 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));
http://git-wip-us.apache.org/repos/asf/impala/blob/f4b6818d/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 dee0126..9f609d4 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
+====