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

Function populate_csv_partitions

datafusion/core/src/test_util/mod.rs:151–177  ·  view source on GitHub ↗

Generate CSV partitions within the supplied directory

(
    tmp_dir: &TempDir,
    partition_count: usize,
    file_extension: &str,
)

Source from the content-addressed store, hash-verified

149
150/// Generate CSV partitions within the supplied directory
151pub fn populate_csv_partitions(
152 tmp_dir: &TempDir,
153 partition_count: usize,
154 file_extension: &str,
155) -> Result<SchemaRef> {
156 // define schema for data source (csv file)
157 let schema = Arc::new(Schema::new(vec![
158 Field::new("c1", DataType::UInt32, false),
159 Field::new("c2", DataType::UInt64, false),
160 Field::new("c3", DataType::Boolean, false),
161 ]));
162
163 // generate a partitioned file
164 for partition in 0..partition_count {
165 let filename = format!("partition-{partition}.{file_extension}");
166 let file_path = tmp_dir.path().join(filename);
167 let mut file = File::create(file_path)?;
168
169 // generate some data
170 for i in 0..=10 {
171 let data = format!("{},{},{}\n", partition, i, i % 2 == 0);
172 file.write_all(data.as_bytes())?;
173 }
174 }
175
176 Ok(schema)
177}
178
179/// TableFactory for tests
180#[derive(Default, Debug)]

Callers 2

create_ctxFunction · 0.50

Calls 5

newFunction · 0.85
createFunction · 0.85
joinMethod · 0.45
pathMethod · 0.45
write_allMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…