[[arrow::export]]
| 48 | |
| 49 | // [[arrow::export]] |
| 50 | std::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 | |
| 67 | template <typename T> |
| 68 | std::shared_ptr<T> MaybeUnbox(const char* class_name, SEXP x) { |
no test coverage detected