[ 
https://issues.apache.org/jira/browse/SPARK-28506?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17240703#comment-17240703
 ] 

Takeshi Yamamuro commented on SPARK-28506:
------------------------------------------

I've checked both systems cannot accept the query above;
{code:java}
postgres=# CREATE TABLE empsalary (
postgres(#     depname text,
postgres(#     empno integer,
postgres(#     salary int,
postgres(#     enroll_date date
postgres(# );
postgres=# SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 1;
ERROR:  window functions are not allowed in GROUP BY
LINE 1: SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GRO...

scala> sql("SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 
1;").show()
org.apache.spark.sql.AnalysisException:
The query operator `Aggregate` contains one or more unsupported
expression types Aggregate, Window or Generate.
Invalid expressions: [RANK() OVER (ORDER BY 1 ASC NULLS FIRST ROWS BETWEEN 
UNBOUNDED PRECEDING AND CURRENT ROW)];;
Project [RANK() OVER (ORDER BY 1 ASC NULLS FIRST ROWS BETWEEN UNBOUNDED 
PRECEDING AND CURRENT ROW)#19, count(1)#20L]
+- Project [count(1)#20L, RANK() OVER (ORDER BY 1 ASC NULLS FIRST ROWS BETWEEN 
UNBOUNDED PRECEDING AND CURRENT ROW)#19, RANK() OVER (ORDER BY 1 ASC NULLS 
FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)#19]
... {code}

> not handling usage of group function and window function at some conditions
> ---------------------------------------------------------------------------
>
>                 Key: SPARK-28506
>                 URL: https://issues.apache.org/jira/browse/SPARK-28506
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 3.1.0
>            Reporter: Dylan Guedes
>            Priority: Major
>
> Hi,
> looks like SparkSQL is not able to handle this query:
> {code:sql}SELECT rank() OVER (ORDER BY 1), count(*) FROM empsalary GROUP BY 
> 1;{code}
> PgSQL, on the other hand, does.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to