You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/09/01 08:25:03 UTC

[GitHub] [spark] yaooqinn opened a new pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

yaooqinn opened a new pull request #33888:
URL: https://github.com/apache/spark/pull/33888


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   Add a config spark.sql.parquet.columnIndexAccess 
   
   When true, we access the parquet files by column index instead of catalyst schema mapping at the executor side. 
   
   This is useful when the parquet file meta is inconsistent with those in Metastore, e.g. creating a table with existing parquet files with column names renamed, the column names are changed by external systems.
   
   By default, it is off
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   better data accessibility 
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   NO
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   
   newly added test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912328348


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47465/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937375741






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704922547



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       What's worse, turning off column pruning also changes the result, which definitely violates the principle (query optimization should not change result)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r701638958



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetReadSupport.scala
##########
@@ -323,9 +327,20 @@ object ParquetReadSupport {
    * @return A list of clipped [[GroupType]] fields, which can be empty.
    */
   private def clipParquetGroupFields(
-      parquetRecord: GroupType, structType: StructType, caseSensitive: Boolean): Seq[Type] = {
+      parquetRecord: GroupType,
+      structType: StructType,
+      caseSensitive: Boolean,
+      columnIndexAccess: Boolean): Seq[Type] = {
     val toParquet = new SparkToParquetSchemaConverter(writeLegacyParquetFormat = false)
-    if (caseSensitive) {
+    if (columnIndexAccess) {
+      structType.zipWithIndex.map { case (f, i) =>
+        if (i >= parquetRecord.getFieldCount) {
+          toParquet.convertField(f)

Review comment:
       shouldn't we call `clipParquetType`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910060552


   **[Test build #142913 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142913/testReport)** for PR 33888 at commit [`6467608`](https://github.com/apache/spark/commit/6467608133700c39f9dbfb64b52751675bc83e91).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912612895


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142979/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910195556


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912462499


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47482/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912837879


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910196127


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142913/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912224992


   @yaooqinn can you put more details in the PR description? Something like
   1. What if the number of columns/inner fields does not match?
   2. What if the types are not compatible?
   3. What's the concrete use case that requires this feature?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937675744


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/143942/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937811840


   **[Test build #143996 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143996/testReport)** for PR 33888 at commit [`b989aa3`](https://github.com/apache/spark/commit/b989aa3821dbaf6cacccde886ed1051068d43cf5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937377914


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48414/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910253248


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47421/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912441395


   **[Test build #142981 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142981/testReport)** for PR 33888 at commit [`e744f0a`](https://github.com/apache/spark/commit/e744f0a81c0fbfb41922fc55d8ce478a37e10250).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912462142


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47480/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912276639


   retest this please


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912462142


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47480/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910224390


   **[Test build #142921 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142921/testReport)** for PR 33888 at commit [`3017e59`](https://github.com/apache/spark/commit/3017e59fee81ef7a3df9d656a0b34493577ff4e5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937632282


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48441/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937379696


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48411/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937673661


   **[Test build #143942 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143942/testReport)** for PR 33888 at commit [`b989aa3`](https://github.com/apache/spark/commit/b989aa3821dbaf6cacccde886ed1051068d43cf5).
    * This patch passes all tests.
    * This patch **does not merge cleanly**.
    * This patch adds no public classes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937377914


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48414/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704921288



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       I don't think that's how by-ordinal access should work. Let's say that the actual parquet schema is [a, b, c], and the catalyst schema is [x, y, z]. If a query reads column `y`, we should read column `b` from Parquet. It's very confusing to the users if `SELECT x`, `SELECT y` and `SELECT z` all return the same value, which is column `a` of the parquet file (assume all columns have the same type).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910196127


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142913/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910302008


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47421/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-911145513


   cc @cloud-fan @maropu 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r702049826



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetReadSupport.scala
##########
@@ -323,15 +344,27 @@ object ParquetReadSupport {
    * @return A list of clipped [[GroupType]] fields, which can be empty.
    */
   private def clipParquetGroupFields(
-      parquetRecord: GroupType, structType: StructType, caseSensitive: Boolean): Seq[Type] = {
+      parquetRecord: GroupType,
+      structType: StructType,
+      caseSensitive: Boolean,
+      accessByColumnOrdinal: Boolean): Seq[Type] = {
     val toParquet = new SparkToParquetSchemaConverter(writeLegacyParquetFormat = false)
-    if (caseSensitive) {
+    if (accessByColumnOrdinal) {
+      structType.zipWithIndex.map { case (f, i) =>
+        if (i < parquetRecord.getFieldCount) {
+          clipParquetType(
+            parquetRecord.getType(i), f.dataType, caseSensitive, accessByColumnOrdinal)
+        } else {
+          toParquet.convertField(f)
+        }
+      }
+    } else if (caseSensitive) {
       val caseSensitiveParquetFieldMap =
         parquetRecord.getFields.asScala.map(f => f.getName -> f).toMap
       structType.map { f =>
         caseSensitiveParquetFieldMap
           .get(f.name)
-          .map(clipParquetType(_, f.dataType, caseSensitive))
+          .map(clipParquetType(_, f.dataType, caseSensitive, accessByColumnOrdinal))

Review comment:
       both accessByColumnOrdinal or `false` are the same




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910382187


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142921/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912441395


   **[Test build #142981 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142981/testReport)** for PR 33888 at commit [`e744f0a`](https://github.com/apache/spark/commit/e744f0a81c0fbfb41922fc55d8ce478a37e10250).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912224525


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47452/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910060552


   **[Test build #142913 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142913/testReport)** for PR 33888 at commit [`6467608`](https://github.com/apache/spark/commit/6467608133700c39f9dbfb64b52751675bc83e91).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912203015


   **[Test build #142951 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142951/testReport)** for PR 33888 at commit [`062c537`](https://github.com/apache/spark/commit/062c5376f2b2483b5af52f956593a6729abef3ca).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704918391



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       in this test, the user and the parser side requests `b`, but at the execution side we follow `by-ordinal` rule to read the parquet file, so `a` is read actually. If `a` has the same data type, there will be side effects; otherwise, we fail like this test




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704916113



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       But the test here shows we can't, or did I miss something?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937675744


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/143942/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] sunchao commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
sunchao commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r702020262



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetReadSupport.scala
##########
@@ -323,15 +344,27 @@ object ParquetReadSupport {
    * @return A list of clipped [[GroupType]] fields, which can be empty.
    */
   private def clipParquetGroupFields(
-      parquetRecord: GroupType, structType: StructType, caseSensitive: Boolean): Seq[Type] = {
+      parquetRecord: GroupType,
+      structType: StructType,
+      caseSensitive: Boolean,
+      accessByColumnOrdinal: Boolean): Seq[Type] = {
     val toParquet = new SparkToParquetSchemaConverter(writeLegacyParquetFormat = false)
-    if (caseSensitive) {
+    if (accessByColumnOrdinal) {
+      structType.zipWithIndex.map { case (f, i) =>
+        if (i < parquetRecord.getFieldCount) {
+          clipParquetType(
+            parquetRecord.getType(i), f.dataType, caseSensitive, accessByColumnOrdinal)
+        } else {
+          toParquet.convertField(f)
+        }
+      }
+    } else if (caseSensitive) {
       val caseSensitiveParquetFieldMap =
         parquetRecord.getFields.asScala.map(f => f.getName -> f).toMap
       structType.map { f =>
         caseSensitiveParquetFieldMap
           .get(f.name)
-          .map(clipParquetType(_, f.dataType, caseSensitive))
+          .map(clipParquetType(_, f.dataType, caseSensitive, accessByColumnOrdinal))

Review comment:
       why do we need to pass down `accessByColumnOrdinal`? it is always false here right? also it seems we can't do this on nested columns?

##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetRowConverter.scala
##########
@@ -200,19 +200,28 @@ private[parquet] class ParquetRowConverter(
 
   // Converters for each field.
   private[this] val fieldConverters: Array[Converter with HasParentContainerUpdater] = {
-    // (SPARK-31116) Use case insensitive map if spark.sql.caseSensitive is false
-    // to prevent throwing IllegalArgumentException when searching catalyst type's field index
-    val catalystFieldNameToIndex = if (SQLConf.get.caseSensitiveAnalysis) {
-      catalystType.fieldNames.zipWithIndex.toMap
+    if (SQLConf.get.parquetAccessByIndex) {
+      // SPARK-36634: When access parquet file by the idx of columns, we can not ensure 2 types
+      // matched
+      parquetType.getFields.asScala.zip(catalystType).zipWithIndex.map {

Review comment:
       what if `len(parquetType.getFields != len(catalystType)`? I think it's not always guaranteed because of `ParquetReadSupport.intersectParquetGroups`? e.g., some fields in catalyst requested schema do not appear in Parquet file schema?

##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetRowConverter.scala
##########
@@ -139,7 +139,8 @@ private[parquet] class ParquetRowConverter(
     convertTz: Option[ZoneId],
     datetimeRebaseMode: LegacyBehaviorPolicy.Value,
     int96RebaseMode: LegacyBehaviorPolicy.Value,
-    updater: ParentContainerUpdater)
+    updater: ParentContainerUpdater,
+    parquetAccessByOrdinal: Boolean)

Review comment:
       nit: `parquetAccessByOrdinal` -> `accessByOrdinal`? parquet seems redundant in this context. Also please update the method comments with the new parameter.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912632866


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142981/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912319864


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142952/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912203937


   > should this be a per-query option (data source options) or a session config?
   
   It seems to be more ease-to-use in session conf


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912632866


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142981/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912238034


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47452/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r703341729



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       hmm, so this feature breaks column pruning. How useful is this feature then?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937377415


   Kubernetes integration test unable to build dist.
   
   exiting with code: 1
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48414/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937811840


   **[Test build #143996 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143996/testReport)** for PR 33888 at commit [`b989aa3`](https://github.com/apache/spark/commit/b989aa3821dbaf6cacccde886ed1051068d43cf5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-911740543


   should this be a per-query option (data source options) or a session config?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912459698


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142966/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912328348


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47465/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912727679


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47491/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704921836



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       Think about a user running `SELECT x, y` and `SELECT y`, he/she will see the column `y` has different values in each run, which is kind of a correctness bug.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912452999


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912205085


   **[Test build #142952 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142952/testReport)** for PR 33888 at commit [`3177993`](https://github.com/apache/spark/commit/3177993234d669bcd35e45196e94dd6b30912ac6).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704914960



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       we can read `a`, `ab`, or `abc` by ordinal.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704277499



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       Not 'all the columns' but the resolved project list zipped directly to the fields of parquet data files




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912462499


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47482/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937610617


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48441/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704569159



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       I'm a bit confused. Say if a parquet file has 3 columns `a, b, c`. By-ordinal access only works if a query needs to read all the columns (no column pruning). Do I miss something?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937632282


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48441/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] github-actions[bot] closed pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #33888:
URL: https://github.com/apache/spark/pull/33888


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912631178


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] sunchao commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
sunchao commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r702038063



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetRowConverter.scala
##########
@@ -200,19 +200,28 @@ private[parquet] class ParquetRowConverter(
 
   // Converters for each field.
   private[this] val fieldConverters: Array[Converter with HasParentContainerUpdater] = {
-    // (SPARK-31116) Use case insensitive map if spark.sql.caseSensitive is false
-    // to prevent throwing IllegalArgumentException when searching catalyst type's field index
-    val catalystFieldNameToIndex = if (SQLConf.get.caseSensitiveAnalysis) {
-      catalystType.fieldNames.zipWithIndex.toMap
+    if (SQLConf.get.parquetAccessByIndex) {
+      // SPARK-36634: When access parquet file by the idx of columns, we can not ensure 2 types
+      // matched
+      parquetType.getFields.asScala.zip(catalystType).zipWithIndex.map {

Review comment:
       what if `len(parquetType.getFields != len(catalystType)`? I think it's not always guaranteed because of `ParquetReadSupport.intersectParquetGroups`? e.g., some fields in catalyst requested schema do not appear in Parquet file schema.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912608489


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912430146


   **[Test build #142979 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142979/testReport)** for PR 33888 at commit [`b53481c`](https://github.com/apache/spark/commit/b53481cbcf911b9f0a15a5e09ad62a65f42690ad).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937377914






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912727631


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47491/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912287204


   **[Test build #142966 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142966/testReport)** for PR 33888 at commit [`3177993`](https://github.com/apache/spark/commit/3177993234d669bcd35e45196e94dd6b30912ac6).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912444059






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912241139


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47452/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912287204


   **[Test build #142966 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142966/testReport)** for PR 33888 at commit [`3177993`](https://github.com/apache/spark/commit/3177993234d669bcd35e45196e94dd6b30912ac6).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704109578



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       Right now by-ordinal access only works if the query selects all the columns. Maybe the column pruning should pass "required column ordinals" to the parquet reader




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937377914






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937379696


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48411/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910321821


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47421/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] github-actions[bot] commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-1013986253


   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910381329


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r703342039



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       shall we turn off column pruning when access-by-ordinal is enabled?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912318688


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r701773655



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetReadSupport.scala
##########
@@ -323,9 +327,20 @@ object ParquetReadSupport {
    * @return A list of clipped [[GroupType]] fields, which can be empty.
    */
   private def clipParquetGroupFields(
-      parquetRecord: GroupType, structType: StructType, caseSensitive: Boolean): Seq[Type] = {
+      parquetRecord: GroupType,
+      structType: StructType,
+      caseSensitive: Boolean,
+      columnIndexAccess: Boolean): Seq[Type] = {
     val toParquet = new SparkToParquetSchemaConverter(writeLegacyParquetFormat = false)
-    if (caseSensitive) {
+    if (columnIndexAccess) {
+      structType.zipWithIndex.map { case (f, i) =>
+        if (i >= parquetRecord.getFieldCount) {
+          toParquet.convertField(f)

Review comment:
       addressed, but shall be applied in `else` branch




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912239963


   > @yaooqinn can you put more details in the PR description? Something like
   > 
   > 1. What if the number of columns/inner fields does not match?
   > 2. What if the types are not compatible?
   > 3. What's the concrete use case that requires this feature?
   
   nice questions, updated accordingly


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704921836



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       Think about a user running `SELECT x, y` and `SELECT y`, he/she will see the column `y` has inconsistent values in each run, which is kind of a correctness bug.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r703998755



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       I guess they are not conflicting. We are using idx-0 to get data from `file 1(my_id)` and  `file 2(myid)` and feed it to my_name. Here the idx is not the final output set but the original input set of raw data




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937505098






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937960914


   **[Test build #143996 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143996/testReport)** for PR 33888 at commit [`b989aa3`](https://github.com/apache/spark/commit/b989aa3821dbaf6cacccde886ed1051068d43cf5).
    * This patch **fails Spark unit tests**.
    * This patch **does not merge cleanly**.
    * This patch adds no public classes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912205085


   **[Test build #142952 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142952/testReport)** for PR 33888 at commit [`3177993`](https://github.com/apache/spark/commit/3177993234d669bcd35e45196e94dd6b30912ac6).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937975445


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/143996/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] sunchao commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
sunchao commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r700366823



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
##########
@@ -903,6 +903,13 @@ object SQLConf {
     .intConf
     .createWithDefault(4096)
 
+  val PARQUET_COLUMN_INDEX_ACCESS = buildConf("spark.sql.parquet.columnIndexAccess")

Review comment:
       Column index is a special feature in Parquet and this may cause confusion. How about `spark.sql.parquet.accessByIndex`?

##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -4223,6 +4223,52 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
     checkAnswer(sql("""SELECT from_json(r'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
     checkAnswer(sql("""SELECT from_json(R'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>

Review comment:
       We should test with both `spark.sql.parquet.enableVectorizedReader` enabled or disabled. I think it currently doesn't work for the latter.

##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
##########
@@ -903,6 +903,13 @@ object SQLConf {
     .intConf
     .createWithDefault(4096)
 
+  val PARQUET_COLUMN_INDEX_ACCESS = buildConf("spark.sql.parquet.columnIndexAccess")
+    .doc("When true, we access the parquet files by column index instead of catalyst schema" +

Review comment:
       nit: parquet -> Parquet

##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -4223,6 +4223,52 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
     checkAnswer(sql("""SELECT from_json(r'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
     checkAnswer(sql("""SELECT from_json(R'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'kent'")
+        sql("insert into t2 select 2, 'yao'")
+        sql("insert into t2 select 3, 'kyuubi'")

Review comment:
       nit: I'd suggest to use more neutral words here :)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] pan3793 commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
pan3793 commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r700930659



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
##########
@@ -903,6 +903,13 @@ object SQLConf {
     .intConf
     .createWithDefault(4096)
 
+  val PARQUET_COLUMN_INDEX_ACCESS = buildConf("spark.sql.parquet.columnIndexAccess")

Review comment:
       How about using `ordinal` instead of `index`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r701640693



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -4223,6 +4223,55 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
     checkAnswer(sql("""SELECT from_json(r'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
     checkAnswer(sql("""SELECT from_json(R'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {

Review comment:
       can we move the test to `ParquetQuerySuite`? then we can use `withAllParquetReaders` to test all the parquet readers.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r700731428



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -4223,6 +4223,52 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
     checkAnswer(sql("""SELECT from_json(r'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
     checkAnswer(sql("""SELECT from_json(R'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>

Review comment:
       add support for the latter, thanks for pointing it out

##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -4223,6 +4223,52 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
     checkAnswer(sql("""SELECT from_json(r'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
     checkAnswer(sql("""SELECT from_json(R'{"a": "\\"}', 'a string')"""), Row(Row("\\")))
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'kent'")
+        sql("insert into t2 select 2, 'yao'")
+        sql("insert into t2 select 3, 'kyuubi'")

Review comment:
       addressed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910099484


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47415/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912839798


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142989/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912462098


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47480/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912319864


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142952/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937505098


   **[Test build #143942 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143942/testReport)** for PR 33888 at commit [`b989aa3`](https://github.com/apache/spark/commit/b989aa3821dbaf6cacccde886ed1051068d43cf5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937600737


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48441/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937379677


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48411/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r702050323



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetReadSupport.scala
##########
@@ -323,15 +344,27 @@ object ParquetReadSupport {
    * @return A list of clipped [[GroupType]] fields, which can be empty.
    */
   private def clipParquetGroupFields(
-      parquetRecord: GroupType, structType: StructType, caseSensitive: Boolean): Seq[Type] = {
+      parquetRecord: GroupType,
+      structType: StructType,
+      caseSensitive: Boolean,
+      accessByColumnOrdinal: Boolean): Seq[Type] = {
     val toParquet = new SparkToParquetSchemaConverter(writeLegacyParquetFormat = false)
-    if (caseSensitive) {
+    if (accessByColumnOrdinal) {
+      structType.zipWithIndex.map { case (f, i) =>
+        if (i < parquetRecord.getFieldCount) {
+          clipParquetType(
+            parquetRecord.getType(i), f.dataType, caseSensitive, accessByColumnOrdinal)
+        } else {
+          toParquet.convertField(f)
+        }
+      }
+    } else if (caseSensitive) {
       val caseSensitiveParquetFieldMap =
         parquetRecord.getFields.asScala.map(f => f.getName -> f).toMap
       structType.map { f =>
         caseSensitiveParquetFieldMap
           .get(f.name)
-          .map(clipParquetType(_, f.dataType, caseSensitive))
+          .map(clipParquetType(_, f.dataType, caseSensitive, accessByColumnOrdinal))

Review comment:
       we support nesting, as you can see from the newly added tests




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912612895


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142979/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910060552






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912839798


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142989/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912693505


   **[Test build #142989 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142989/testReport)** for PR 33888 at commit [`b989aa3`](https://github.com/apache/spark/commit/b989aa3821dbaf6cacccde886ed1051068d43cf5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910321821


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47421/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910224390


   **[Test build #142921 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142921/testReport)** for PR 33888 at commit [`3017e59`](https://github.com/apache/spark/commit/3017e59fee81ef7a3df9d656a0b34493577ff4e5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912693505


   **[Test build #142989 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142989/testReport)** for PR 33888 at commit [`b989aa3`](https://github.com/apache/spark/commit/b989aa3821dbaf6cacccde886ed1051068d43cf5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912444059


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142951/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r701639602



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetRowConverter.scala
##########
@@ -200,19 +200,28 @@ private[parquet] class ParquetRowConverter(
 
   // Converters for each field.
   private[this] val fieldConverters: Array[Converter with HasParentContainerUpdater] = {
-    // (SPARK-31116) Use case insensitive map if spark.sql.caseSensitive is false
-    // to prevent throwing IllegalArgumentException when searching catalyst type's field index
-    val catalystFieldNameToIndex = if (SQLConf.get.caseSensitiveAnalysis) {
-      catalystType.fieldNames.zipWithIndex.toMap
+    if (SQLConf.get.parquetAccessByOrdinal) {

Review comment:
       can we pass it in as a parameter of `ParquetRowConverter`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r704958740



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetQuerySuite.scala
##########
@@ -901,6 +901,91 @@ abstract class ParquetQuerySuite extends QueryTest with ParquetTest with SharedS
       }
     }
   }
+
+  test("SPARK-36634: Support access and read parquet file by column index") {
+    withTempDir { dir =>
+      val loc = s"file:///$dir/t"
+
+      withTable("t1", "t2", "t3") {
+        sql(s"create table t1 (my_id int, my_name string) using parquet location '$loc'")
+        sql(s"create table t2 (myid int, myName string) using parquet location '$loc'")
+        sql("insert into t1 select 1, 'apache'")
+        sql("insert into t2 select 2, 'software'")
+        sql("insert into t2 select 3, 'foundation'")
+        sql(s"create table t3 (myid int, myname string, myage int) using parquet location '$loc'")
+
+        withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "false")) {
+          checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(null), Row(null)))
+          checkAnswer(sql("select my_id, my_name from t1"),
+            Seq(Row(1, "apache"), Row(null, null), Row(null, null)))
+          assert(sql("select my_id, my_name from t1 where my_id=2").isEmpty)
+          checkAnswer(sql("select myid, myname, myage from t3"),
+            Seq(Row(2, "software", null),
+              Row(3, "foundation", null),
+              Row(null, null, null)))
+        }
+
+        sql("insert into t3 select 4, 'spark', 11")
+
+        withAllParquetReaders {
+          withSQLConf((SQLConf.PARQUET_ACCESS_BY_ORDINAL.key, "true")) {
+            checkAnswer(sql("select my_id from t1"), Seq(Row(1), Row(2), Row(3)))
+            val e1 = {
+              intercept[SparkException](sql("select my_name from t1").collect())
+            }
+            assert(e1.getCause.getMessage.contains("Parquet column cannot be converted in"))

Review comment:
       I see. Let me think it over.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912430146


   **[Test build #142979 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142979/testReport)** for PR 33888 at commit [`b53481c`](https://github.com/apache/spark/commit/b53481cbcf911b9f0a15a5e09ad62a65f42690ad).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937375741


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48411/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912462479


   Kubernetes integration test unable to build dist.
   
   exiting with code: 1
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47482/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r700701053



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala
##########
@@ -903,6 +903,13 @@ object SQLConf {
     .intConf
     .createWithDefault(4096)
 
+  val PARQUET_COLUMN_INDEX_ACCESS = buildConf("spark.sql.parquet.columnIndexAccess")

Review comment:
       make sense




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on a change in pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on a change in pull request #33888:
URL: https://github.com/apache/spark/pull/33888#discussion_r702049276



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetRowConverter.scala
##########
@@ -200,19 +200,28 @@ private[parquet] class ParquetRowConverter(
 
   // Converters for each field.
   private[this] val fieldConverters: Array[Converter with HasParentContainerUpdater] = {
-    // (SPARK-31116) Use case insensitive map if spark.sql.caseSensitive is false
-    // to prevent throwing IllegalArgumentException when searching catalyst type's field index
-    val catalystFieldNameToIndex = if (SQLConf.get.caseSensitiveAnalysis) {
-      catalystType.fieldNames.zipWithIndex.toMap
+    if (SQLConf.get.parquetAccessByIndex) {
+      // SPARK-36634: When access parquet file by the idx of columns, we can not ensure 2 types
+      // matched
+      parquetType.getFields.asScala.zip(catalystType).zipWithIndex.map {

Review comment:
       I have added test cases for this, for name or idx mapping the output sets for the exceed part result in `nulls`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912328326


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47465/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912456596


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47480/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910382187


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142921/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937975445


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/143996/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912727679


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47491/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912722307


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47491/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912241139


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47452/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912304918


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47465/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-911276204


   retest this please


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] yaooqinn commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912321859


   > @yaooqinn should orc support this similar behavior?
   
   yes, we can support other file sources later, if this looks good to the community and gets merged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] advancedxy commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
advancedxy commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-912320394


   @yaooqinn should orc support this similar behavior? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column ordinal

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-937505098


   **[Test build #143942 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143942/testReport)** for PR 33888 at commit [`b989aa3`](https://github.com/apache/spark/commit/b989aa3821dbaf6cacccde886ed1051068d43cf5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #33888: [SPARK-36634][SQL] Support access and read parquet file by column index

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33888:
URL: https://github.com/apache/spark/pull/33888#issuecomment-910099484


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/47415/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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