This is an automated email from the ASF dual-hosted git repository.

ravindra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new f8cd263  ARROW-5601: [C++][Gandiva] fail if the output type is not 
supported
f8cd263 is described below

commit f8cd2639b2f36b3d84dceaead8a1d0b3ed493c2c
Author: Pindikura Ravindra <ravin...@dremio.com>
AuthorDate: Fri Jun 14 19:41:01 2019 +0530

    ARROW-5601: [C++][Gandiva] fail if the output type is not supported
    
    Author: Pindikura Ravindra <ravin...@dremio.com>
    
    Closes #4569 from pravindra/arrow-5601 and squashes the following commits:
    
    bee31332 <Pindikura Ravindra> ARROW-5601:  fail if the output type is not 
supported
---
 cpp/src/gandiva/llvm_generator.cc  |  9 +++++++--
 cpp/src/gandiva/tests/utf8_test.cc | 17 +++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/cpp/src/gandiva/llvm_generator.cc 
b/cpp/src/gandiva/llvm_generator.cc
index 28887c9..867f07b 100644
--- a/cpp/src/gandiva/llvm_generator.cc
+++ b/cpp/src/gandiva/llvm_generator.cc
@@ -318,11 +318,16 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, 
FieldDescriptorPtr out
 
   // save the value in the output vector.
   builder->SetInsertPoint(loop_body_tail);
-  if (output->Type()->id() == arrow::Type::BOOL) {
+  auto output_type_id = output->Type()->id();
+  if (output_type_id == arrow::Type::BOOL) {
     SetPackedBitValue(output_ref, loop_var, output_value->data());
-  } else {
+  } else if (arrow::is_primitive(output_type_id) ||
+             output_type_id == arrow::Type::DECIMAL) {
     llvm::Value* slot_offset = builder->CreateGEP(output_ref, loop_var);
     builder->CreateStore(output_value->data(), slot_offset);
+  } else {
+    return Status::NotImplemented("output type ", output->Type()->ToString(),
+                                  " not supported");
   }
   ADD_TRACE("saving result " + output->Name() + " value %T", 
output_value->data());
 
diff --git a/cpp/src/gandiva/tests/utf8_test.cc 
b/cpp/src/gandiva/tests/utf8_test.cc
index 8129169..6df4da6 100644
--- a/cpp/src/gandiva/tests/utf8_test.cc
+++ b/cpp/src/gandiva/tests/utf8_test.cc
@@ -504,4 +504,21 @@ TEST_F(TestUtf8, TestIsNull) {
                             outputs[1]);  // isnotnull
 }
 
+TEST_F(TestUtf8, TestVarlenOutput) {
+  // schema for input fields
+  auto field_a = field("a", utf8());
+  auto schema = arrow::schema({field_a});
+
+  // build expressions.
+  auto expr = 
TreeExprBuilder::MakeExpression(TreeExprBuilder::MakeField(field_a),
+                                              field("res", utf8()));
+
+  // Build a projector for the expressions.
+  std::shared_ptr<Projector> projector;
+
+  // assert that it fails gracefully.
+  ASSERT_RAISES(NotImplemented,
+                Projector::Make(schema, {expr}, TestConfiguration(), 
&projector));
+}
+
 }  // namespace gandiva

Reply via email to