You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by maropu <gi...@git.apache.org> on 2018/06/28 07:50:08 UTC

[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

GitHub user maropu opened a pull request:

    https://github.com/apache/spark/pull/21657

    [SPARK-24676][SQL] Project required data from CSV parsed data when column pruning disabled

    ## What changes were proposed in this pull request?
    This pr modified code to project required data from CSV parsed data when column pruning disabled.
    In the current master, an exception below happens if `spark.sql.csv.parser.columnPruning.enabled` is false. This is because required formats and CSV parsed formats are different from each other;
    ```
    ./bin/spark-shell --conf spark.sql.csv.parser.columnPruning.enabled=false
    scala> val dir = "/tmp/spark-csv/csv"
    scala> spark.range(10).selectExpr("id % 2 AS p", "id").write.mode("overwrite").partitionBy("p").csv(dir)
    scala> spark.read.csv(dir).selectExpr("sum(p)").collect()
    18/06/25 13:48:46 ERROR Executor: Exception in task 2.0 in stage 2.0 (TID 7)
    java.lang.ClassCastException: org.apache.spark.unsafe.types.UTF8String cannot be cast to java.lang.Integer
            at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:101)
            at org.apache.spark.sql.catalyst.expressions.BaseGenericInternalRow$class.getInt(rows.scala:41)
            ...
    ```
    
    ## How was this patch tested?
    Added tests in `CSVSuite`.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/maropu/spark SPARK-24676

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/21657.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #21657
    
----
commit ecd3c80d9ded538c5c07f65b4f5aa1a4fbf2677b
Author: Takeshi Yamamuro <ya...@...>
Date:   2018-06-25T06:17:58Z

    Fix

----


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @HyukjinKwon @gatorsmile Would you mind to merge the PR?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #93010 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93010/testReport)** for PR 21657 at commit [`dd5bb59`](https://github.com/apache/spark/commit/dd5bb595fe282035e0cf8996cfea15724fe0f674).


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92703 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92703/testReport)** for PR 21657 at commit [`d5921f0`](https://github.com/apache/spark/commit/d5921f08d8efa00f64f01d005e843291568c1e80).
     * This patch **fails due to an unknown error code, -9**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/956/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r199033421
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVFileFormat.scala ---
    @@ -131,20 +132,30 @@ class CSVFileFormat extends TextBasedFileFormat with DataSourceRegister {
           )
         }
         val caseSensitive = sparkSession.sessionState.conf.caseSensitiveAnalysis
    +    val columnPruning = sparkSession.sessionState.conf.csvColumnPruning
     
         (file: PartitionedFile) => {
           val conf = broadcastedHadoopConf.value.value
           val parser = new UnivocityParser(
             StructType(dataSchema.filterNot(_.name == parsedOptions.columnNameOfCorruptRecord)),
             StructType(requiredSchema.filterNot(_.name == parsedOptions.columnNameOfCorruptRecord)),
             parsedOptions)
    -      CSVDataSource(parsedOptions).readFile(
    +      val inputRows = CSVDataSource(parsedOptions).readFile(
             conf,
             file,
             parser,
             requiredSchema,
             dataSchema,
             caseSensitive)
    +
    +      if (columnPruning) {
    +        inputRows
    +      } else {
    +        val inputAttrs = dataSchema.toAttributes
    --- End diff --
    
      IIUC, before the column pruning pr, `UnivocityParser` always required columns only. So, we don't need to project them in `CSVFileFormat`. cc: @HyukjinKwon  
    https://github.com/apache/spark/blob/e3de6ab30d52890eb08578e55eb4a5d2b4e7aa35/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala#L50


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92445 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92445/testReport)** for PR 21657 at commit [`4f192a9`](https://github.com/apache/spark/commit/4f192a9972c7f011a4c3844a5a788b566241c26c).


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @MaxGekk Do you mean we remove the option for column pruning?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @HyukjinKwon @MaxGekk 


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200291945
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    --- End diff --
    
    Could you convert it to `Array` explicitly. I have checked type of `tokenIndexArr`, it is actually `scala.collection.immutable.$colon$colon` - lazy list.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/745/
    Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r201187928
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
    --- End diff --
    
    ok


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92706 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92706/testReport)** for PR 21657 at commit [`d5921f0`](https://github.com/apache/spark/commit/d5921f08d8efa00f64f01d005e843291568c1e80).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r198863991
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVFileFormat.scala ---
    @@ -131,20 +132,30 @@ class CSVFileFormat extends TextBasedFileFormat with DataSourceRegister {
           )
         }
         val caseSensitive = sparkSession.sessionState.conf.caseSensitiveAnalysis
    +    val columnPruning = sparkSession.sessionState.conf.csvColumnPruning
     
         (file: PartitionedFile) => {
           val conf = broadcastedHadoopConf.value.value
           val parser = new UnivocityParser(
             StructType(dataSchema.filterNot(_.name == parsedOptions.columnNameOfCorruptRecord)),
             StructType(requiredSchema.filterNot(_.name == parsedOptions.columnNameOfCorruptRecord)),
             parsedOptions)
    -      CSVDataSource(parsedOptions).readFile(
    +      val inputRows = CSVDataSource(parsedOptions).readFile(
             conf,
             file,
             parser,
             requiredSchema,
             dataSchema,
             caseSensitive)
    +
    +      if (columnPruning) {
    +        inputRows
    +      } else {
    +        val inputAttrs = dataSchema.toAttributes
    --- End diff --
    
    It seems the bug is not related to the column pruning feature, and most likely it presented in previous versions. Should it be ported to the 2.3 branch?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92445 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92445/testReport)** for PR 21657 at commit [`4f192a9`](https://github.com/apache/spark/commit/4f192a9972c7f011a4c3844a5a788b566241c26c).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/961/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/690/
    Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r198865492
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    +          .option("header", "true").csv(dir)
    --- End diff --
    
    "true" -> true ?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93010/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    ok to test


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92629/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r201172532
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
    --- End diff --
    
    Nit: generally, we should consider adding the schema into the message. 


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92704/
    Test FAILed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202528267
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,29 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    s"requiredSchema (${requiredSchema.catalogString}) should be the subset of " +
    +      s"dataSchema (${dataSchema.catalogString}).")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    +    requiredSchema.map(f => java.lang.Integer.valueOf(dataSchema.indexOf(f))).toArray
    +
       val tokenizer = {
         val parserSetting = options.asParserSettings
         if (options.columnPruning && requiredSchema.length < dataSchema.length) {
    -      val tokenIndexArr = requiredSchema.map(f => java.lang.Integer.valueOf(dataSchema.indexOf(f)))
           parserSetting.selectIndexes(tokenIndexArr: _*)
         }
         new CsvParser(parserSetting)
       }
    -  private val schema = if (options.columnPruning) requiredSchema else dataSchema
     
    -  private val row = new GenericInternalRow(schema.length)
    +  private val parsedSchema = if (options.columnPruning) requiredSchema else dataSchema
    --- End diff --
    
    Add a comment like
    
    > // When column pruning is enabled, the parser only parses the required columns based on their positions in the data schema. 


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r201540833
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    +    requiredSchema.map(f => java.lang.Integer.valueOf(dataSchema.indexOf(f))).toArray
    --- End diff --
    
    This variable is used in both cases: line 56 ( `options.columnPruning=true`) and line 208 (`options.columnPruning=false`).


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #93015 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93015/testReport)** for PR 21657 at commit [`81b3971`](https://github.com/apache/spark/commit/81b397140486fab7f7c2f7dcb15d5a9a62c99845).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200614027
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    --- End diff --
    
    ah, I see. I'll recheck. Thanks!


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @HyukjinKwon WDYT?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92834/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/832/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92706/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    > Do you mean we remove the option for column pruning in csv?
    
    I mean reverting back the index mapping - `tokenIndexArr`. In this case, your changes in `buildReader` are not needed.
    
    If `spark.sql.csv.parser.columnPruning.enabled`is set to `false`, the `tokenIndexArr` will map data index to required index. In the default case (`spark.sql.csv.parser.columnPruning.enabled` is `true`), the array is actually not needed, and it can be replaced by the identity function. 


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202527982
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,20 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    +          .option("header", "true").csv(dir)
    +        var df = spark.read.option("header", true).csv(dir).selectExpr("sum(p)", "count(c0)")
    --- End diff --
    
    Normally, we do not use `var` for DataFrame even in test cases


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r199034387
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    --- End diff --
    
    Sure, I added the test: https://github.com/apache/spark/pull/21657/files#diff-219ac8201e443435499123f96e94d29fR1592


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200197250
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -82,7 +83,12 @@ class UnivocityParser(
       //
       //   output row - ["A", 2]
       private val valueConverters: Array[ValueConverter] = {
    -    schema.map(f => makeConverter(f.name, f.dataType, f.nullable, options)).toArray
    +    requiredSchema.map(f => makeConverter(f.name, f.dataType, f.nullable, options)).toArray
    +  }
    +
    +  // If `columnPruning` disabled, this index is used to reorder parsed tokens
    +  private lazy val tokenIndexArr: Array[Int] = {
    +    requiredSchema.map(f => dataSchema.indexOf(f)).toArray
    --- End diff --
    
    I would apply this small optimization: `java.lang.Integer.valueOf(dataSchema.indexOf(f))`


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92418 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92418/testReport)** for PR 21657 at commit [`ecd3c80`](https://github.com/apache/spark/commit/ecd3c80d9ded538c5c07f65b4f5aa1a4fbf2677b).


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202528391
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -197,15 +202,21 @@ class UnivocityParser(
        */
       def parse(input: String): InternalRow = doParse(input)
     
    +  private val getToken = if (options.columnPruning) {
    +    (tokens: Array[String], index: Int) => tokens(index)
    +  } else {
    +    (tokens: Array[String], index: Int) => tokens(tokenIndexArr(index))
    +  }
    +
       private def convert(tokens: Array[String]): InternalRow = {
    -    if (tokens.length != schema.length) {
    +    if (tokens.length != parsedSchema.length) {
    --- End diff --
    
    If possible, could you add a test case that satisfy `tokens.length != parsedSchema.length`


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Please let me do one pass within few days.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92704 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92704/testReport)** for PR 21657 at commit [`d5921f0`](https://github.com/apache/spark/commit/d5921f08d8efa00f64f01d005e843291568c1e80).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    cc: @HyukjinKwon 


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r199033486
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    +          .option("header", "true").csv(dir)
    +        val df = spark.read.option("header", "true").csv(dir).selectExpr("sum(p)", "avg(c0)")
    +        checkAnswer(df, Row(5, 4.5))
    --- End diff --
    
    ok


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r198865322
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    +          .option("header", "true").csv(dir)
    +        val df = spark.read.option("header", "true").csv(dir).selectExpr("sum(p)", "avg(c0)")
    --- End diff --
    
    The string exprs and `selectExpr` can be replaced by `.select(sum('p), avg('c0))`


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92703/
    Test FAILed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #93010 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93010/testReport)** for PR 21657 at commit [`dd5bb59`](https://github.com/apache/spark/commit/dd5bb595fe282035e0cf8996cfea15724fe0f674).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92590/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92418 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92418/testReport)** for PR 21657 at commit [`ecd3c80`](https://github.com/apache/spark/commit/ecd3c80d9ded538c5c07f65b4f5aa1a4fbf2677b).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/542/
    Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200210059
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -82,7 +83,12 @@ class UnivocityParser(
       //
       //   output row - ["A", 2]
       private val valueConverters: Array[ValueConverter] = {
    -    schema.map(f => makeConverter(f.name, f.dataType, f.nullable, options)).toArray
    +    requiredSchema.map(f => makeConverter(f.name, f.dataType, f.nullable, options)).toArray
    +  }
    +
    +  // If `columnPruning` disabled, this index is used to reorder parsed tokens
    +  private lazy val tokenIndexArr: Array[Int] = {
    --- End diff --
    
    ok


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200209800
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -197,15 +203,21 @@ class UnivocityParser(
        */
       def parse(input: String): InternalRow = doParse(input)
     
    +  private val getToken = if (options.columnPruning) {
    +    (tokens: Array[String], index: Int) => tokens(index)
    +  } else {
    +    (tokens: Array[String], index: Int) => tokens(tokenIndexArr(index))
    --- End diff --
    
    If `options.columnPruning` disabled (by default), `tokenIndexArr` is not totally used in most cases. If so, it'd be better to drop `lazy`?


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202528247
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,29 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    s"requiredSchema (${requiredSchema.catalogString}) should be the subset of " +
    +      s"dataSchema (${dataSchema.catalogString}).")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    +    requiredSchema.map(f => java.lang.Integer.valueOf(dataSchema.indexOf(f))).toArray
    +
       val tokenizer = {
         val parserSetting = options.asParserSettings
         if (options.columnPruning && requiredSchema.length < dataSchema.length) {
    --- End diff --
    
    Can be simplified to
    > // When to-be-parsed schema is shorter than the to-be-read data schema, we let Univocity CSV parser select a sequence of fields for reading by their positions.
    > `if (parsedSchema.length < dataSchema.length)`


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Actually the issue happened because I removed the mapping: https://github.com/apache/spark/commit/64fad0b519cf35b8c0a0dec18dd3df9488a5ed25#diff-d19881aceddcaa5c60620fdcda99b4c4L79
    
    I would propose to revert it back, and remove all those "expensive" (comparing to look up `tokenIndexArr`) `map`s and the projection: https://github.com/apache/spark/pull/21657/files#diff-a549ac2e19ee7486911e2e6403444d9dR156


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/747/
    Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200560873
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    --- End diff --
    
    Any side-effect?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #93015 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/93015/testReport)** for PR 21657 at commit [`81b3971`](https://github.com/apache/spark/commit/81b397140486fab7f7c2f7dcb15d5a9a62c99845).


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92706 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92706/testReport)** for PR 21657 at commit [`d5921f0`](https://github.com/apache/spark/commit/d5921f08d8efa00f64f01d005e843291568c1e80).


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200197165
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -82,7 +83,12 @@ class UnivocityParser(
       //
       //   output row - ["A", 2]
       private val valueConverters: Array[ValueConverter] = {
    -    schema.map(f => makeConverter(f.name, f.dataType, f.nullable, options)).toArray
    +    requiredSchema.map(f => makeConverter(f.name, f.dataType, f.nullable, options)).toArray
    +  }
    +
    +  // If `columnPruning` disabled, this index is used to reorder parsed tokens
    +  private lazy val tokenIndexArr: Array[Int] = {
    --- End diff --
    
    It seems the code here and in the line https://github.com/apache/spark/pull/21657/files#diff-d19881aceddcaa5c60620fdcda99b4c4R51 above is the same. Could you fold the lines.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r199033773
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVFileFormat.scala ---
    @@ -131,20 +132,30 @@ class CSVFileFormat extends TextBasedFileFormat with DataSourceRegister {
           )
         }
         val caseSensitive = sparkSession.sessionState.conf.caseSensitiveAnalysis
    +    val columnPruning = sparkSession.sessionState.conf.csvColumnPruning
     
         (file: PartitionedFile) => {
           val conf = broadcastedHadoopConf.value.value
           val parser = new UnivocityParser(
             StructType(dataSchema.filterNot(_.name == parsedOptions.columnNameOfCorruptRecord)),
             StructType(requiredSchema.filterNot(_.name == parsedOptions.columnNameOfCorruptRecord)),
             parsedOptions)
    -      CSVDataSource(parsedOptions).readFile(
    +      val inputRows = CSVDataSource(parsedOptions).readFile(
             conf,
             file,
             parser,
             requiredSchema,
             dataSchema,
             caseSensitive)
    +
    +      if (columnPruning) {
    +        inputRows
    +      } else {
    +        val inputAttrs = dataSchema.toAttributes
    --- End diff --
    
    I think we better just merge this into the master since we already added some changes related with column pruning stuff. Let me double check it before merging it in.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Eh .. actually can we revive https://github.com/apache/spark/commit/64fad0b519cf35b8c0a0dec18dd3df9488a5ed25#diff-d19881aceddcaa5c60620fdcda99b4c4L79 ? This sounds safer to me.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/93015/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Not sure though,  the `tokenIndexArr` implementation is always faster than the unsafe projection?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92704 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92704/testReport)** for PR 21657 at commit [`d5921f0`](https://github.com/apache/spark/commit/d5921f08d8efa00f64f01d005e843291568c1e80).


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200210431
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -82,7 +83,12 @@ class UnivocityParser(
       //
       //   output row - ["A", 2]
       private val valueConverters: Array[ValueConverter] = {
    -    schema.map(f => makeConverter(f.name, f.dataType, f.nullable, options)).toArray
    +    requiredSchema.map(f => makeConverter(f.name, f.dataType, f.nullable, options)).toArray
    +  }
    +
    +  // If `columnPruning` disabled, this index is used to reorder parsed tokens
    +  private lazy val tokenIndexArr: Array[Int] = {
    +    requiredSchema.map(f => dataSchema.indexOf(f)).toArray
    --- End diff --
    
    ok


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92834 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92834/testReport)** for PR 21657 at commit [`dd5bb59`](https://github.com/apache/spark/commit/dd5bb595fe282035e0cf8996cfea15724fe0f674).


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r201042748
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    +    requiredSchema.map(f => java.lang.Integer.valueOf(dataSchema.indexOf(f))).toArray
    --- End diff --
    
    Just in case, we can do an optimization by memory here. The array is used under the flag `options.columnPruning` only. We can create an empty array (or null) if `options.columnPruning` is set to `false`.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202528931
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -223,8 +234,8 @@ class UnivocityParser(
         } else {
           try {
             var i = 0
    -        while (i < schema.length) {
    -          row(i) = valueConverters(i).apply(tokens(i))
    +        while (i < requiredSchema.length) {
    --- End diff --
    
    ok


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @MaxGekk, does this look good to you?


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200210434
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -197,15 +203,21 @@ class UnivocityParser(
        */
       def parse(input: String): InternalRow = doParse(input)
     
    +  private val getToken = if (options.columnPruning) {
    +    (tokens: Array[String], index: Int) => tokens(index)
    +  } else {
    +    (tokens: Array[String], index: Int) => tokens(tokenIndexArr(index))
    --- End diff --
    
    ok


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200204856
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -197,15 +203,21 @@ class UnivocityParser(
        */
       def parse(input: String): InternalRow = doParse(input)
     
    +  private val getToken = if (options.columnPruning) {
    +    (tokens: Array[String], index: Int) => tokens(index)
    +  } else {
    +    (tokens: Array[String], index: Int) => tokens(tokenIndexArr(index))
    --- End diff --
    
    The `lazy` for `tokenIndexArr` means that internal laziness flag will be check per each token. I would remove `lazy` for `tokenIndexArr`


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    retest this please


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r198865725
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    --- End diff --
    
    Just in case, if required schema is empty, the fix works too?


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r199033429
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    +          .option("header", "true").csv(dir)
    +        val df = spark.read.option("header", "true").csv(dir).selectExpr("sum(p)", "avg(c0)")
    --- End diff --
    
    I think both are fine~


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202528977
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -197,15 +202,21 @@ class UnivocityParser(
        */
       def parse(input: String): InternalRow = doParse(input)
     
    +  private val getToken = if (options.columnPruning) {
    +    (tokens: Array[String], index: Int) => tokens(index)
    +  } else {
    +    (tokens: Array[String], index: Int) => tokens(tokenIndexArr(index))
    +  }
    +
       private def convert(tokens: Array[String]): InternalRow = {
    -    if (tokens.length != schema.length) {
    +    if (tokens.length != parsedSchema.length) {
    --- End diff --
    
    will do


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200802851
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    --- End diff --
    
    ok, fixed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92703 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92703/testReport)** for PR 21657 at commit [`d5921f0`](https://github.com/apache/spark/commit/d5921f08d8efa00f64f01d005e843291568c1e80).


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92590 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92590/testReport)** for PR 21657 at commit [`fc2108e`](https://github.com/apache/spark/commit/fc2108e52ee987d7ca3d4cce811ad9fc4e462c47).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92629 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92629/testReport)** for PR 21657 at commit [`af620cb`](https://github.com/apache/spark/commit/af620cb40b3430b64ac7e303f89e92ed9c22c7b6).


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202528933
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,29 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    s"requiredSchema (${requiredSchema.catalogString}) should be the subset of " +
    +      s"dataSchema (${dataSchema.catalogString}).")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    +    requiredSchema.map(f => java.lang.Integer.valueOf(dataSchema.indexOf(f))).toArray
    +
       val tokenizer = {
         val parserSetting = options.asParserSettings
         if (options.columnPruning && requiredSchema.length < dataSchema.length) {
    -      val tokenIndexArr = requiredSchema.map(f => java.lang.Integer.valueOf(dataSchema.indexOf(f)))
           parserSetting.selectIndexes(tokenIndexArr: _*)
         }
         new CsvParser(parserSetting)
       }
    -  private val schema = if (options.columnPruning) requiredSchema else dataSchema
     
    -  private val row = new GenericInternalRow(schema.length)
    +  private val parsedSchema = if (options.columnPruning) requiredSchema else dataSchema
    --- End diff --
    
    ok


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92590 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92590/testReport)** for PR 21657 at commit [`fc2108e`](https://github.com/apache/spark/commit/fc2108e52ee987d7ca3d4cce811ad9fc4e462c47).


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @HyukjinKwon kindly ping


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r198863283
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    +          .option("header", "true").csv(dir)
    +        val df = spark.read.option("header", "true").csv(dir).selectExpr("sum(p)", "avg(c0)")
    +        checkAnswer(df, Row(5, 4.5))
    --- End diff --
    
    Can you use something else instead of `avg`? I would eliminate equality checking for floating point operands. You can easily get `4.49999999999` instead of `4.5`. 


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    ok, will revive the code here


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    retest this please


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    retest this please


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202527784
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,29 @@ class UnivocityParser(
         requiredSchema: StructType,
    --- End diff --
    
    Could you add the parameter descriptions of `dataSchema` and `requiredSchema` above class `UnivocityParser`?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @HyukjinKwon ping


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92418/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/92445/
    Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r200608015
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    --- End diff --
    
    You have O(n) instead of O(1) for getting a value from the collection by an index.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/744/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @HyukjinKwon @MaxGekk plz check?


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r199021518
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    +          .option("header", "true").csv(dir)
    --- End diff --
    
    ok


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by maropu <gi...@git.apache.org>.
Github user maropu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r199032884
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ---
    @@ -1579,4 +1579,16 @@ class CSVSuite extends QueryTest with SharedSQLContext with SQLTestUtils with Te
           }
         }
       }
    +
    +  test("SPARK-24676 project required data from parsed data when columnPruning disabled") {
    +    withSQLConf(SQLConf.CSV_PARSER_COLUMN_PRUNING.key -> "false") {
    +      withTempPath { path =>
    +        val dir = path.getAbsolutePath
    +        spark.range(10).selectExpr("id % 2 AS p", "id AS c0", "id AS c1").write.partitionBy("p")
    +          .option("header", "true").csv(dir)
    +        val df = spark.read.option("header", "true").csv(dir).selectExpr("sum(p)", "avg(c0)")
    --- End diff --
    
    I think both is ok. We have preferred one?


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test FAILed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92834 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92834/testReport)** for PR 21657 at commit [`dd5bb59`](https://github.com/apache/spark/commit/dd5bb595fe282035e0cf8996cfea15724fe0f674).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r202528372
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -223,8 +234,8 @@ class UnivocityParser(
         } else {
           try {
             var i = 0
    -        while (i < schema.length) {
    -          row(i) = valueConverters(i).apply(tokens(i))
    +        while (i < requiredSchema.length) {
    --- End diff --
    
    Add the comment like
    
    > // When the length of the returned tokens is identical to the length of the parsed schema, we just need to convert the tokens that correspond to the required columns.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/21657


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Merged build finished. Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Thanks! Merged to master


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/655/
    Test PASSed.


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    @HyukjinKwon yes


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    **[Test build #92629 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/92629/testReport)** for PR 21657 at commit [`af620cb`](https://github.com/apache/spark/commit/af620cb40b3430b64ac7e303f89e92ed9c22c7b6).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---

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


[GitHub] spark pull request #21657: [SPARK-24676][SQL] Project required data from CSV...

Posted by MaxGekk <gi...@git.apache.org>.
Github user MaxGekk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21657#discussion_r201582494
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/UnivocityParser.scala ---
    @@ -38,24 +38,28 @@ class UnivocityParser(
         requiredSchema: StructType,
         val options: CSVOptions) extends Logging {
       require(requiredSchema.toSet.subsetOf(dataSchema.toSet),
    -    "requiredSchema should be the subset of schema.")
    +    "requiredSchema should be the subset of dataSchema.")
     
       def this(schema: StructType, options: CSVOptions) = this(schema, schema, options)
     
       // A `ValueConverter` is responsible for converting the given value to a desired type.
       private type ValueConverter = String => Any
     
    +  // This index is used to reorder parsed tokens
    +  private val tokenIndexArr =
    +    requiredSchema.map(f => java.lang.Integer.valueOf(dataSchema.indexOf(f))).toArray
    --- End diff --
    
    ah, I see


---

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


[GitHub] spark issue #21657: [SPARK-24676][SQL] Project required data from CSV parsed...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/21657
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/testing-k8s-prb-make-spark-distribution-unified/559/
    Test PASSed.


---

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