Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/10942#discussion_r51355831 --- Diff: sql/hive/src/test/scala/org/apache/spark/sql/sources/BucketedReadSuite.scala --- @@ -59,6 +60,136 @@ class BucketedReadSuite extends QueryTest with SQLTestUtils with TestHiveSinglet } } + // To verify bucket pruning, we compare the contents of remaining buckets (before filtering) + // with the expectedAnswer. + private def checkPrunedAnswers( + bucketedDataFrame: DataFrame, + expectedAnswer: DataFrame): Unit = { + val rdd = bucketedDataFrame.queryExecution.executedPlan.find(_.isInstanceOf[PhysicalRDD]) + assert(rdd.isDefined) + checkAnswer( + expectedAnswer.orderBy(expectedAnswer.logicalPlan.output.map(attr => Column(attr)) : _*), + rdd.get.executeCollectPublic().sortBy(_.toString())) + } + + test("read partitioning bucketed tables with bucket pruning filters") { + val df = (10 until 50).map(i => (i % 5, i % 13 + 10, i.toString)).toDF("i", "j", "k") + + withTable("bucketed_table") { + // The number of buckets should be large enough to make sure each bucket contains --- End diff -- This is just for simplifying verification of bucket pruning. In the current testing verification solution, we are checking if the rows in all the scanned buckets (**without applying any filter**) exactly match the expected/correct answers. You know, applying these filters could hide the bugs in bucket pruning. Thus, we want to skip all the filters when verifying bucket pruning. If more than one bucketing column values are hashed into the same bucket, the returned results could contain invalid rows that are in the same bucket. These invalid rows should be filtered out by the filters when running the whole query plan. Thanks!
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org