You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/29 20:03:40 UTC

[GitHub] [arrow] westonpace commented on a diff in pull request #13032: ARROW-16416: [C++] Support cast-function in Substrait

westonpace commented on code in PR #13032:
URL: https://github.com/apache/arrow/pull/13032#discussion_r862108441


##########
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(output_type_desc.first);
+        return compute::call(func_name, std::move(arguments), cast_options);

Review Comment:
   ```suggestion
           auto cast_options = compute::CastOptions::Safe(std::move(output_type_desc.first));
           return compute::call(func_name, std::move(arguments), std::move(cast_options));
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org