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

    https://github.com/apache/spark/pull/17636#discussion_r111833402
  
    --- Diff: 
sql/core/src/test/resources/sql-tests/inputs/subquery/negative-cases/invalid-correlation.sql
 ---
    @@ -1,42 +1,72 @@
     -- The test file contains negative test cases
     -- of invalid queries where error messages are expected.
     
    -create temporary view t1 as select * from values
    +CREATE TEMPORARY VIEW t1 AS SELECT * FROM VALUES
       (1, 2, 3)
    -as t1(t1a, t1b, t1c);
    +AS t1(t1a, t1b, t1c);
     
    -create temporary view t2 as select * from values
    +CREATE TEMPORARY VIEW t2 AS SELECT * FROM VALUES
       (1, 0, 1)
    -as t2(t2a, t2b, t2c);
    +AS t2(t2a, t2b, t2c);
     
    -create temporary view t3 as select * from values
    +CREATE TEMPORARY VIEW t3 AS SELECT * FROM VALUES
       (3, 1, 2)
    -as t3(t3a, t3b, t3c);
    +AS t3(t3a, t3b, t3c);
     
     -- TC 01.01
     -- The column t2b in the SELECT of the subquery is invalid
     -- because it is neither an aggregate function nor a GROUP BY column.
    -select t1a, t2b
    -from   t1, t2
    -where  t1b = t2c
    -and    t2b = (select max(avg)
    -              from   (select   t2b, avg(t2b) avg
    -                      from     t2
    -                      where    t2a = t1.t1b
    +SELECT t1a, t2b
    +FROM   t1, t2
    +WHERE  t1b = t2c
    +AND    t2b = (SELECT max(avg)
    +              FROM   (SELECT   t2b, avg(t2b) avg
    +                      FROM     t2
    +                      WHERE    t2a = t1.t1b
                          )
                  )
     ;
     
     -- TC 01.02
     -- Invalid due to the column t2b not part of the output from table t2.
    -select *
    -from   t1
    -where  t1a in (select   min(t2a)
    -               from     t2
    -               group by t2c
    -               having   t2c in (select   max(t3c)
    -                                from     t3
    -                                group by t3b
    -                                having   t3b > t2b ))
    +SELECT *
    +FROM   t1
    +WHERE  t1a in (SELECT   min(t2a)
    +               FROM     t2
    +               GROUP by t2c
    --- End diff --
    
    Nit: `by` -> `BY`


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