spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liancheng <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-6715][SQL] Eliminate duplicate filters ...
Date Mon, 06 Apr 2015 16:36:50 GMT
Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5369#discussion_r27808662
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/sources/FilteredScanSuite.scala
---
    @@ -233,6 +258,73 @@ class FilteredScanSuite extends DataSourceTest {
     
       testPushDown("SELECT a, b, c FROM oneToTenFiltered WHERE c like '%eE%'", 1)
       testPushDown("SELECT a, b, c FROM oneToTenFiltered WHERE c like '%Ee%'", 0)
    + 
    +  // Filter should not be duplicate with pushdown predicate 
    +  // This query should not have Filter node and have 1 row
    +  testNotFilter("SELECT a, b FROM oneToTenFiltered WHERE a = 1", 1)
    +  // This query have Filter node which filters 10 rows to 1 row
    +  testFilter("SELECT a, b FROM oneToTenFiltered WHERE b = 2", 10, 1)
    + 
    +  def testNotFilter(sqlString: String, count: Int): Unit = {
    +    test(s"Without Filter: $sqlString") {
    +      val queryExecution = sql(sqlString).queryExecution
    +      val filterPlan = queryExecution.executedPlan.collect {
    +        case f: execution.Filter => f
    +      } match {
    +        case Seq(f) => fail(s"Shouldn't find Filter\n$queryExecution")
    +        case _ =>
    +      }
    + 
    +      val physicalRDDPlan = queryExecution.executedPlan.collect {
    +        case p: execution.PhysicalRDD => p
    +      } match {
    +        case Seq(p) => p
    +        case _ => fail(s"Can't find PhysicalRDD\n$queryExecution")
    +      }
    --- End diff --
    
    The above code can be simplified as:
    
    ```scala
    val queryExecution = sql(sqlString).queryExecution
    
    val Seq(physicalRDDPlan) = queryExecution.executedPlan.collect {
      case _: execution.Filter => fail(s"Filter node shouldn't appear.\n$queryExecution")
      case plan: execution.PhysicalRDD => plan
    }
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message