Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8509#discussion_r38701003
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaSuite.scala
 ---
    @@ -941,4 +942,313 @@ class ParquetSchemaSuite extends ParquetSchemaTest {
           |  optional fixed_len_byte_array(8) f1 (DECIMAL(18, 3));
           |}
         """.stripMargin)
    +
    +  private def testSchemaClipping(
    +      testName: String,
    +      parquetSchema: String,
    +      catalystSchema: StructType,
    +      expectedSchema: String): Unit = {
    +    test(s"Clipping - $testName") {
    +      val expected = MessageTypeParser.parseMessageType(expectedSchema)
    +      val actual = CatalystReadSupport.clipParquetSchema(
    +        MessageTypeParser.parseMessageType(parquetSchema), catalystSchema)
    +
    +      try {
    +        expected.checkContains(actual)
    +        actual.checkContains(expected)
    +      } catch { case cause: Throwable =>
    +        fail(
    +          s"""Expected clipped schema:
    +             |$expected
    +             |Actual clipped schema:
    +             |$actual
    +           """.stripMargin,
    +          cause)
    +      }
    +    }
    +  }
    +
    +  testSchemaClipping(
    +    "simple nested struct",
    +
    +    parquetSchema =
    +      """message root {
    +        |  required group f0 {
    +        |    optional int32 f00;
    +        |    optional int32 f01;
    +        |  }
    +        |}
    +      """.stripMargin,
    +
    +    catalystSchema = {
    +      val f0Type = new StructType().add("f00", IntegerType, nullable = 
true)
    +      new StructType()
    +        .add("f0", f0Type, nullable = false)
    +        .add("f1", IntegerType, nullable = true)
    +    },
    +
    +    expectedSchema =
    +      """message root {
    +        |  required group f0 {
    +        |    optional int32 f00;
    +        |  }
    +        |  optional int32 f1;
    +        |}
    +      """.stripMargin)
    +
    +  testSchemaClipping(
    +    "parquet-protobuf style array",
    +
    +    parquetSchema =
    +      """message root {
    +        |  required group f0 {
    +        |    repeated binary f00 (UTF8);
    +        |    repeated group f01 {
    +        |      optional int32 f010;
    +        |      optional double f011;
    +        |    }
    +        |  }
    +        |}
    +      """.stripMargin,
    +
    +    catalystSchema = {
    +      val f11Type = new StructType().add("f011", DoubleType, nullable = 
true)
    --- End diff --
    
    f01 should be ArrayType(StructType())


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to