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

Function populate_csv_partitions

datafusion/core/tests/sql/mod.rs:178–204  ·  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

176
177/// Generate CSV partitions within the supplied directory
178fn populate_csv_partitions(
179 tmp_dir: &TempDir,
180 partition_count: usize,
181 file_extension: &str,
182) -> Result<SchemaRef> {
183 // define schema for data source (csv file)
184 let schema = Arc::new(Schema::new(vec![
185 Field::new("c1", DataType::UInt32, false),
186 Field::new("c2", DataType::UInt64, false),
187 Field::new("c3", DataType::Boolean, false),
188 ]));
189
190 // generate a partitioned file
191 for partition in 0..partition_count {
192 let filename = format!("partition-{partition}.{file_extension}");
193 let file_path = tmp_dir.path().join(filename);
194 let mut file = File::create(file_path)?;
195
196 // generate some data
197 for i in 0..=10 {
198 let data = format!("{},{},{}\n", partition, i, i % 2 == 0);
199 file.write_all(data.as_bytes())?;
200 }
201 }
202
203 Ok(schema)
204}
205
206/// Specialized String representation
207fn col_str(column: &ArrayRef, row_index: usize) -> String {

Callers 2

write_parquet_resultsFunction · 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…