AngersZhuuuu opened a new pull request #33892:
URL: https://github.com/apache/spark/pull/33892


   ### What changes were proposed in this pull request?
   For case 
   ```
   CREATE TABLE employees 
   (name STRING, dept STRING, salary INT, age INT);
   
   SELECT AVG(age) OVER win AS salary, 
   AVG(salary) OVER win AS avgsalary,
   MIN(salary) OVER win AS minsalary,
   MAX(salary) OVER win AS maxsalary,
   COUNT(1) OVER win AS numEmps
   FROM employees;
   ```
   Project convert to GlobalAggregate but it use a undefined window spec, the 
origin error message is bad
   ```
   
   Error in query: unresolved operator 'Aggregate 
[unresolvedwindowexpression(avg(age#43), WindowSpecReference(win)) AS 
salary#34, unresolvedwindowexpression(avg(salary#42), WindowSpecReference(win)) 
AS avgsalary#35, unresolvedwindowexpression(min(salary#42), 
WindowSpecReference(win)) AS minsalary#36, 
unresolvedwindowexpression(max(salary#42), WindowSpecReference(win)) AS 
maxsalary#37, unresolvedwindowexpression(count(1), WindowSpecReference(win)) AS 
numEmps#38];
   'Aggregate [unresolvedwindowexpression(avg(age#43), 
WindowSpecReference(win)) AS salary#34, 
unresolvedwindowexpression(avg(salary#42), WindowSpecReference(win)) AS 
avgsalary#35, unresolvedwindowexpression(min(salary#42), 
WindowSpecReference(win)) AS minsalary#36, 
unresolvedwindowexpression(max(salary#42), WindowSpecReference(win)) AS 
maxsalary#37, unresolvedwindowexpression(count(1), WindowSpecReference(win)) AS 
numEmps#38]
   +- SubqueryAlias spark_catalog.default.employees
   +- HiveTableRelation [`default`.`employees`, 
org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, Data Cols: [name#40, 
dept#41, salary#42, age#43], Partition Cols: []]
   ```
   Here we should throw error message of undefined window such as 
   ```
   Window specification w is not defined in the WINDOW clause.
   ```
   
   ### Why are the changes needed?
   Better error message
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   
   ### How was this patch tested?
   Added UT
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to