MCPcopy Create free account
hub / github.com/apache/datafusion / widen_schema

Function widen_schema

benchmarks/src/bin/gen_wide_data.rs:189–209  ·  view source on GitHub ↗

Builds the wide schema by laying out the suffix-renamed zero-padded copies first and the unsuffixed base columns last. Putting the base columns at the *end* of the schema is deliberate — column lookup for the filter / project columns has to traverse past all the padding entries, exercising any per-column-position cost in the scanner / planner.

(src: &SchemaRef, factor: usize)

Source from the content-addressed store, hash-verified

187/// padding entries, exercising any per-column-position cost in the
188/// scanner / planner.
189fn widen_schema(src: &SchemaRef, factor: usize) -> SchemaRef {
190 let src_fields = src.fields();
191 let mut fields: Vec<Arc<Field>> = Vec::with_capacity(src_fields.len() * factor);
192 for copy in 2..=factor {
193 for f in src_fields {
194 fields.push(Arc::new(Field::new(
195 format!("{}_{}", f.name(), copy),
196 f.data_type().clone(),
197 true,
198 )));
199 }
200 }
201 for f in src_fields {
202 fields.push(Arc::new(Field::new(
203 f.name().clone(),
204 f.data_type().clone(),
205 f.is_nullable(),
206 )));
207 }
208 Arc::new(Schema::new(fields))
209}
210
211fn widen_batch(
212 batch: &RecordBatch,

Callers 1

mainFunction · 0.85

Calls 8

newFunction · 0.85
fieldsMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
data_typeMethod · 0.45
nameMethod · 0.45
is_nullableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…