Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes array type conversion in legacy mode
  • Loading branch information
liancheng committed Aug 1, 2015
commit 2859132e33a1d8d4e86016feca1d0876d162b380
Original file line number Diff line number Diff line change
Expand Up @@ -439,29 +439,31 @@ private[parquet] class CatalystSchemaConverter(
// ===================================================

// Spark 1.4.x and prior versions convert ArrayType with nullable elements into a 3-level
// LIST structure. This behavior mimics parquet-hive (1.6.0rc3). Note that this case is
// covered by the backwards-compatibility rules implemented in `isElementType()`.
// LIST structure. This behavior is somewhat a hybrid of parquet-hive and parquet-avro
// (1.6.0rc3): the 3-level structure is similar to parquet-hive while the 3rd level anonymous
// field name "array" is from parquet-avro. Note that this case is covered by the backwards-
// compatibility rules implemented in `isElementType()`.
case ArrayType(elementType, nullable @ true) if !followParquetFormatSpec =>
// <list-repetition> group <name> (LIST) {
// optional group bag {
// repeated <element-type> element;
// repeated <element-type> array;
// }
// }
ConversionPatterns.listType(
repetition,
field.name,
Types
.buildGroup(REPEATED)
// "array_element" is the name chosen by parquet-hive (1.7.0 and prior version)
.addField(convertField(StructField("array_element", elementType, nullable)))
// "array" is the name chosen by Spark SQL 1.4.0 and prior versions
.addField(convertField(StructField("array", elementType, nullable)))
.named("bag"))

// Spark 1.4.x and prior versions convert ArrayType with non-nullable elements into a 2-level
// LIST structure. This behavior mimics parquet-avro (1.6.0rc3). Note that this case is
// covered by the backwards-compatibility rules implemented in `isElementType()`.
case ArrayType(elementType, nullable @ false) if !followParquetFormatSpec =>
// <list-repetition> group <name> (LIST) {
// repeated <element-type> element;
// repeated <element-type> array;
// }
ConversionPatterns.listType(
repetition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class ParquetSchemaInferenceSuite extends ParquetSchemaTest {
|message root {
| optional group _1 (LIST) {
| repeated group bag {
| optional int32 array_element;
| optional int32 array;
| }
| }
|}
Expand Down Expand Up @@ -267,7 +267,7 @@ class ParquetSchemaInferenceSuite extends ParquetSchemaTest {
| optional binary _1 (UTF8);
| optional group _2 (LIST) {
| repeated group bag {
| optional group array_element {
| optional group array {
| required int32 _1;
| required double _2;
| }
Expand Down Expand Up @@ -616,7 +616,7 @@ class ParquetSchemaSuite extends ParquetSchemaTest {
"""message root {
| optional group f1 (LIST) {
| repeated group bag {
| optional int32 array_element;
| optional int32 array;
| }
| }
|}
Expand Down