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

Method Cast

cpp/src/arrow/stl.h:373–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371template <typename Tuple, std::size_t N = std::tuple_size<Tuple>::value>
372struct EnsureColumnTypes {
373 static Status Cast(const Table& table, std::shared_ptr<Table>* table_owner,
374 const compute::CastOptions& cast_options, compute::ExecContext* ctx,
375 std::reference_wrapper<const ::arrow::Table>* result) {
376 using Element = BareTupleElement<N - 1, Tuple>;
377 std::shared_ptr<DataType> expected_type = ConversionTraits<Element>::type_singleton();
378
379 if (!table.schema()->field(N - 1)->type()->Equals(*expected_type)) {
380 ARROW_ASSIGN_OR_RAISE(
381 Datum casted,
382 compute::Cast(table.column(N - 1), expected_type, cast_options, ctx));
383 auto new_field = table.schema()->field(N - 1)->WithType(expected_type);
384 ARROW_ASSIGN_OR_RAISE(*table_owner,
385 table.SetColumn(N - 1, new_field, casted.chunked_array()));
386 *result = **table_owner;
387 }
388
389 return EnsureColumnTypes<Tuple, N - 1>::Cast(result->get(), table_owner, cast_options,
390 ctx, result);
391 }
392};
393
394template <typename Tuple>

Callers

nothing calls this directly

Calls 11

CastFunction · 0.85
WithTypeMethod · 0.80
chunked_arrayMethod · 0.80
type_singletonFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.50
EqualsMethod · 0.45
typeMethod · 0.45
fieldMethod · 0.45
schemaMethod · 0.45
SetColumnMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected