You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/02/11 22:33:28 UTC

[GitHub] [arrow-rs] ScottSyms edited a comment on issue #1302: module 'data_type' is private in Rust Parquet 8.0.0

ScottSyms edited a comment on issue #1302:
URL: https://github.com/apache/arrow-rs/issues/1302#issuecomment-1036692748


   Executing some code from stack overflow which works with the Rust parquet crate versions earlier than 8.0.0.  The error generated by the **use parquet::data_type::ByteArray;** import suggests the data_type module is not made public.  Not sure if this a release change or a bug.
   
   ```
   use std::{fs, path::Path, sync::Arc};
   use parquet::{column::writer::ColumnWriter, data_type::ByteArray, file::{
       properties::WriterProperties,
       writer::{FileWriter, SerializedFileWriter},
   }, schema::parser::parse_message_type};
   
   fn main() {
       let path = Path::new("./sample.parquet");
   
       let message_type = "
           message schema {
               REQUIRED INT32 b;
               REQUIRED BINARY msg (UTF8);
           }
       ";
       let schema = Arc::new(parse_message_type(message_type).unwrap());
       let props = Arc::new(WriterProperties::builder().build());
       let file = fs::File::create(&path).unwrap();
   
       let mut rows: i64 = 0;
       let data = vec![
           (10, "A"),
           (20, "B"),
           (30, "C"),
           (40, "D"),
       ];
   
       let mut writer = SerializedFileWriter::new(file, schema, props).unwrap();
       for (key, value) in data {
           let mut row_group_writer = writer.next_row_group().unwrap();
           let id_writer = row_group_writer.next_column().unwrap();
           if let Some(mut writer) = id_writer {
               match writer {
                   ColumnWriter::Int32ColumnWriter(ref mut typed) => {
                       let values = vec![key];
                       rows +=
                           typed.write_batch(&values[..], None, None).unwrap() as i64;
                   },
                   _ => {
                       unimplemented!();
                   }
               }
               row_group_writer.close_column(writer).unwrap();
           }
           let data_writer = row_group_writer.next_column().unwrap();
           if let Some(mut writer) = data_writer {
               match writer {
                   ColumnWriter::ByteArrayColumnWriter(ref mut typed) => {
                       let values = ByteArray::from(value);
                       rows += typed.write_batch(&[values], None, None).unwrap() as i64;
                   }
                   _ => {
                       unimplemented!();
                   }
               }
               row_group_writer.close_column(writer).unwrap();
           }
           writer.close_row_group(row_group_writer).unwrap();
       }
       writer.close().unwrap();
   
       println!("Wrote {}", rows);
   
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org