Support Questions
Find answers, ask questions, and share your expertise

SemanticException End of a WindowFrame cannot be UNBOUNDED PRECEDING

New Contributor

I am using HDP 2.6.3.0-235.

I am running the following query:

create table employee_contract(
    name string,
    dept_num int,
    salary int
);


SELECT name, dept_num, salary,
MAX(salary) OVER (PARTITION BY dept_num ORDER BY 
name ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) win1
FROM employee_contract;

This give the "SemanticException End of a WindowFrame cannot be UNBOUNDED PRECEDING" error message.

But the hive documentation states that the end of a window can be unbounded.

Also there was a jira issue raised about it.

2 REPLIES 2

New Contributor

@Vibhor Gupta Hive doesn't support ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING only ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.

,

@Vibhor Gupta The problem with this query is that ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING does not work in HIVE. You can only use ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. You can combine it then with some case statement to get max of all preceding

New Contributor

Thank you @Srdan Kotus for your response.