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

    https://github.com/apache/spark/pull/11646#discussion_r56108277
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategy.scala
 ---
    @@ -0,0 +1,202 @@
    +/*
    + * 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
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import org.apache.hadoop.fs.Path
    +
    +import org.apache.spark.Logging
    +import org.apache.spark.sql._
    +import org.apache.spark.sql.catalyst.expressions
    +import org.apache.spark.sql.catalyst.expressions._
    +import org.apache.spark.sql.catalyst.planning.PhysicalOperation
    +import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
    +import org.apache.spark.sql.execution.{DataSourceScan, SparkPlan}
    +import org.apache.spark.sql.sources._
    +import org.apache.spark.sql.types._
    +
    +/**
    + * A strategy for planning scans over collections of files that might be 
partitioned or bucketed
    + * by user specified columns.
    + *
    + * At a high level planning occurs in several phases:
    + *  - Split filters by when they need to be evaluated.
    + *  - Prune the schema of the data requested based on any projections 
present. Today this pruning
    + *    is only done on top level columns, but formats should support 
pruning of nested columns as
    + *    well.
    + *  - Construct a reader function by passing filters and the schema into 
the FileFormat.
    + *  - Using an partition pruning predicates, enumerate the list of files 
that should be read.
    + *  - Split the files into tasks and construct a FileScanRDD.
    + *  - Add any projection or filters that must be evaluated after the scan.
    + *
    + * Files are assigned into tasks using the following algorithm:
    + *  - If the table is bucketed, group files by bucket id into the correct 
number of partitions.
    + *  - If the table is not bucketed or bucketing is turned off:
    + *   - If any file is larger than the threshold, split it into pieces 
based on that threshold
    + *   - Sort the files by decreasing file size.
    + *   - Assign the ordered files to buckets using the following algorithm.  
If the current partition
    + *     is under the threshold with the addition of the next file, add it.  
If not, open a new bucket
    + *     and add it.  Proceed to the next file.
    + */
    +private[sql] object FileSourceStrategy extends Strategy with Logging {
    +  def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
    +    case PhysicalOperation(projects, filters, l@LogicalRelation(files: 
HadoopFsRelation, _, _))
    +      if files.fileFormat.toString == "TestFileFormat" =>
    --- End diff --
    
    Currently only the test format, but in a follow up PR we'll add Parquet and 
eventually remove this check and the old code path.


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