sunchao / parquet-rs

Apache Parquet implementation in Rust
Apache License 2.0
149 stars 20 forks source link

How to get column name #200

Closed jcgomes90 closed 5 years ago

jcgomes90 commented 5 years ago

I am trying to write out a parquet file with a schema that will have many fields:

let message_type = "message schema"
{
     REQUIRED DOUBLE a;
     OPTIONAL DOUBLE b;
     ...
}

I am iterating through the row columns as below.

let mut row_group_writer = serialized_writer.next_row_group().unwrap();
while let Some(mut col_writer) = row_group_writer.next_column().unwrap()
{
     ...
}

I want to read the column name of the schema (ie. 'a'). Ideally have a match statement within the while loop for the column name. I read through the parquet-rs documentations and couldn't find a way to do this. Is this possible? Is there an alternative method?

sunchao commented 5 years ago

When you initialize the file writer, you'd pass a schema to it right? you should be able to get the field name from the schema I think.