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/03/16 08:30:57 UTC

[GitHub] [spark] peter-toth opened a new pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

peter-toth opened a new pull request #31848:
URL: https://github.com/apache/spark/pull/31848


   ### What changes were proposed in this pull request?
   This PR fixes `FileScan.equals()`.
   
   ### Why are the changes needed?
   Without this fix `FileScan.equals` doesn't take `fileIndex` and `readSchema` into account.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, before this fix incorrect reuse of `FileScan` and so `BatchScanExec` could have happed causing correctness issues.
   
   ### How was this patch tested?
   Trivial fix.
   


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   thanks, merging to master/3.1/3.0!


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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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] peter-toth commented on a change in pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r595132671



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -86,7 +86,7 @@ trait FileScan extends Scan
 
   override def equals(obj: Any): Boolean = obj match {
     case f: FileScan =>
-      fileIndex == f.fileIndex && readSchema == f.readSchema
+      fileIndex == f.fileIndex && readSchema == f.readSchema &&
         ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) &&
         ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters)

Review comment:
       Yes, I was thinking about the same. I will try to do this today.




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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] peter-toth commented on a change in pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r596229442



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,24 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes
+    val partitionFilterAttributes = AttributeSet(partitionFilters).map(a => a.name -> a).toMap
+    val dataFiltersAttributes = AttributeSet(dataFilters).map(a => a.name -> a).toMap
+    val normalizedPartitionFilters = ExpressionSet(partitionFilters.map(
+      QueryPlan.normalizeExpressions(_, output.map(a =>
+        partitionFilterAttributes.getOrElse(a.name, a)))))

Review comment:
       I think we shall, added in https://github.com/apache/spark/pull/31848/commits/776828e5741807a0e7d70f437f1968f1299f3185




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136340 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136340/testReport)** for PR 31848 at commit [`30d2d8b`](https://github.com/apache/spark/commit/30d2d8b38ae95661d9461e2f6fb961e01d144e64).


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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] dongjoon-hyun commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597194052



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/FileScanSuite.scala
##########
@@ -0,0 +1,385 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql
+
+import scala.collection.mutable
+
+import com.google.common.collect.ImmutableMap
+import org.apache.hadoop.fs.{FileStatus, Path}
+
+import org.apache.spark.sql.catalyst.dsl.expressions._
+import org.apache.spark.sql.catalyst.expressions.{And, Expression, IsNull, LessThan}
+import org.apache.spark.sql.execution.datasources.{PartitioningAwareFileIndex, PartitionSpec}
+import org.apache.spark.sql.execution.datasources.v2.FileScan
+import org.apache.spark.sql.execution.datasources.v2.csv.CSVScan
+import org.apache.spark.sql.execution.datasources.v2.json.JsonScan
+import org.apache.spark.sql.execution.datasources.v2.orc.OrcScan
+import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan
+import org.apache.spark.sql.execution.datasources.v2.text.TextScan
+import org.apache.spark.sql.sources.Filter
+import org.apache.spark.sql.test.SharedSparkSession
+import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+trait FileScanSuiteBase extends SharedSparkSession {
+  private def newPartitioningAwareFileIndex() = {
+    new PartitioningAwareFileIndex(spark, Map.empty, None) {
+      override def partitionSpec(): PartitionSpec = {
+        PartitionSpec.emptySpec
+      }
+
+      override protected def leafFiles: mutable.LinkedHashMap[Path, FileStatus] = {
+        mutable.LinkedHashMap.empty
+      }
+
+      override protected def leafDirToChildrenFiles: Map[Path, Array[FileStatus]] = {
+        Map.empty
+      }
+
+      override def rootPaths: Seq[Path] = {
+        Seq.empty
+      }
+
+      override def refresh(): Unit = {}
+    }
+  }
+
+  type ScanBuilder = (
+    SparkSession,
+      PartitioningAwareFileIndex,
+      StructType,
+      StructType,
+      StructType,
+      Array[Filter],
+      CaseInsensitiveStringMap,
+      Seq[Expression],
+      Seq[Expression]) => FileScan
+
+  def run(scanBuilders: Seq[(String, ScanBuilder, Seq[String])]): Unit = {
+    val dataSchema = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false)))
+    val dataSchemaNotEqual = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false),
+      StructField("new", IntegerType, false)))
+    val readDataSchema = StructType(Seq(StructField("data", IntegerType, false)))
+    val readDataSchemaNotEqual = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("other", IntegerType, false)))
+    val readPartitionSchema = StructType(Seq(StructField("partition", IntegerType, false)))
+    val readPartitionSchemaNotEqual = StructType(Seq(
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false)))

Review comment:
       In this case, the shorter is the better. Could you use the following style?
   ```scala
   -    val dataSchema = StructType(Seq(
   -      StructField("data", IntegerType, false),
   -      StructField("partition", IntegerType, false),
   -      StructField("other", IntegerType, false)))
   -    val dataSchemaNotEqual = StructType(Seq(
   -      StructField("data", IntegerType, false),
   -      StructField("partition", IntegerType, false),
   -      StructField("other", IntegerType, false),
   -      StructField("new", IntegerType, false)))
   -    val readDataSchema = StructType(Seq(StructField("data", IntegerType, false)))
   -    val readDataSchemaNotEqual = StructType(Seq(
   -      StructField("data", IntegerType, false),
   -      StructField("other", IntegerType, false)))
   -    val readPartitionSchema = StructType(Seq(StructField("partition", IntegerType, false)))
   -    val readPartitionSchemaNotEqual = StructType(Seq(
   -      StructField("partition", IntegerType, false),
   -      StructField("other", IntegerType, false)))
   +    val dataSchema = StructType.fromDDL("data INT, partition INT, other INT")
   +    val dataSchemaNotEqual = StructType.fromDDL("data INT, partition INT, other INT, new INT")
   +    val readDataSchema = StructType.fromDDL("data INT")
   +    val readDataSchemaNotEqual = StructType.fromDDL("data INT, other INT")
   +    val readPartitionSchema = StructType.fromDDL("partition INT")
   +    val readPartitionSchemaNotEqual = StructType.fromDDL("partition INT, other INT")
   ```




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -86,7 +86,7 @@ trait FileScan extends Scan
 
   override def equals(obj: Any): Boolean = obj match {
     case f: FileScan =>
-      fileIndex == f.fileIndex && readSchema == f.readSchema
+      fileIndex == f.fileIndex && readSchema == f.readSchema &&
         ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) &&
         ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters)

Review comment:
       SGTM




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -86,7 +86,7 @@ trait FileScan extends Scan
 
   override def equals(obj: Any): Boolean = obj match {
     case f: FileScan =>
-      fileIndex == f.fileIndex && readSchema == f.readSchema
+      fileIndex == f.fileIndex && readSchema == f.readSchema &&
         ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) &&
         ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters)

Review comment:
       shall we canonicalize the filters here to fix the exchange reuse issue?




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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,24 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes
+    val partitionFilterAttributes = AttributeSet(partitionFilters).map(a => a.name -> a).toMap
+    val dataFiltersAttributes = AttributeSet(dataFilters).map(a => a.name -> a).toMap
+    val normalizedPartitionFilters = ExpressionSet(partitionFilters.map(
+      QueryPlan.normalizeExpressions(_, output.map(a =>
+        partitionFilterAttributes.getOrElse(a.name, a)))))

Review comment:
       or the attr name inside the `data/partitionFilterAttributes` have been normalized already before?




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

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] peter-toth commented on a change in pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r594989408



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -86,7 +86,7 @@ trait FileScan extends Scan
 
   override def equals(obj: Any): Boolean = obj match {
     case f: FileScan =>
-      fileIndex == f.fileIndex && readSchema == f.readSchema
+      fileIndex == f.fileIndex && readSchema == f.readSchema &&
         ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) &&
         ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters)

Review comment:
       But don't we need the `output` of the ScanExec (`BatchScanExec`) node to do that?




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

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] peter-toth commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r598726497



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/FileScanSuite.scala
##########
@@ -0,0 +1,374 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql
+
+import scala.collection.mutable
+
+import com.google.common.collect.ImmutableMap
+import org.apache.hadoop.fs.{FileStatus, Path}
+
+import org.apache.spark.sql.catalyst.dsl.expressions._
+import org.apache.spark.sql.catalyst.expressions.{And, Expression, IsNull, LessThan}
+import org.apache.spark.sql.execution.datasources.{PartitioningAwareFileIndex, PartitionSpec}
+import org.apache.spark.sql.execution.datasources.v2.FileScan
+import org.apache.spark.sql.execution.datasources.v2.csv.CSVScan
+import org.apache.spark.sql.execution.datasources.v2.json.JsonScan
+import org.apache.spark.sql.execution.datasources.v2.orc.OrcScan
+import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan
+import org.apache.spark.sql.execution.datasources.v2.text.TextScan
+import org.apache.spark.sql.sources.Filter
+import org.apache.spark.sql.test.SharedSparkSession
+import org.apache.spark.sql.types.StructType
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+trait FileScanSuiteBase extends SharedSparkSession {
+  private def newPartitioningAwareFileIndex() = {
+    new PartitioningAwareFileIndex(spark, Map.empty, None) {
+      override def partitionSpec(): PartitionSpec = {
+        PartitionSpec.emptySpec
+      }
+
+      override protected def leafFiles: mutable.LinkedHashMap[Path, FileStatus] = {
+        mutable.LinkedHashMap.empty
+      }
+
+      override protected def leafDirToChildrenFiles: Map[Path, Array[FileStatus]] = {
+        Map.empty
+      }
+
+      override def rootPaths: Seq[Path] = {
+        Seq.empty
+      }
+
+      override def refresh(): Unit = {}
+    }
+  }
+
+  type ScanBuilder = (
+    SparkSession,
+      PartitioningAwareFileIndex,
+      StructType,
+      StructType,
+      StructType,
+      Array[Filter],
+      CaseInsensitiveStringMap,
+      Seq[Expression],
+      Seq[Expression]) => FileScan
+
+  def run(scanBuilders: Seq[(String, ScanBuilder, Seq[String])]): Unit = {
+    val dataSchema = StructType.fromDDL("data INT, partition INT, other INT")
+    val dataSchemaNotEqual = StructType.fromDDL("data INT, partition INT, other INT, new INT")
+    val readDataSchema = StructType.fromDDL("data INT")
+    val readDataSchemaNotEqual = StructType.fromDDL("data INT, other INT")
+    val readPartitionSchema = StructType.fromDDL("partition INT")
+    val readPartitionSchemaNotEqual = StructType.fromDDL("partition INT, other INT")
+    val pushedFilters =
+      Array[Filter](sources.And(sources.IsNull("data"), sources.LessThan("data", 0)))
+    val pushedFiltersNotEqual =
+      Array[Filter](sources.And(sources.IsNull("data"), sources.LessThan("data", 1)))
+    val optionsMap = ImmutableMap.of("key", "value")
+    val options = new CaseInsensitiveStringMap(ImmutableMap.copyOf(optionsMap))
+    val optionsNotEqual =
+      new CaseInsensitiveStringMap(ImmutableMap.copyOf(ImmutableMap.of("key2", "value2")))
+    val partitionFilters = Seq(And(IsNull('data.int), LessThan('data.int, 0)))
+    val partitionFiltersNotEqual = Seq(And(IsNull('data.int), LessThan('data.int, 1)))
+    val dataFilters = Seq(And(IsNull('data.int), LessThan('data.int, 0)))
+    val dataFiltersNotEqual = Seq(And(IsNull('data.int), LessThan('data.int, 1)))
+
+    scanBuilders.foreach { case (name, scanBuilder, exclusions) =>
+      test(s"SPARK-33482: Test $name equals") {
+        val partitioningAwareFileIndex = newPartitioningAwareFileIndex()
+
+        val parquetScan = scanBuilder(

Review comment:
       Fixed in https://github.com/apache/spark/pull/31848/commits/0d38ac27dec27b77e0057113fbb57de8ea4cd3ca




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

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] dongjoon-hyun commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597194052



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/FileScanSuite.scala
##########
@@ -0,0 +1,385 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql
+
+import scala.collection.mutable
+
+import com.google.common.collect.ImmutableMap
+import org.apache.hadoop.fs.{FileStatus, Path}
+
+import org.apache.spark.sql.catalyst.dsl.expressions._
+import org.apache.spark.sql.catalyst.expressions.{And, Expression, IsNull, LessThan}
+import org.apache.spark.sql.execution.datasources.{PartitioningAwareFileIndex, PartitionSpec}
+import org.apache.spark.sql.execution.datasources.v2.FileScan
+import org.apache.spark.sql.execution.datasources.v2.csv.CSVScan
+import org.apache.spark.sql.execution.datasources.v2.json.JsonScan
+import org.apache.spark.sql.execution.datasources.v2.orc.OrcScan
+import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan
+import org.apache.spark.sql.execution.datasources.v2.text.TextScan
+import org.apache.spark.sql.sources.Filter
+import org.apache.spark.sql.test.SharedSparkSession
+import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+trait FileScanSuiteBase extends SharedSparkSession {
+  private def newPartitioningAwareFileIndex() = {
+    new PartitioningAwareFileIndex(spark, Map.empty, None) {
+      override def partitionSpec(): PartitionSpec = {
+        PartitionSpec.emptySpec
+      }
+
+      override protected def leafFiles: mutable.LinkedHashMap[Path, FileStatus] = {
+        mutable.LinkedHashMap.empty
+      }
+
+      override protected def leafDirToChildrenFiles: Map[Path, Array[FileStatus]] = {
+        Map.empty
+      }
+
+      override def rootPaths: Seq[Path] = {
+        Seq.empty
+      }
+
+      override def refresh(): Unit = {}
+    }
+  }
+
+  type ScanBuilder = (
+    SparkSession,
+      PartitioningAwareFileIndex,
+      StructType,
+      StructType,
+      StructType,
+      Array[Filter],
+      CaseInsensitiveStringMap,
+      Seq[Expression],
+      Seq[Expression]) => FileScan
+
+  def run(scanBuilders: Seq[(String, ScanBuilder, Seq[String])]): Unit = {
+    val dataSchema = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false)))
+    val dataSchemaNotEqual = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false),
+      StructField("new", IntegerType, false)))
+    val readDataSchema = StructType(Seq(StructField("data", IntegerType, false)))
+    val readDataSchemaNotEqual = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("other", IntegerType, false)))
+    val readPartitionSchema = StructType(Seq(StructField("partition", IntegerType, false)))
+    val readPartitionSchemaNotEqual = StructType(Seq(
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false)))

Review comment:
       In this case, shorter is better. Could you use the following style?
   ```scala
   -    val dataSchema = StructType(Seq(
   -      StructField("data", IntegerType, false),
   -      StructField("partition", IntegerType, false),
   -      StructField("other", IntegerType, false)))
   -    val dataSchemaNotEqual = StructType(Seq(
   -      StructField("data", IntegerType, false),
   -      StructField("partition", IntegerType, false),
   -      StructField("other", IntegerType, false),
   -      StructField("new", IntegerType, false)))
   -    val readDataSchema = StructType(Seq(StructField("data", IntegerType, false)))
   -    val readDataSchemaNotEqual = StructType(Seq(
   -      StructField("data", IntegerType, false),
   -      StructField("other", IntegerType, false)))
   -    val readPartitionSchema = StructType(Seq(StructField("partition", IntegerType, false)))
   -    val readPartitionSchemaNotEqual = StructType(Seq(
   -      StructField("partition", IntegerType, false),
   -      StructField("other", IntegerType, false)))
   +    val dataSchema = StructType.fromDDL("data INT, partition INT, other INT")
   +    val dataSchemaNotEqual = StructType.fromDDL("data INT, partition INT, other INT, new INT")
   +    val readDataSchema = StructType.fromDDL("data INT")
   +    val readDataSchemaNotEqual = StructType.fromDDL("data INT, other INT")
   +    val readPartitionSchema = StructType.fromDDL("partition INT")
   +    val readPartitionSchemaNotEqual = StructType.fromDDL("partition INT, other INT")
   ```




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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,24 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes
+    val partitionFilterAttributes = AttributeSet(partitionFilters).map(a => a.name -> a).toMap
+    val dataFiltersAttributes = AttributeSet(dataFilters).map(a => a.name -> a).toMap
+    val normalizedPartitionFilters = ExpressionSet(partitionFilters.map(
+      QueryPlan.normalizeExpressions(_, output.map(a =>
+        partitionFilterAttributes.getOrElse(a.name, a)))))

Review comment:
       shall we consider case sensitivity 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.

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] dongjoon-hyun commented on pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-804807267


   Thank you, @peter-toth and @cloud-fan .


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

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] dongjoon-hyun commented on pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-805110197


   It seems this breaks `branch-3.0`.
   ```
   [error] /Users/dongjoon/APACHE/spark-merge/external/avro/src/test/scala/org/apache/spark/sql/avro/AvroScanSuite.scala:26: one more argument than can be applied to method apply: (sparkSession: org.apache.spark.sql.SparkSession, fileIndex: org.apache.spark.sql.execution.datasources.PartitioningAwareFileIndex, dataSchema: org.apache.spark.sql.types.StructType, readDataSchema: org.apache.spark.sql.types.StructType, readPartitionSchema: org.apache.spark.sql.types.StructType, options: org.apache.spark.sql.util.CaseInsensitiveStringMap, partitionFilters: Seq[org.apache.spark.sql.catalyst.expressions.Expression], dataFilters: Seq[org.apache.spark.sql.catalyst.expressions.Expression])org.apache.spark.sql.v2.avro.AvroScan in object AvroScan
   [error]       (s, fi, ds, rds, rps, f, o, pf, df) => AvroScan(s, fi, ds, rds, rps, o, f, pf, df),
   [error]                                                                                      ^
   [error] one error found
   ```
   
   I'll revert it first at branch-3.0. Please make a backporting PR to branch-3.0, @peter-toth .


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

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] peter-toth commented on pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-802164579


   @dongjoon-hyun I added new UTs in https://github.com/apache/spark/pull/31848/commits/9711da02b01d900bd25b3814e11358f2c36453f2
   


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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] peter-toth commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597885016



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,25 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes.map(a => a.withName(normalizeName(a.name)))

Review comment:
       I see your point and agree that name is that matters in these `Filter` like `Expressions` but if we go this way then I think:
   - we also need to clear other properties of `AttributeReference`s like `qualifier`
   - we need to either explicitly sort `partitionFilters` and `dataFilters` expression lists (probably with `.sortBy(_.hashCode())`) to make sure they match with `f.partitionFilters` and `f.dataFilters`, or use `Set(partitionFilters) == Set(f.partitionFilters)` because we can't use `ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters)` as we removed all expr ids
   - we need to reorder all descendants of each `partitionFilters` and `dataFilters` expression (with `Canonicalize.expressionReorder()` to make sure like `id = 1` matches with `1 = id` (and `Canonicalize.ignoreTimeZone()` also needs to be applied)
   
   And just a side note that I think we could do most of the above at https://github.com/apache/spark/blob/v3.1.1/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PruneFileSourcePartitions.scala#L120-L121 before `withFilters()` and then `FileScan.equals()` became very simple.
   
   But I wonder all these changes are simpler than the current PR?




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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136340 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136340/testReport)** for PR 31848 at commit [`30d2d8b`](https://github.com/apache/spark/commit/30d2d8b38ae95661d9461e2f6fb961e01d144e64).
    * 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.

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] dongjoon-hyun commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597137203



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/FileScanSuite.scala
##########
@@ -0,0 +1,385 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql
+
+import scala.collection.mutable
+
+import com.google.common.collect.ImmutableMap
+import org.apache.hadoop.fs.{FileStatus, Path}
+
+import org.apache.spark.sql.catalyst.dsl.expressions._
+import org.apache.spark.sql.catalyst.expressions.{And, Expression, IsNull, LessThan}
+import org.apache.spark.sql.execution.datasources.{PartitioningAwareFileIndex, PartitionSpec}
+import org.apache.spark.sql.execution.datasources.v2.FileScan
+import org.apache.spark.sql.execution.datasources.v2.csv.CSVScan
+import org.apache.spark.sql.execution.datasources.v2.json.JsonScan
+import org.apache.spark.sql.execution.datasources.v2.orc.OrcScan
+import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan
+import org.apache.spark.sql.execution.datasources.v2.text.TextScan
+import org.apache.spark.sql.sources.Filter
+import org.apache.spark.sql.test.SharedSparkSession
+import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+trait FileScanSuiteBase extends SharedSparkSession {

Review comment:
       This looks nice!




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136349 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136349/testReport)** for PR 31848 at commit [`0d38ac2`](https://github.com/apache/spark/commit/0d38ac27dec27b77e0057113fbb57de8ea4cd3ca).


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136253 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136253/testReport)** for PR 31848 at commit [`d782723`](https://github.com/apache/spark/commit/d782723ee5728f54ad8884dab45e3d263a5fa442).


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,25 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes.map(a => a.withName(normalizeName(a.name)))

Review comment:
       Good point. For simplicity maybe we should just assign fresh expr IDs like what this PR did, but we can remove the case sensitivity handling 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.

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136349 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136349/testReport)** for PR 31848 at commit [`0d38ac2`](https://github.com/apache/spark/commit/0d38ac27dec27b77e0057113fbb57de8ea4cd3ca).


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

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] peter-toth commented on pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-804736406


   Thanks @cloud-fan and @dongjoon-hyun for the review.


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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -86,7 +86,7 @@ trait FileScan extends Scan
 
   override def equals(obj: Any): Boolean = obj match {
     case f: FileScan =>
-      fileIndex == f.fileIndex && readSchema == f.readSchema
+      fileIndex == f.fileIndex && readSchema == f.readSchema &&
         ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) &&
         ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters)

Review comment:
       Thinking about it a bit more, do we really need `output`? We can canonicalize expr IDs to 0 and only look at the column name.




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

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] peter-toth commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597121998



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,25 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes.map(a => a.withName(normalizeName(a.name)))
+    val partitionFilterAttributes =
+      AttributeSet(partitionFilters).map(a => normalizeName(a.name) -> a).toMap
+    val dataFiltersAttributes = AttributeSet(dataFilters).map(a => normalizeName(a.name) -> a).toMap
+    val normalizedPartitionFilters = ExpressionSet(partitionFilters.map(
+      QueryPlan.normalizeExpressions(_,
+        output.map(a => partitionFilterAttributes.getOrElse(a.name, a)))))
+    val normalizedDataFilters = ExpressionSet(dataFilters.map(
+      QueryPlan.normalizeExpressions(_,
+        output.map(a => dataFiltersAttributes.getOrElse(a.name, a)))))
+    (normalizedPartitionFilters, normalizedDataFilters)
+  }
+
   override def equals(obj: Any): Boolean = obj match {

Review comment:
       Shall I update `hashCode()` as well? Looks like we can easily come up with a better one...




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

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] dongjoon-hyun commented on pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-802179891


   Thank you for update, @peter-toth !


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

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] dongjoon-hyun commented on pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-800441357


   Thank you, @peter-toth . I prefer a simple one focusing on `.equals()` only.
   
   > @dongjoon-hyun, you asked for a UT in [#31820 (review)](https://github.com/apache/spark/pull/31820#pullrequestreview-612593409), shall I create a simple one focusing on `.equals()` (I wonder where is the right place for such a test?) or shall shall I create an e2e test where a correctness issue is shown and fixed?
   
   


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136340 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136340/testReport)** for PR 31848 at commit [`30d2d8b`](https://github.com/apache/spark/commit/30d2d8b38ae95661d9461e2f6fb961e01d144e64).


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

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] dongjoon-hyun commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597136614



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,25 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes.map(a => a.withName(normalizeName(a.name)))
+    val partitionFilterAttributes =
+      AttributeSet(partitionFilters).map(a => normalizeName(a.name) -> a).toMap
+    val dataFiltersAttributes = AttributeSet(dataFilters).map(a => normalizeName(a.name) -> a).toMap
+    val normalizedPartitionFilters = ExpressionSet(partitionFilters.map(
+      QueryPlan.normalizeExpressions(_,
+        output.map(a => partitionFilterAttributes.getOrElse(a.name, a)))))
+    val normalizedDataFilters = ExpressionSet(dataFilters.map(
+      QueryPlan.normalizeExpressions(_,
+        output.map(a => dataFiltersAttributes.getOrElse(a.name, a)))))
+    (normalizedPartitionFilters, normalizedDataFilters)
+  }
+
   override def equals(obj: Any): Boolean = obj match {

Review comment:
       Please file a new JIRA and go for it, @peter-toth ! :)




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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] peter-toth commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r598564355



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,25 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes.map(a => a.withName(normalizeName(a.name)))

Review comment:
       Ok, removed in https://github.com/apache/spark/pull/31848/commits/30d2d8b38ae95661d9461e2f6fb961e01d144e64




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

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] dongjoon-hyun commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597136204



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,25 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes.map(a => a.withName(normalizeName(a.name)))
+    val partitionFilterAttributes =
+      AttributeSet(partitionFilters).map(a => normalizeName(a.name) -> a).toMap
+    val dataFiltersAttributes = AttributeSet(dataFilters).map(a => normalizeName(a.name) -> a).toMap
+    val normalizedPartitionFilters = ExpressionSet(partitionFilters.map(
+      QueryPlan.normalizeExpressions(_,
+        output.map(a => partitionFilterAttributes.getOrElse(a.name, a)))))
+    val normalizedDataFilters = ExpressionSet(dataFilters.map(
+      QueryPlan.normalizeExpressions(_,
+        output.map(a => dataFiltersAttributes.getOrElse(a.name, a)))))
+    (normalizedPartitionFilters, normalizedDataFilters)
+  }
+
   override def equals(obj: Any): Boolean = obj match {

Review comment:
       Shall we do that separately because it's irrelevant to the correctness issue?
   In general, we expect a performance improvement with that, don't we?
   Apache Spark doesn't allow to backport performance improvement.




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136349 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136349/testReport)** for PR 31848 at commit [`0d38ac2`](https://github.com/apache/spark/commit/0d38ac27dec27b77e0057113fbb57de8ea4cd3ca).
    * 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.

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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] peter-toth commented on pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-805636366


   > It seems this breaks `branch-3.0`.
   > 
   > ```
   > [error] /Users/dongjoon/APACHE/spark-merge/external/avro/src/test/scala/org/apache/spark/sql/avro/AvroScanSuite.scala:26: one more argument than can be applied to method apply: (sparkSession: org.apache.spark.sql.SparkSession, fileIndex: org.apache.spark.sql.execution.datasources.PartitioningAwareFileIndex, dataSchema: org.apache.spark.sql.types.StructType, readDataSchema: org.apache.spark.sql.types.StructType, readPartitionSchema: org.apache.spark.sql.types.StructType, options: org.apache.spark.sql.util.CaseInsensitiveStringMap, partitionFilters: Seq[org.apache.spark.sql.catalyst.expressions.Expression], dataFilters: Seq[org.apache.spark.sql.catalyst.expressions.Expression])org.apache.spark.sql.v2.avro.AvroScan in object AvroScan
   > [error]       (s, fi, ds, rds, rps, f, o, pf, df) => AvroScan(s, fi, ds, rds, rps, o, f, pf, df),
   > [error]                                                                                      ^
   > [error] one error found
   > ```
   > 
   > I'll revert it first at branch-3.0. Please make a backporting PR to branch-3.0, @peter-toth .
   
   @dongjoon-hyun, I've opened a 3.0 backport PR here: https://github.com/apache/spark/pull/31952


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -86,7 +86,7 @@ trait FileScan extends Scan
 
   override def equals(obj: Any): Boolean = obj match {
     case f: FileScan =>
-      fileIndex == f.fileIndex && readSchema == f.readSchema
+      fileIndex == f.fileIndex && readSchema == f.readSchema &&
         ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) &&
         ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters)

Review comment:
       You are right. Then it's hard to canonicalize `Scan` implementations that are outside of Spark...




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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] dongjoon-hyun commented on pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-800453255


   For the following question, yes, it seems that we don't have a proper one yet. If we don't have a proper test suite, shall we  make one like `FileScanSuite`? I guess the new test suite need to cover all the following implementations: ParquetScan, OrcScan, CSVScan, JsonScan, TextScan, AvroScan.
   > I wonder where is the right place for such a 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.

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] peter-toth commented on pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-800066405


   @dongjoon-hyun, you asked for a UT in https://github.com/apache/spark/pull/31820#pullrequestreview-612593409, shall I create a simple one focusing on `.equals()` (I wonder where is the right place for such a test?) or shall shall I create an e2e test where a correctness issue is shown and fixed?


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/FileScanSuite.scala
##########
@@ -0,0 +1,374 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql
+
+import scala.collection.mutable
+
+import com.google.common.collect.ImmutableMap
+import org.apache.hadoop.fs.{FileStatus, Path}
+
+import org.apache.spark.sql.catalyst.dsl.expressions._
+import org.apache.spark.sql.catalyst.expressions.{And, Expression, IsNull, LessThan}
+import org.apache.spark.sql.execution.datasources.{PartitioningAwareFileIndex, PartitionSpec}
+import org.apache.spark.sql.execution.datasources.v2.FileScan
+import org.apache.spark.sql.execution.datasources.v2.csv.CSVScan
+import org.apache.spark.sql.execution.datasources.v2.json.JsonScan
+import org.apache.spark.sql.execution.datasources.v2.orc.OrcScan
+import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan
+import org.apache.spark.sql.execution.datasources.v2.text.TextScan
+import org.apache.spark.sql.sources.Filter
+import org.apache.spark.sql.test.SharedSparkSession
+import org.apache.spark.sql.types.StructType
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+trait FileScanSuiteBase extends SharedSparkSession {
+  private def newPartitioningAwareFileIndex() = {
+    new PartitioningAwareFileIndex(spark, Map.empty, None) {
+      override def partitionSpec(): PartitionSpec = {
+        PartitionSpec.emptySpec
+      }
+
+      override protected def leafFiles: mutable.LinkedHashMap[Path, FileStatus] = {
+        mutable.LinkedHashMap.empty
+      }
+
+      override protected def leafDirToChildrenFiles: Map[Path, Array[FileStatus]] = {
+        Map.empty
+      }
+
+      override def rootPaths: Seq[Path] = {
+        Seq.empty
+      }
+
+      override def refresh(): Unit = {}
+    }
+  }
+
+  type ScanBuilder = (
+    SparkSession,
+      PartitioningAwareFileIndex,
+      StructType,
+      StructType,
+      StructType,
+      Array[Filter],
+      CaseInsensitiveStringMap,
+      Seq[Expression],
+      Seq[Expression]) => FileScan
+
+  def run(scanBuilders: Seq[(String, ScanBuilder, Seq[String])]): Unit = {
+    val dataSchema = StructType.fromDDL("data INT, partition INT, other INT")
+    val dataSchemaNotEqual = StructType.fromDDL("data INT, partition INT, other INT, new INT")
+    val readDataSchema = StructType.fromDDL("data INT")
+    val readDataSchemaNotEqual = StructType.fromDDL("data INT, other INT")
+    val readPartitionSchema = StructType.fromDDL("partition INT")
+    val readPartitionSchemaNotEqual = StructType.fromDDL("partition INT, other INT")
+    val pushedFilters =
+      Array[Filter](sources.And(sources.IsNull("data"), sources.LessThan("data", 0)))
+    val pushedFiltersNotEqual =
+      Array[Filter](sources.And(sources.IsNull("data"), sources.LessThan("data", 1)))
+    val optionsMap = ImmutableMap.of("key", "value")
+    val options = new CaseInsensitiveStringMap(ImmutableMap.copyOf(optionsMap))
+    val optionsNotEqual =
+      new CaseInsensitiveStringMap(ImmutableMap.copyOf(ImmutableMap.of("key2", "value2")))
+    val partitionFilters = Seq(And(IsNull('data.int), LessThan('data.int, 0)))
+    val partitionFiltersNotEqual = Seq(And(IsNull('data.int), LessThan('data.int, 1)))
+    val dataFilters = Seq(And(IsNull('data.int), LessThan('data.int, 0)))
+    val dataFiltersNotEqual = Seq(And(IsNull('data.int), LessThan('data.int, 1)))
+
+    scanBuilders.foreach { case (name, scanBuilder, exclusions) =>
+      test(s"SPARK-33482: Test $name equals") {
+        val partitioningAwareFileIndex = newPartitioningAwareFileIndex()
+
+        val parquetScan = scanBuilder(

Review comment:
       `parquetScan` -> `fileScan`?




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

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 closed pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #31848:
URL: https://github.com/apache/spark/pull/31848


   


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,25 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes.map(a => a.withName(normalizeName(a.name)))

Review comment:
       Thinking about it again, the `FileScan` equality already considers `fileIndex` and `readSchema`, which means 2 file scans only equal to each other if they read the same set of files and the same set of columns.
   
   Given that, I think the expr IDs do not matter for filters, only the column name matters. For normal v2 sources, they use `Filter` not `Expression`, which do not have expr IDs either.
   
   The data/partition filters are created in `PruneFileSourcePartitions`(see https://github.com/apache/spark/blob/v3.1.1/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PruneFileSourcePartitions.scala#L51), and the column names inside filters are already normalized w.r.t. the actual file scan output schema, so we don't need to consider case sensitivity here.
   
   That said, I think the normalize logic here should be very simple: just turn expr IDs to 0.




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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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] peter-toth commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597535923



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/FileScanSuite.scala
##########
@@ -0,0 +1,385 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql
+
+import scala.collection.mutable
+
+import com.google.common.collect.ImmutableMap
+import org.apache.hadoop.fs.{FileStatus, Path}
+
+import org.apache.spark.sql.catalyst.dsl.expressions._
+import org.apache.spark.sql.catalyst.expressions.{And, Expression, IsNull, LessThan}
+import org.apache.spark.sql.execution.datasources.{PartitioningAwareFileIndex, PartitionSpec}
+import org.apache.spark.sql.execution.datasources.v2.FileScan
+import org.apache.spark.sql.execution.datasources.v2.csv.CSVScan
+import org.apache.spark.sql.execution.datasources.v2.json.JsonScan
+import org.apache.spark.sql.execution.datasources.v2.orc.OrcScan
+import org.apache.spark.sql.execution.datasources.v2.parquet.ParquetScan
+import org.apache.spark.sql.execution.datasources.v2.text.TextScan
+import org.apache.spark.sql.sources.Filter
+import org.apache.spark.sql.test.SharedSparkSession
+import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+trait FileScanSuiteBase extends SharedSparkSession {
+  private def newPartitioningAwareFileIndex() = {
+    new PartitioningAwareFileIndex(spark, Map.empty, None) {
+      override def partitionSpec(): PartitionSpec = {
+        PartitionSpec.emptySpec
+      }
+
+      override protected def leafFiles: mutable.LinkedHashMap[Path, FileStatus] = {
+        mutable.LinkedHashMap.empty
+      }
+
+      override protected def leafDirToChildrenFiles: Map[Path, Array[FileStatus]] = {
+        Map.empty
+      }
+
+      override def rootPaths: Seq[Path] = {
+        Seq.empty
+      }
+
+      override def refresh(): Unit = {}
+    }
+  }
+
+  type ScanBuilder = (
+    SparkSession,
+      PartitioningAwareFileIndex,
+      StructType,
+      StructType,
+      StructType,
+      Array[Filter],
+      CaseInsensitiveStringMap,
+      Seq[Expression],
+      Seq[Expression]) => FileScan
+
+  def run(scanBuilders: Seq[(String, ScanBuilder, Seq[String])]): Unit = {
+    val dataSchema = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false)))
+    val dataSchemaNotEqual = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false),
+      StructField("new", IntegerType, false)))
+    val readDataSchema = StructType(Seq(StructField("data", IntegerType, false)))
+    val readDataSchemaNotEqual = StructType(Seq(
+      StructField("data", IntegerType, false),
+      StructField("other", IntegerType, false)))
+    val readPartitionSchema = StructType(Seq(StructField("partition", IntegerType, false)))
+    val readPartitionSchemaNotEqual = StructType(Seq(
+      StructField("partition", IntegerType, false),
+      StructField("other", IntegerType, false)))

Review comment:
       Thanks @dongjoon-hyun, I updated the PR with this change in: https://github.com/apache/spark/pull/31848/commits/d782723ee5728f54ad8884dab45e3d263a5fa442




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

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] peter-toth commented on pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on pull request #31848:
URL: https://github.com/apache/spark/pull/31848#issuecomment-801264874


   > For the following question, yes, it seems that we don't have a proper one yet. If we don't have a proper test suite, shall we make one like `FileScanSuite`? I guess the new test suite need to cover all the following implementations: ParquetScan, OrcScan, CSVScan, JsonScan, TextScan, AvroScan.
   > 
   > > I wonder where is the right place for such a test?
   
   Thanks @dongjoon-hyun, I will try to update this PR with new tests this week.


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136253 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136253/testReport)** for PR 31848 at commit [`d782723`](https://github.com/apache/spark/commit/d782723ee5728f54ad8884dab45e3d263a5fa442).
    * 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.

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-34756][SQL] Fix FileScan equality check

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


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


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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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


   **[Test build #136253 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/136253/testReport)** for PR 31848 at commit [`d782723`](https://github.com/apache/spark/commit/d782723ee5728f54ad8884dab45e3d263a5fa442).


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

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] peter-toth commented on a change in pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r595472475



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -86,7 +86,7 @@ trait FileScan extends Scan
 
   override def equals(obj: Any): Boolean = obj match {
     case f: FileScan =>
-      fileIndex == f.fileIndex && readSchema == f.readSchema
+      fileIndex == f.fileIndex && readSchema == f.readSchema &&
         ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) &&
         ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters)

Review comment:
       I was thinking about a change like in https://github.com/apache/spark/pull/31848/commits/f65ebe3f397053e103d482c50d7f250f798bb825.
   That way we don't need to duplicate some parts of the canonicalization logic defined in `QueryPlan.normalizeExpressions` and in `Expression.canonicalized` (`Canonicalize.expressionReorder`, `Canonicalize.ignoreTimeZone`)...
   
   If this looks ok to you then I can add UTs for `.equals()` into a new `FileScanSuite` as @dongjoon-hyun suggested and move the e2e UT from https://github.com/apache/spark/pull/31820 to here as we don't need the other change in `BatchScanExec`.




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

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] dongjoon-hyun commented on a change in pull request #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r597136204



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -84,11 +85,25 @@ trait FileScan extends Scan
 
   protected def seqToString(seq: Seq[Any]): String = seq.mkString("[", ", ", "]")
 
+  private lazy val (normalizedPartitionFilters, normalizedDataFilters) = {
+    val output = readSchema().toAttributes.map(a => a.withName(normalizeName(a.name)))
+    val partitionFilterAttributes =
+      AttributeSet(partitionFilters).map(a => normalizeName(a.name) -> a).toMap
+    val dataFiltersAttributes = AttributeSet(dataFilters).map(a => normalizeName(a.name) -> a).toMap
+    val normalizedPartitionFilters = ExpressionSet(partitionFilters.map(
+      QueryPlan.normalizeExpressions(_,
+        output.map(a => partitionFilterAttributes.getOrElse(a.name, a)))))
+    val normalizedDataFilters = ExpressionSet(dataFilters.map(
+      QueryPlan.normalizeExpressions(_,
+        output.map(a => dataFiltersAttributes.getOrElse(a.name, a)))))
+    (normalizedPartitionFilters, normalizedDataFilters)
+  }
+
   override def equals(obj: Any): Boolean = obj match {

Review comment:
       Shall we do that separately because it's irrelevant to the correctness issue?
   In general, we expect a performance improvement with that, don't we?
   In general, Apache Spark doesn't allow to backport performance improvement.




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

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 #31848: [SPARK-33482][SPARK-34756][SQL] Fix FileScan equality check

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






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

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] peter-toth commented on a change in pull request #31848: [SPARK-34756][SQL] Fix FileScan equality check

Posted by GitBox <gi...@apache.org>.
peter-toth commented on a change in pull request #31848:
URL: https://github.com/apache/spark/pull/31848#discussion_r594989408



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/FileScan.scala
##########
@@ -86,7 +86,7 @@ trait FileScan extends Scan
 
   override def equals(obj: Any): Boolean = obj match {
     case f: FileScan =>
-      fileIndex == f.fileIndex && readSchema == f.readSchema
+      fileIndex == f.fileIndex && readSchema == f.readSchema &&
         ExpressionSet(partitionFilters) == ExpressionSet(f.partitionFilters) &&
         ExpressionSet(dataFilters) == ExpressionSet(f.dataFilters)

Review comment:
       But don't we need the `output` of the ScanExec (`BatchScanExec`) node to do that?
   I need to look into this a bit...




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

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