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

    https://github.com/apache/spark/pull/13280#discussion_r64946259
  
    --- Diff: 
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/SpecificParquetRecordReaderBase.java
 ---
    @@ -194,7 +196,24 @@ protected void initialize(String path, List<String> 
columns) throws IOException
             }
             builder.addFields(fileSchema.getType(s));
           }
    -      this.requestedSchema = builder.named("spark_schema");
    +      if (columns.size() > 0) {
    +        this.requestedSchema = builder.named("spark_schema");
    +      } else {
    +        // !! HACK ALERT !!
    +        //
    +        // PARQUET-363 & PARQUET-278: parquet-mr 1.8.1 doesn't allow 
constructing empty GroupType,
    +        // which prevents us to avoid selecting any columns for queries 
like
    +        // `SELECT COUNT(*) FROM t`.
    +        // This issue has been fixed in parquet-mr 1.8.2-SNAPSHOT.
    +        //
    +        // To workaround this problem, here we first construct a 
`MessageType` with a single dummy
    +        // field, and then remove the field to obtain an empty 
`MessageType`.
    +        //
    +        // TODO Reverts this change after upgrading parquet-mr to 1.8.2+
    +        
builder.addField(Types.required(PrimitiveType.PrimitiveTypeName.INT32).named("dummy"));
    +        this.requestedSchema = builder.named("spark_schema");
    --- End diff --
    
    Please replace `"spark_schema"` with 
`CatalystSchemaConverter.SPARK_PARQUET_SCHEMA_NAME`.


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