Github user watermen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9959#discussion_r45940129
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala 
---
    @@ -2028,4 +2028,25 @@ class SQLQuerySuite extends QueryTest with 
SharedSQLContext {
           Row(false) :: Row(true) :: Nil)
       }
     
    +  test("push filter through aggregation with alias and literals") {
    +    withTempTable("src") {
    +      Seq((1, 1), (-1, 1)).toDF("key", "value").registerTempTable("src")
    +      val q1 = sql(
    +        """
    +          | SELECT k, v from (
    +          |   SELECT key + 1 AS k, sum(value) + 2 AS v, 3 c FROM src GROUP 
BY key
    +          | ) t WHERE k = 0 and v > 0 and c = 3
    +        """.stripMargin)
    +      val q2 = sql(
    +        """
    +          | SELECT k, v from (
    +          |   SELECT key + 1 AS k, sum(value) + 2 AS v, 3 c FROM src WHERE 
key + 1 = 0 GROUP BY key
    +          | ) t WHERE v > 0
    +        """.stripMargin)
    --- End diff --
    
    Can also push `v > 0` into Subquery use `HAVING`? like:
    ```
    SELECT k, v from (
      SELECT key + 1 AS k, sum(value) + 2 AS v, 3 c FROM src WHERE key + 1 = 0 
GROUP BY key HAVING v > 0
    ) t
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to