| 93 | int NumBatches() override { return num_batches_; } |
| 94 | |
| 95 | static Result<csv::ConvertOptions> GetConvertOptions( |
| 96 | const CsvFragmentScanOptions& csv_options, const FragmentScanRequest& scan_request, |
| 97 | const CsvInspectedFragment& inspected_fragment) { |
| 98 | // We use the convert options given from the user but override which columns we are |
| 99 | // looking for. |
| 100 | auto convert_options = csv_options.convert_options; |
| 101 | std::vector<std::string> columns; |
| 102 | std::unordered_map<std::string, std::shared_ptr<DataType>> column_types; |
| 103 | for (const auto& scan_column : scan_request.fragment_selection->columns()) { |
| 104 | if (scan_column.path.indices().size() != 1) { |
| 105 | return Status::Invalid("CSV reader does not supported nested references"); |
| 106 | } |
| 107 | const std::string& column_name = |
| 108 | inspected_fragment.column_names[scan_column.path.indices()[0]]; |
| 109 | columns.push_back(column_name); |
| 110 | column_types[column_name] = scan_column.requested_type->GetSharedPtr(); |
| 111 | } |
| 112 | convert_options.include_columns = std::move(columns); |
| 113 | convert_options.column_types = std::move(column_types); |
| 114 | return convert_options; |
| 115 | } |
| 116 | |
| 117 | static Future<std::shared_ptr<FragmentScanner>> Make( |
| 118 | const CsvFragmentScanOptions& csv_options, const FragmentScanRequest& scan_request, |