Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions cpp/src/arrow/engine/substrait/expression_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "arrow/util/make_unique.h"
#include "arrow/visit_scalar_inline.h"


namespace arrow {

using internal::checked_cast;
Expand Down Expand Up @@ -159,21 +160,17 @@ Result<compute::Expression> FromProto(const substrait::Expression& expr,

ARROW_ASSIGN_OR_RAISE(auto decoded_function,
ext_set.DecodeFunction(scalar_fn.function_reference()));
ARROW_ASSIGN_OR_RAISE(auto arrow_function, ext_set.GetFunctionMap().GetArrowFromSubstrait(decoded_function.name.to_string()));
return arrow_function(scalar_fn);
}

std::vector<compute::Expression> arguments(scalar_fn.args_size());
for (int i = 0; i < scalar_fn.args_size(); ++i) {
ARROW_ASSIGN_OR_RAISE(arguments[i], FromProto(scalar_fn.args(i), ext_set));
}

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));
}
case substrait::Expression::kEnum: {
auto enum_expr = expr.enum_();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this convert to the string value of the enum? Can you add a small comment here explaining that.

if(enum_expr.has_specified()){
return compute::literal(std::move(enum_expr.specified()));
} else {
return Status::Invalid("Substrait Enum value not specified");
}
}

default:
Expand Down
Loading