You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by marmbrus <gi...@git.apache.org> on 2016/03/15 03:45:08 UTC

[GitHub] spark pull request: [WIP][SPARK-13883][SQL] Parquet Implementation...

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

    https://github.com/apache/spark/pull/11709#discussion_r56108571
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetRelation.scala ---
    @@ -268,6 +273,127 @@ private[sql] class DefaultSource extends FileFormat with DataSourceRegister with
             file.getName == ParquetFileWriter.PARQUET_METADATA_FILE
       }
     
    +  /**
    +   * Returns a function that can be used to read a single file in as an Iterator of InternalRow.
    +   *
    +   * @param partitionSchema The schema of the partition column row that will be present in each
    +   *                        PartitionedFile.  These columns should be prepended to the rows that
    +   *                        are produced by the iterator.
    +   * @param dataSchema The schema of the data that should be output for each row.  This may be a
    +   *                   subset of the columns that are present in the file if  column pruning has
    +   *                   occurred.
    +   * @param filters A set of filters than can optionally be used to reduce the number of rows output
    +   * @param options A set of string -> string configuration options.
    +   * @return
    +   */
    +  override def buildReader(
    +      sqlContext: SQLContext,
    +      partitionSchema: StructType,
    +      dataSchema: StructType,
    +      filters: Seq[Filter],
    +      options: Map[String, String]): PartitionedFile => Iterator[InternalRow] = {
    +    val parquetConf = new Configuration(sqlContext.sparkContext.hadoopConfiguration)
    +    parquetConf.set(ParquetInputFormat.READ_SUPPORT_CLASS, classOf[CatalystReadSupport].getName)
    +    parquetConf.set(
    +      CatalystReadSupport.SPARK_ROW_REQUESTED_SCHEMA,
    +      CatalystSchemaConverter.checkFieldNames(dataSchema).json)
    +    parquetConf.set(
    +      CatalystWriteSupport.SPARK_ROW_SCHEMA,
    +      CatalystSchemaConverter.checkFieldNames(dataSchema).json)
    +
    +    // We want to clear this temporary metadata from saving into Parquet file.
    +    // This metadata is only useful for detecting optional columns when pushdowning filters.
    +    val dataSchemaToWrite = StructType.removeMetadata(StructType.metadataKeyForOptionalField,
    +      dataSchema).asInstanceOf[StructType]
    +    CatalystWriteSupport.setSchema(dataSchemaToWrite, parquetConf)
    +
    +    // Sets flags for `CatalystSchemaConverter`
    +    parquetConf.setBoolean(
    +      SQLConf.PARQUET_BINARY_AS_STRING.key,
    +      sqlContext.conf.getConf(SQLConf.PARQUET_BINARY_AS_STRING))
    +    parquetConf.setBoolean(
    +      SQLConf.PARQUET_INT96_AS_TIMESTAMP.key,
    +      sqlContext.conf.getConf(SQLConf.PARQUET_INT96_AS_TIMESTAMP))
    +
    +    // Try to push down filters when filter push-down is enabled.
    +    if (sqlContext.getConf(SQLConf.PARQUET_FILTER_PUSHDOWN_ENABLED.key).toBoolean) {
    --- End diff --
    
    @liancheng any idea why this isn't working?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org