message: Adding Projection Pushdown to Arrow Scans
diff: @@ -953,7 +953,8 @@ void ColumnArrowToDuckDBDictionary(Vector &vector, ArrowArray &array, ArrowScanS
  void ArrowTableFunction::ArrowToDuckDB(ArrowScanState &scan_state,
  std::unordered_map<idx_t, unique_ptr<ArrowConvertData>> &arrow_convert_data,
  DataChunk &output) {
  - for (idx_t col_idx = 0; col_idx < output.ColumnCount(); col_idx++) {
  + for (idx_t idx = 0; idx < scan_state.column_ids.size(); idx++) {
  + auto col_idx = scan_state.column_ids[idx];
  std::pair<idx_t, idx_t> arrow_convert_idx {0, 0};
  auto &array = *scan_state.chunk->arrow_array.children[col_idx];
  if (!array.release) {
  @@ -963,11 +964,11 @@ void ArrowTableFunction::ArrowToDuckDB(ArrowScanState &scan_state,
  throw InvalidInputException("arrow_scan: array length mismatch");
  }
  if (array.dictionary) {
  - ColumnArrowToDuckDBDictionary(output.data[col_idx], array, scan_state, output.size(), arrow_convert_data,
  + ColumnArrowToDuckDBDictionary(output.data[idx], array, scan_state, output.size(), arrow_convert_data,
  col_idx, arrow_convert_idx);
  } else {
  - SetValidityMask(output.data[col_idx], array, scan_state, output.size(), -1);
  - ColumnArrowToDuckDB(output.data[col_idx], array, scan_state, output.size(), arrow_convert_data, col_idx,
  + SetValidityMask(output.data[idx], array, scan_state, output.size(), -1);
  + ColumnArrowToDuckDB(output.data[idx], array, scan_state, output.size(), arrow_convert_data, col_idx,
  arrow_convert_idx);
  }
  }
  @@ -990,9 +991,6 @@ void ArrowTableFunction::ArrowScanFunction(ClientContext &context, const Functio
  return;
  }
  - if ((idx_t)state.chunk->arrow_array.n_children != output.ColumnCount()) {
  - throw InvalidInputException("arrow_scan: array column count mismatch");
  - }
  int64_t output_size = MinValue<int64_t>(STANDARD_VECTOR_SIZE, state.chunk->arrow_array.length - state.chunk_offset);
  data.lines_read += output_size;
  output.SetCardinality(output_size);
  @@ -1010,9 +1008,6 @@ void ArrowTableFunction::ArrowScanFunctionParallel(ClientContext &context, const
  if (state.chunk_offset >= (idx_t)state.chunk->arrow_array.length) {
  return;
  }
  - if ((idx_t)state.chunk->arrow_array.n_children != output.ColumnCount()) {
  - throw InvalidInputException("arrow_scan: array column count mismatch");
  - }
  int64_t output_size = MinValue<int64_t>(STANDARD_VECTOR_SIZE, state.chunk->arrow_array.length - state.chunk_offset);
  data.lines_read += output_size;
  output.SetCardinality(output_size);
  @@ -1081,7 +1076,7 @@ void ArrowTableFunction::RegisterFunction(BuiltinFunctions &set) {
  ArrowScanFunction, ArrowScanBind, ArrowScanInit, nullptr, nullptr, nullptr,
  ArrowScanCardinality, nullptr, nullptr, ArrowScanMaxThreads,
  ArrowScanInitParallelState, ArrowScanFunctionParallel, ArrowScanParallelInit,
  - ArrowScanParallelStateNext, false, false, ArrowProgress));
  + ArrowScanParallelStateNext, true, false, ArrowProgress));
  set.AddFunction(arrow);
  }
  