You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2022/04/30 01:52:47 UTC

[arrow] branch master updated: ARROW-16416: [C++] Support cast-function in Substrait

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

westonpace 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 f8d6eac3d9 ARROW-16416: [C++] Support cast-function in Substrait
f8d6eac3d9 is described below

commit f8d6eac3d97876eed43faa9aaec9f1201dec55ba
Author: Yaron Gvili <rt...@hotmail.com>
AuthorDate: Fri Apr 29 15:52:05 2022 -1000

    ARROW-16416: [C++] Support cast-function in Substrait
    
    The cast-function is special in Arrow, because its operation is determined by its output type rather than just by its parameter, and so it requires special handling in Substrait to support it.
    
    Closes #13032 from rtpsw/ARROW-16416
    
    Lead-authored-by: Yaron Gvili <rt...@hotmail.com>
    Co-authored-by: rtpsw <rt...@hotmail.com>
    Co-authored-by: Weston Pace <we...@gmail.com>
    Signed-off-by: Weston Pace <we...@gmail.com>
---
 cpp/src/arrow/engine/substrait/expression_internal.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/cpp/src/arrow/engine/substrait/expression_internal.cc b/cpp/src/arrow/engine/substrait/expression_internal.cc
index d18ae4dcb4..5d7d66225e 100644
--- a/cpp/src/arrow/engine/substrait/expression_internal.cc
+++ b/cpp/src/arrow/engine/substrait/expression_internal.cc
@@ -165,7 +165,15 @@ Result<compute::Expression> FromProto(const substrait::Expression& expr,
         ARROW_ASSIGN_OR_RAISE(arguments[i], FromProto(scalar_fn.args(i), ext_set));
       }
 
-      return compute::call(decoded_function.name.to_string(), std::move(arguments));
+      auto func_name = decoded_function.name.to_string();
+      if (func_name != "cast") {
+        return compute::call(func_name, std::move(arguments));
+      } else {
+        ARROW_ASSIGN_OR_RAISE(auto output_type_desc,
+                              FromProto(scalar_fn.output_type(), ext_set));
+        auto cast_options = compute::CastOptions::Safe(std::move(output_type_desc.first));
+        return compute::call(func_name, std::move(arguments), std::move(cast_options));
+      }
     }
 
     default: