Return-Path: X-Original-To: apmail-spark-reviews-archive@minotaur.apache.org Delivered-To: apmail-spark-reviews-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62029175CB for ; Mon, 6 Apr 2015 16:36:51 +0000 (UTC) Received: (qmail 14035 invoked by uid 500); 6 Apr 2015 16:36:51 -0000 Delivered-To: apmail-spark-reviews-archive@spark.apache.org Received: (qmail 14012 invoked by uid 500); 6 Apr 2015 16:36:51 -0000 Mailing-List: contact reviews-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@spark.apache.org Received: (qmail 14001 invoked by uid 99); 6 Apr 2015 16:36:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 16:36:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9EB1BE10AF; Mon, 6 Apr 2015 16:36:50 +0000 (UTC) From: liancheng To: reviews@spark.apache.org Reply-To: reviews@spark.apache.org References: In-Reply-To: Subject: [GitHub] spark pull request: [SPARK-6715][SQL] Eliminate duplicate filters ... Content-Type: text/plain Message-Id: <20150406163650.9EB1BE10AF@git1-us-west.apache.org> Date: Mon, 6 Apr 2015 16:36:50 +0000 (UTC) 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