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

    https://github.com/apache/spark/pull/13280#discussion_r64945499
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetSchemaSuite.scala
 ---
    @@ -1415,6 +1425,18 @@ class ParquetSchemaSuite extends ParquetSchemaTest {
             |}
           """.stripMargin)
     
    +  // !! HACK ALERT !!
    +  //
    +  // PARQUET-363 and PARQUET-278: Parquet 1.8.1 doesn't allow constructing 
empty groups, but does
    +  // support empty groups as valid projections, for cases like select 
count(*). This work-around
    +  // constructs a group with a dummy column and then removes it.
    +  //
    +  // This is fixed in Parquet so this hack should be removed when Parquet 
is updated.
    +  val emptySchema: MessageType = Types.buildMessage()
    +      .required(PrimitiveType.PrimitiveTypeName.INT32).named("dummy")
    +      .named("root")
    +  emptySchema.getFields.clear(); // remove the dummy column
    --- End diff --
    
    Maybe move `emptySchema` into `object CatalystReadSupport` as a method? Now 
the same "HACK ALERT" appears 3 times in total:
    
    ```scala
        def emptyMessageType(name: String): MessageType = {
          // (Add the HACK ALERT here.)
          val messageType = Types.buildMessage()
            .required(PrimitiveType.PrimitiveTypeName.INT32).named("dummy")
            .named(name)
          messageType.getFields.clear()
          messageType
        }
    ```
    
    Also, let's make sure the hack alert message mentions the specific 
parquet-mr version (1.8.2-SNAPSHOT) that fixes PARQUET-363. So that people 
clearly know when can we remove this hack.


---
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