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

    https://github.com/apache/spark/pull/20933#discussion_r181529318
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/orc/OrcDataSourceV2.scala
 ---
    @@ -0,0 +1,194 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.spark.sql.execution.datasources.v2.orc
    +
    +import java.net.URI
    +import java.util.Locale
    +
    +import org.apache.hadoop.conf.Configuration
    +import org.apache.hadoop.fs.{FileStatus, Path}
    +import org.apache.hadoop.mapreduce.{JobID, TaskAttemptID, TaskID, TaskType}
    +import org.apache.hadoop.mapreduce.lib.input.FileSplit
    +import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl
    +import org.apache.orc.{OrcConf, OrcFile}
    +import org.apache.orc.mapred.OrcStruct
    +import org.apache.orc.mapreduce.OrcInputFormat
    +
    +import org.apache.spark.TaskContext
    +import org.apache.spark.sql.SparkSession
    +import org.apache.spark.sql.catalyst.InternalRow
    +import org.apache.spark.sql.catalyst.expressions.{Expression, JoinedRow}
    +import 
org.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjection
    +import org.apache.spark.sql.execution.datasources._
    +import 
org.apache.spark.sql.execution.datasources.orc.{OrcColumnarBatchReader, 
OrcDeserializer, OrcFilters, OrcUtils}
    +import 
org.apache.spark.sql.execution.datasources.v2.ColumnarBatchFileSourceReader
    +import org.apache.spark.sql.internal.SQLConf
    +import org.apache.spark.sql.sources.v2.{DataSourceOptions, DataSourceV2, 
ReadSupport, ReadSupportWithSchema}
    +import org.apache.spark.sql.sources.v2.reader._
    +import org.apache.spark.sql.types.{AtomicType, StructType}
    +import org.apache.spark.util.SerializableConfiguration
    +
    +class OrcDataSourceV2 extends DataSourceV2 with ReadSupport with 
ReadSupportWithSchema {
    +  override def createReader(options: DataSourceOptions): DataSourceReader 
= {
    +    new OrcDataSourceReader(options, None)
    +  }
    +
    +  override def createReader(schema: StructType, options: 
DataSourceOptions): DataSourceReader = {
    +    new OrcDataSourceReader(options, Some(schema))
    +  }
    +}
    +
    +case class OrcDataSourceReader(options: DataSourceOptions, 
userSpecifiedSchema: Option[StructType])
    +  extends ColumnarBatchFileSourceReader
    +  with SupportsPushDownCatalystFilters {
    +
    +  override def inferSchema(files: Seq[FileStatus]): Option[StructType] = {
    +    OrcUtils.readSchema(sparkSession, files)
    +  }
    +
    +  private var pushedFiltersArray: Array[Expression] = Array.empty
    +
    +  override def readFunction: PartitionedFile => Iterator[InternalRow] = {
    --- End diff --
    
    btw i think it's also ok if we know what we want in the final version, and 
the intermediate change tries to minimize code changes (i haven't looked at the 
pr at all so don't interpret this comment as endorsing or not endorsing the pr 
design)


---

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

Reply via email to