| 209 | } |
| 210 | |
| 211 | fn widen_batch( |
| 212 | batch: &RecordBatch, |
| 213 | wide_schema: &SchemaRef, |
| 214 | factor: usize, |
| 215 | ) -> Result<RecordBatch> { |
| 216 | let cols = batch.columns(); |
| 217 | let n_rows = batch.num_rows(); |
| 218 | let mut wide = Vec::with_capacity(cols.len() * factor); |
| 219 | // Zero-padded copies first… |
| 220 | for _ in 2..=factor { |
| 221 | for c in cols { |
| 222 | wide.push(zero_array(c.data_type(), n_rows)); |
| 223 | } |
| 224 | } |
| 225 | // …then the base data columns at the end. |
| 226 | for c in cols { |
| 227 | wide.push(Arc::clone(c)); |
| 228 | } |
| 229 | RecordBatch::try_new(Arc::clone(wide_schema), wide) |
| 230 | .map_err(|e| exec_datafusion_err!("building wide batch: {e}")) |
| 231 | } |
| 232 | |
| 233 | fn open_writer( |
| 234 | path: &Path, |