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

Function Table__cast

r/src/compute.cpp:50–65  ·  view source on GitHub ↗

[[arrow::export]]

Source from the content-addressed store, hash-verified

48
49// [[arrow::export]]
50std::shared_ptr<arrow::Table> Table__cast(const std::shared_ptr<arrow::Table>& table,
51 const std::shared_ptr<arrow::Schema>& schema,
52 cpp11::list options) {
53 auto opts = make_cast_options(options);
54 auto nc = table->num_columns();
55
56 using ColumnVector = std::vector<std::shared_ptr<arrow::ChunkedArray>>;
57 ColumnVector columns(nc);
58 for (int i = 0; i < nc; i++) {
59 arrow::Datum value(table->column(i));
60 arrow::Datum out =
61 ValueOrStop(arrow::compute::Cast(value, schema->field(i)->type(), *opts));
62 columns[i] = out.chunked_array();
63 }
64 return arrow::Table::Make(schema, std::move(columns), table->num_rows());
65}
66
67template <typename T>
68std::shared_ptr<T> MaybeUnbox(const char* class_name, SEXP x) {

Callers 1

_arrow_Table__castFunction · 0.85

Calls 10

make_cast_optionsFunction · 0.85
ValueOrStopFunction · 0.85
CastFunction · 0.85
chunked_arrayMethod · 0.80
MakeFunction · 0.50
num_columnsMethod · 0.45
columnMethod · 0.45
typeMethod · 0.45
fieldMethod · 0.45
num_rowsMethod · 0.45

Tested by

no test coverage detected