/// Generate CSV partitions within the supplied directory
Generate CSV partitions within the supplied directory
Generate CSV partitions within the supplied directory
fn populate_csv_partitions(
        tmp_dir: &TempDir,
        partition_count: usize,
        file_extension: &str,
    ) -> Result<SchemaRef> {
        // define schema for data source (csv file)
        let schema = Arc::new(Schema::new(vec![
            Field::new("c1", DataType::UInt32, false),
            Field::new("c2", DataType::UInt64, false),
            Field::new("c3", DataType::Boolean, false),
        ]));
        // generate a partitioned file
        for partition in 0..partition_count {
            let filename = format!("partition-{}.{}", partition, file_extension);
            let file_path = tmp_dir.path().join(&filename);
            let mut file = File::create(file_path)?;
            // generate some data
            for i in 0..=10 {
                let data = format!("{},{},{}\n", partition, i, i % 2 == 0);
                file.write_all(data.as_bytes())?;
            }
        }
        Ok(schema)
    }
fn populate_csv_partitions ( tmp_dir : & TempDir , partition_count : usize , file_extension : & str , ) -> Result < SchemaRef > { // define schema for data source (csv file) let schema = Arc :: new ( Schema :: new ( vec ! [ Field new ( " " DataType UInt32 false ) Field new ( " " DataType UInt64 false ) Field new ( " " DataType Boolean false ) ] ) ) ; // generate a partitioned file for partition in 0 .. partition_count { let filename = format ! ( " " partition file_extension ) ; let file_path = tmp_dir . path ( ) . join ( & filename ) ; let mut file = File :: create ( file_path ) ? ; // generate some data for i in 0 ..= 10 { let data = format ! ( " \n " partition i i 2 0 ) ; file . write_all ( data . as_bytes ( ) ) ? ; } } Ok ( schema ) }
Generate CSV partitions within the supplied directory
Generate CSV partitions within the supplied directory
tmp_dir
&TempDir
partition_count
usize
file_extension
&str