Build a [`PaimonTableScan`] from the configured parameters.
(self)
| 103 | impl PaimonScanBuilder<'_> { |
| 104 | /// Build a [`PaimonTableScan`] from the configured parameters. |
| 105 | pub(crate) fn build(self) -> DFResult<Arc<dyn ExecutionPlan>> { |
| 106 | let (projected_schema, projected_columns) = if let Some(indices) = self.projection { |
| 107 | let fields: Vec<Field> = indices |
| 108 | .iter() |
| 109 | .map(|&i| self.schema.field(i).clone()) |
| 110 | .collect(); |
| 111 | let column_names: Vec<String> = fields.iter().map(|f| f.name().clone()).collect(); |
| 112 | (Arc::new(Schema::new(fields)), Some(column_names)) |
| 113 | } else { |
| 114 | let column_names: Vec<String> = self |
| 115 | .schema |
| 116 | .fields() |
| 117 | .iter() |
| 118 | .map(|f| f.name().clone()) |
| 119 | .collect(); |
| 120 | (self.schema.clone(), Some(column_names)) |
| 121 | }; |
| 122 | |
| 123 | let splits = self.plan.splits().to_vec(); |
| 124 | let planned_partitions: Vec<Arc<[_]>> = if splits.is_empty() { |
| 125 | vec![Arc::from(Vec::new())] |
| 126 | } else { |
| 127 | let num_partitions = splits.len().min(self.target_partitions.max(1)); |
| 128 | bucket_round_robin(splits, num_partitions) |
| 129 | .into_iter() |
| 130 | .map(Arc::from) |
| 131 | .collect() |
| 132 | }; |
| 133 | |
| 134 | Ok(Arc::new(PaimonTableScan::new( |
| 135 | projected_schema, |
| 136 | self.table.clone(), |
| 137 | projected_columns, |
| 138 | self.pushed_predicate, |
| 139 | planned_partitions, |
| 140 | self.limit, |
| 141 | self.filter_exact, |
| 142 | ))) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | #[async_trait] |