MCPcopy Create free account
hub / github.com/apache/arrow / ExecuteImpl

Method ExecuteImpl

cpp/src/arrow/compute/cast.cc:95–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 }
94
95 Result<Datum> ExecuteImpl(const std::vector<Datum>& args,
96 const FunctionOptions* options,
97 ExecContext* ctx) const override {
98 ARROW_ASSIGN_OR_RAISE(auto cast_options, ValidateOptions(options));
99 // args[0].type() could be a nullptr so check for that before
100 // we do anything with it.
101 if (args[0].type() && args[0].type()->Equals(*cast_options->to_type)) {
102 // Nested types might differ in field names but still be considered equal,
103 // so we can only return non-nested types as-is.
104 if (!is_nested(args[0].type()->id())) {
105 return args[0];
106 } else if (args[0].is_array()) {
107 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<ArrayData> array,
108 ::arrow::internal::GetArrayView(
109 args[0].array(), cast_options->to_type.owned_type));
110 return Datum(array);
111 } else if (args[0].is_chunked_array()) {
112 ARROW_ASSIGN_OR_RAISE(
113 std::shared_ptr<ChunkedArray> array,
114 args[0].chunked_array()->View(cast_options->to_type.owned_type));
115 return Datum(array);
116 }
117 }
118
119 Result<std::shared_ptr<CastFunction>> result =
120 GetCastFunction(*cast_options->to_type);
121 if (!result.ok()) {
122 Status s = result.status();
123 return s.WithMessage(s.message(), " from ", *args[0].type());
124 }
125 return (*result)->Execute(args, options, ctx);
126 }
127};
128
129static auto kCastOptionsType = GetFunctionOptionsType<CastOptions>(

Callers

nothing calls this directly

Calls 15

GetArrayViewFunction · 0.85
GetCastFunctionFunction · 0.85
is_arrayMethod · 0.80
chunked_arrayMethod · 0.80
DatumClass · 0.70
is_nestedFunction · 0.50
ARROW_ASSIGN_OR_RAISEFunction · 0.50
typeMethod · 0.45
EqualsMethod · 0.45
idMethod · 0.45
arrayMethod · 0.45
ViewMethod · 0.45

Tested by

no test coverage detected