Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/13280#discussion_r64947036
--- 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 --
Just a double check, so the following two are equivalent, right? I wasn't
aware of the first approach (which is a little bit confusing since there are
two consecutive `named` calls).
```scala
// (1)
Types
.buildMessage()
.required(PrimitiveType.PrimitiveTypeName.INT32).named("dummy")
.named("root")
// (2)
Types
.buildMessage()
.addField(
Types.required(PrimitiveType.PrimitiveTypeName.INT32).named("dummy")
)
.named("root")
```
---
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]