You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@parquet.apache.org by "etseidl (via GitHub)" <gi...@apache.org> on 2024/11/15 22:18:50 UTC

[PR] Add map_no_value.parquet [parquet-testing]

etseidl opened a new pull request, #63:
URL: https://github.com/apache/parquet-testing/pull/63

   https://github.com/apache/parquet-format/pull/469 recently clarified that a `MAP` in a Parquet file need not have a `values` field in the `key_value` group. This PR adds `map_no_value.parquet` which contains such a map.


-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#discussion_r1848804699


##########
data/map_no_value.md:
##########
@@ -0,0 +1,159 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+`map_no_value.parquet` is generated with parquet-rs version 53.2.0
+using the following code:
+```
+    fn main() {
+        use crate::schema::parser::parse_message_type;
+        use crate::file::writer::SerializedFileWriter;
+        use crate::data_type::Int32Type;
+        use std::sync::Arc;
+
+        let schema = "
+            message spark_schema {
+                REQUIRED group my_map (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                        OPTIONAL INT32 value;
+                    }
+                }
+                REQUIRED group my_map_no_v (MAP) {

Review Comment:
   Yes, that's the troublesome column. I include the others for validation, since the spec says a value-less map `can be represented as a map with all null values or as a set of keys`.



-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#discussion_r1854313782


##########
data/map_no_value.md:
##########
@@ -0,0 +1,163 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+`map_no_value.parquet` is generated with parquet-rs version 53.2.0
+using the following code:
+```
+    fn main() {
+        use crate::data_type::Int32Type;
+        use crate::file::properties::{EnabledStatistics, WriterProperties};
+        use crate::file::writer::SerializedFileWriter;
+        use crate::schema::parser::parse_message_type;
+        use std::sync::Arc;
+
+        let schema = "
+            message schema {
+                REQUIRED group my_map (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                        OPTIONAL INT32 value;
+                    }
+                }
+                REQUIRED group my_map_no_v (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                    }
+                }
+                REQUIRED group my_list (LIST) {
+                    REPEATED group list {
+                        REQUIRED INT32 element;
+                    }
+                }
+            }
+            ";
+        let schema = Arc::new(parse_message_type(schema).unwrap());
+
+        // Write Parquet file to buffer
+        let mut file = std::fs::File::create("/tmp/map_no_value.parquet").unwrap();
+        let props = Arc::new(
+            WriterProperties::builder()
+                .set_statistics_enabled(EnabledStatistics::None)
+                .build(),
+        );
+        let mut file_writer = SerializedFileWriter::new(&mut file, schema, props).unwrap();
+        let mut row_group_writer = file_writer.next_row_group().unwrap();
+
+        // Write column my_map.key_value.key
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_map.key_value.value
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_map_no_v.key_value.key
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_list.list.element
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Finalize Parquet file
+        row_group_writer.close().unwrap();
+        file_writer.close().unwrap();
+    }
+```
+
+It contains a MAP with all null values, a second MAP without a `values` field, and
+an equivalent LIST repeating the MAP keys. The first column is 3 MAP rows:
+```
+{1 -> null, 2 -> null, 3 -> null}
+{4 -> null, 5 -> null, 6 -> null}
+{7 -> null, 8 -> null, 9 -> null}
+```
+
+The last two columns comprise 3 equivalent rows of `list<Integer>`:
+```
+[1, 2, 3]
+[4, 5, 6]
+[7, 8, 9]
+```
+
+Here is the file metadata printed by parquet-cli:
+```
+File path:  map_no_value.parquet
+Created by: parquet-rs version 53.2.0
+Properties: (none)
+Schema:
+message schema {
+  required group my_map (MAP) {
+    repeated group key_value {
+      required int32 key;
+      optional int32 value;
+    }
+  }
+  required group my_map_no_v (MAP) {
+    repeated group key_value {
+      required int32 key;
+    }
+  }
+  required group my_list (LIST) {
+    repeated group list {
+      required int32 element;
+    }
+  }
+}
+
+
+Row group 0:  count: 3  105.00 B records  start: 4  total(compressed): 315 B total(uncompressed):315 B
+--------------------------------------------------------------------------------
+                           type      encodings count     avg size   nulls   min / max
+my_map.key_value.key       INT32     _ RR_     9         10.00 B            
+my_map.key_value.value     INT32     _ RR_     9         5.00 B             
+my_map_no_v.key_value.key  INT32     _ RR_     9         10.00 B            
+my_list.list.element       INT32     _ RR_     9         10.00 B

Review Comment:
   Oops. Fixed.



-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#discussion_r1847225319


##########
data/map_no_value.md:
##########
@@ -0,0 +1,54 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+`map_no_value.parquet` is generated with parquet-rs version 53.2.0.

Review Comment:
   Added. I also added another column to the example: a `MAP` with all null values.



-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#issuecomment-2494260826

   >  Btw, can we disable PageIndex to make it smaller?
   
   For some reason parquet-rs always produces an offset index, even if statistics are disabled. At least it's only 40-ish bytes extra.


-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on code in PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#discussion_r1853412089


##########
data/map_no_value.md:
##########
@@ -0,0 +1,163 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+`map_no_value.parquet` is generated with parquet-rs version 53.2.0
+using the following code:
+```
+    fn main() {
+        use crate::data_type::Int32Type;
+        use crate::file::properties::{EnabledStatistics, WriterProperties};
+        use crate::file::writer::SerializedFileWriter;
+        use crate::schema::parser::parse_message_type;
+        use std::sync::Arc;
+
+        let schema = "
+            message schema {
+                REQUIRED group my_map (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                        OPTIONAL INT32 value;
+                    }
+                }
+                REQUIRED group my_map_no_v (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                    }
+                }
+                REQUIRED group my_list (LIST) {
+                    REPEATED group list {
+                        REQUIRED INT32 element;
+                    }
+                }
+            }
+            ";
+        let schema = Arc::new(parse_message_type(schema).unwrap());
+
+        // Write Parquet file to buffer
+        let mut file = std::fs::File::create("/tmp/map_no_value.parquet").unwrap();
+        let props = Arc::new(
+            WriterProperties::builder()
+                .set_statistics_enabled(EnabledStatistics::None)
+                .build(),
+        );
+        let mut file_writer = SerializedFileWriter::new(&mut file, schema, props).unwrap();
+        let mut row_group_writer = file_writer.next_row_group().unwrap();
+
+        // Write column my_map.key_value.key
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_map.key_value.value
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_map_no_v.key_value.key
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_list.list.element
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Finalize Parquet file
+        row_group_writer.close().unwrap();
+        file_writer.close().unwrap();
+    }
+```
+
+It contains a MAP with all null values, a second MAP without a `values` field, and
+an equivalent LIST repeating the MAP keys. The first column is 3 MAP rows:
+```
+{1 -> null, 2 -> null, 3 -> null}
+{4 -> null, 5 -> null, 6 -> null}
+{7 -> null, 8 -> null, 9 -> null}
+```
+
+The last two columns comprise 3 equivalent rows of `list<Integer>`:
+```
+[1, 2, 3]
+[4, 5, 6]
+[7, 8, 9]
+```
+
+Here is the file metadata printed by parquet-cli:
+```
+File path:  map_no_value.parquet
+Created by: parquet-rs version 53.2.0
+Properties: (none)
+Schema:
+message schema {
+  required group my_map (MAP) {
+    repeated group key_value {
+      required int32 key;
+      optional int32 value;
+    }
+  }
+  required group my_map_no_v (MAP) {
+    repeated group key_value {
+      required int32 key;
+    }
+  }
+  required group my_list (LIST) {
+    repeated group list {
+      required int32 element;
+    }
+  }
+}
+
+
+Row group 0:  count: 3  105.00 B records  start: 4  total(compressed): 315 B total(uncompressed):315 B
+--------------------------------------------------------------------------------
+                           type      encodings count     avg size   nulls   min / max
+my_map.key_value.key       INT32     _ RR_     9         10.00 B            
+my_map.key_value.value     INT32     _ RR_     9         5.00 B             
+my_map_no_v.key_value.key  INT32     _ RR_     9         10.00 B            
+my_list.list.element       INT32     _ RR_     9         10.00 B

Review Comment:
   Nit: the code block (```) is not closed



-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#discussion_r1848477378


##########
data/map_no_value.md:
##########
@@ -0,0 +1,159 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+`map_no_value.parquet` is generated with parquet-rs version 53.2.0
+using the following code:
+```
+    fn main() {
+        use crate::schema::parser::parse_message_type;
+        use crate::file::writer::SerializedFileWriter;
+        use crate::data_type::Int32Type;
+        use std::sync::Arc;
+
+        let schema = "
+            message spark_schema {
+                REQUIRED group my_map (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                        OPTIONAL INT32 value;
+                    }
+                }
+                REQUIRED group my_map_no_v (MAP) {

Review Comment:
   So this is we actually needed?



-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#issuecomment-2493107927

   ```
   {
     "Version": "1.0",
     "CreatedBy": "parquet-rs version 53.2.0",
     "TotalRows": "3",
     "NumberOfRowGroups": "1",
     "NumberOfRealColumns": "3",
     "NumberOfColumns": "4",
     "Columns": [
        { "Id": "0", "Name": "my_map.key_value.key", "PhysicalType": "INT32", "ConvertedType": "NONE", "LogicalType": {"Type": "None"} },
        { "Id": "1", "Name": "my_map.key_value.value", "PhysicalType": "INT32", "ConvertedType": "NONE", "LogicalType": {"Type": "None"} },
        { "Id": "2", "Name": "my_map_no_v.key_value.key", "PhysicalType": "INT32", "ConvertedType": "NONE", "LogicalType": {"Type": "None"} },
        { "Id": "3", "Name": "my_list.list.element", "PhysicalType": "INT32", "ConvertedType": "NONE", "LogicalType": {"Type": "None"} }
     ],
     "RowGroups": [
        {
          "Id": "0",  "TotalBytes": "315",  "TotalCompressedBytes": "315",  "Rows": "3",
          "ColumnChunks": [
             {"Id": "0", "Values": "9", "StatsSet": "False",
              "Compression": "UNCOMPRESSED", "Encodings": "PLAIN RLE RLE_DICTIONARY ", "UncompressedSize": "90", "CompressedSize": "90", "OffsetIndex": {"offset": "319", "length": "10"} },
             {"Id": "1", "Values": "9", "StatsSet": "False",
              "Compression": "UNCOMPRESSED", "Encodings": "PLAIN RLE RLE_DICTIONARY ", "UncompressedSize": "45", "CompressedSize": "45", "OffsetIndex": {"offset": "329", "length": "11"} },
             {"Id": "2", "Values": "9", "StatsSet": "False",
              "Compression": "UNCOMPRESSED", "Encodings": "PLAIN RLE RLE_DICTIONARY ", "UncompressedSize": "90", "CompressedSize": "90", "OffsetIndex": {"offset": "340", "length": "11"} },
             {"Id": "3", "Values": "9", "StatsSet": "False",
              "Compression": "UNCOMPRESSED", "Encodings": "PLAIN RLE RLE_DICTIONARY ", "UncompressedSize": "90", "CompressedSize": "90", "OffsetIndex": {"offset": "351", "length": "11"} }
           ]
        }
     ]
   }
   ```
   
   General LGTM. Btw, can we disable PageIndex to make it smaller?


-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#discussion_r1845403766


##########
data/map_no_value.md:
##########
@@ -0,0 +1,54 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+`map_no_value.parquet` is generated with parquet-rs version 53.2.0.

Review Comment:
   Would it help to mention how you made this file?



-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#issuecomment-2494549352

   > > Btw, can we disable PageIndex to make it smaller?
   > 
   > For some reason parquet-rs always produces an offset index, even if statistics are disabled. At least it's only 40-ish bytes extra.
   
   Is this something we should consider changing (make the offset index optional?)


-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#issuecomment-2495459421

   > Probably...I've never touched that behavior because I don't know if it is intentional or not.
   
   I vaguely remember the original rationale being it was impossible to decode ranges (e.g. rows 100-200) if you didn't have the offset index, and since it was small it was ok to always write.
   
   


-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#discussion_r1849584329


##########
data/map_no_value.md:
##########
@@ -0,0 +1,159 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+`map_no_value.parquet` is generated with parquet-rs version 53.2.0
+using the following code:
+```
+    fn main() {
+        use crate::schema::parser::parse_message_type;
+        use crate::file::writer::SerializedFileWriter;
+        use crate::data_type::Int32Type;
+        use std::sync::Arc;
+
+        let schema = "
+            message spark_schema {
+                REQUIRED group my_map (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                        OPTIONAL INT32 value;
+                    }
+                }
+                REQUIRED group my_map_no_v (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                    }
+                }
+                REQUIRED group my_list (LIST) {
+                    REPEATED group list {
+                        REQUIRED INT32 element;
+                    }
+                }
+            }
+            ";
+        let schema = Arc::new(parse_message_type(schema).unwrap());
+
+        // Write Parquet file to buffer
+        let mut buffer = std::fs::File::create("/tmp/map_no_value.parquet").unwrap();
+        let mut file_writer =
+            SerializedFileWriter::new(&mut buffer, schema, Default::default()).unwrap();
+        let mut row_group_writer = file_writer.next_row_group().unwrap();
+
+        // Write column my_map.key_value.key
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_map.key_value.value
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_map_no_v.key_value.key
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_list.list.element
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Finalize Parquet file
+        row_group_writer.close().unwrap();
+        file_writer.close().unwrap();
+    }
+```
+
+It contains a MAP with all null values, a second MAP without a `values` field, and
+an equivalent LIST repeating the MAP keys. The first column is 3 MAP rows:
+```
+{1 -> null, 2 -> null, 3 -> null}
+{4 -> null, 5 -> null, 6 -> null}
+{7 -> null, 8 -> null, 9 -> null}
+```
+
+The last two columns comprise 3 equivalent rows of `list<Integer>`:
+```
+[1, 2, 3]
+[4, 5, 6]
+[7, 8, 9]
+```
+
+Here is the file metadata printed by parquet-cli:
+```
+File path:  map_no_value.parquet
+Created by: parquet-rs version 53.2.0
+Properties: (none)
+Schema:
+message spark_schema {
+  required group my_map (MAP) {
+    repeated group key_value {
+      required int32 key;
+      optional int32 value;
+    }
+  }
+  required group my_map_no_v (MAP) {
+    repeated group key_value {
+      required int32 key;
+    }
+  }
+  required group my_list (LIST) {
+    repeated group list {
+      required int32 element;
+    }
+  }
+}
+
+
+Row group 0:  count: 3  123.00 B records  start: 4  total(compressed): 369 B total(uncompressed):369 B 

Review Comment:
   The row group is 369 B but the total file size is 1.1KB. Can we reduce those unnecessary overhead?



-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on code in PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#discussion_r1849664627


##########
data/map_no_value.md:
##########
@@ -0,0 +1,159 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+`map_no_value.parquet` is generated with parquet-rs version 53.2.0
+using the following code:
+```
+    fn main() {
+        use crate::schema::parser::parse_message_type;
+        use crate::file::writer::SerializedFileWriter;
+        use crate::data_type::Int32Type;
+        use std::sync::Arc;
+
+        let schema = "
+            message spark_schema {
+                REQUIRED group my_map (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                        OPTIONAL INT32 value;
+                    }
+                }
+                REQUIRED group my_map_no_v (MAP) {
+                    REPEATED group key_value {
+                        REQUIRED INT32 key;
+                    }
+                }
+                REQUIRED group my_list (LIST) {
+                    REPEATED group list {
+                        REQUIRED INT32 element;
+                    }
+                }
+            }
+            ";
+        let schema = Arc::new(parse_message_type(schema).unwrap());
+
+        // Write Parquet file to buffer
+        let mut buffer = std::fs::File::create("/tmp/map_no_value.parquet").unwrap();
+        let mut file_writer =
+            SerializedFileWriter::new(&mut buffer, schema, Default::default()).unwrap();
+        let mut row_group_writer = file_writer.next_row_group().unwrap();
+
+        // Write column my_map.key_value.key
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_map.key_value.value
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_map_no_v.key_value.key
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Write column my_list.list.element
+        let mut column_writer = row_group_writer.next_column().unwrap().unwrap();
+        column_writer
+            .typed::<Int32Type>()
+            .write_batch(
+                &[1, 2, 3, 4, 5, 6, 7, 8, 9],
+                Some(&[1, 1, 1, 1, 1, 1, 1, 1, 1]),
+                Some(&[0, 1, 1, 0, 1, 1, 0, 1, 1]),
+            )
+            .unwrap();
+        column_writer.close().unwrap();
+
+        // Finalize Parquet file
+        row_group_writer.close().unwrap();
+        file_writer.close().unwrap();
+    }
+```
+
+It contains a MAP with all null values, a second MAP without a `values` field, and
+an equivalent LIST repeating the MAP keys. The first column is 3 MAP rows:
+```
+{1 -> null, 2 -> null, 3 -> null}
+{4 -> null, 5 -> null, 6 -> null}
+{7 -> null, 8 -> null, 9 -> null}
+```
+
+The last two columns comprise 3 equivalent rows of `list<Integer>`:
+```
+[1, 2, 3]
+[4, 5, 6]
+[7, 8, 9]
+```
+
+Here is the file metadata printed by parquet-cli:
+```
+File path:  map_no_value.parquet
+Created by: parquet-rs version 53.2.0
+Properties: (none)
+Schema:
+message spark_schema {
+  required group my_map (MAP) {
+    repeated group key_value {
+      required int32 key;
+      optional int32 value;
+    }
+  }
+  required group my_map_no_v (MAP) {
+    repeated group key_value {
+      required int32 key;
+    }
+  }
+  required group my_list (LIST) {
+    repeated group list {
+      required int32 element;
+    }
+  }
+}
+
+
+Row group 0:  count: 3  123.00 B records  start: 4  total(compressed): 369 B total(uncompressed):369 B 

Review Comment:
   I got rid of most of the statistics and got the file size down to 825B. I don't think the footer can be made much smaller.



-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU merged PR #63:
URL: https://github.com/apache/parquet-testing/pull/63


-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org


Re: [PR] Add map_no_value.parquet [parquet-testing]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #63:
URL: https://github.com/apache/parquet-testing/pull/63#issuecomment-2494773143

   > > > Btw, can we disable PageIndex to make it smaller?
   > > 
   > > 
   > > For some reason parquet-rs always produces an offset index, even if statistics are disabled. At least it's only 40-ish bytes extra.
   > 
   > Is this something we should consider changing (make the offset index optional?)
   
   Probably...I've never touched that behavior because I don't know if it is intentional or not.


-- 
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: issues-unsubscribe@parquet.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@parquet.apache.org
For additional commands, e-mail: issues-help@parquet.apache.org