Path: blob/main/crates/polars-parquet/src/parquet/schema/io_thrift/mod.rs
8512 views
mod from_thrift;12mod to_thrift;34#[cfg(test)]5mod tests {6use crate::parquet::error::ParquetResult;7use crate::parquet::schema::io_message::from_message;8use crate::parquet::schema::types::ParquetType;910fn test_round_trip(message: &str) -> ParquetResult<()> {11let expected_schema = from_message(message)?;12let thrift_schema = expected_schema.to_thrift();13let thrift_schema = thrift_schema.into_iter().collect::<Vec<_>>();14let result_schema = ParquetType::try_from_thrift(&thrift_schema)?;15assert_eq!(result_schema, expected_schema);16Ok(())17}1819#[test]20fn test_schema_type_thrift_conversion() {21let message_type = "22message conversions {23REQUIRED INT64 id;24OPTIONAL group int_array_Array (LIST) {25REPEATED group list {26OPTIONAL group element (LIST) {27REPEATED group list {28OPTIONAL INT32 element;29}30}31}32}33OPTIONAL group int_map (MAP) {34REPEATED group map (MAP_KEY_VALUE) {35REQUIRED BYTE_ARRAY key (UTF8);36OPTIONAL INT32 value;37}38}39OPTIONAL group int_Map_Array (LIST) {40REPEATED group list {41OPTIONAL group g (MAP) {42REPEATED group map (MAP_KEY_VALUE) {43REQUIRED BYTE_ARRAY key (UTF8);44OPTIONAL group value {45OPTIONAL group H {46OPTIONAL group i (LIST) {47REPEATED group list {48OPTIONAL DOUBLE element;49}50}51}52}53}54}55}56}57OPTIONAL group nested_struct {58OPTIONAL INT32 A;59OPTIONAL group b (LIST) {60REPEATED group list {61REQUIRED FIXED_LEN_BYTE_ARRAY (16) element;62}63}64}65}66";67test_round_trip(message_type).unwrap();68}6970#[test]71fn test_schema_type_thrift_conversion_decimal() {72let message_type = "73message decimals {74OPTIONAL INT32 field0;75OPTIONAL INT64 field1 (DECIMAL (18, 2));76OPTIONAL FIXED_LEN_BYTE_ARRAY (16) field2 (DECIMAL (38, 18));77OPTIONAL BYTE_ARRAY field3 (DECIMAL (9));78}79";80test_round_trip(message_type).unwrap();81}82}838485