| 891 | |
| 892 | private: |
| 893 | static Result<std::shared_ptr<Table>> ToTable( |
| 894 | const std::shared_ptr<ChunkedArray>& chunked_array) { |
| 895 | if (chunked_array->null_count() == 0) { |
| 896 | return Table::FromChunkedStructArray(chunked_array); |
| 897 | } |
| 898 | // We avoid using `Table::FromChunkedStructArray` here since it doesn't take top-level |
| 899 | // validity into account for the columns. |
| 900 | // |
| 901 | // TODO: We could instead use the provided sort keys to only flatten the selected |
| 902 | // columns (via `GetFlattenedField`). Same for the Array -> RecordBatch conversion, |
| 903 | // since `RecordBatch::FromStructArray` flattens all columns as well. |
| 904 | ARROW_ASSIGN_OR_RAISE(auto columns, chunked_array->Flatten()); |
| 905 | return Table::Make(schema(chunked_array->type()->fields()), std::move(columns), |
| 906 | chunked_array->length()); |
| 907 | } |
| 908 | |
| 909 | Result<Datum> SortIndices(const Array& values, const SortOptions& options, |
| 910 | ExecContext* ctx) const { |