-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When I try to refactor the planner having, I find the having planner is wrong.
1147 line in planner.rs
// This step "dereferences" any aliases in the HAVING clause.In fact, having can't access the projection alias (because having is before the select).
having is just filter group results, it can't get alias in projection.
for example:
-- create
CREATE TABLE EMPLOYEE (
empId INTEGER PRIMARY KEY,
name TEXT NOT NULL,
dept TEXT NOT NULL
);
-- insert
INSERT INTO EMPLOYEE VALUES (0001, 'Clark', 'Sales');
-- fetch
select empId, length(name) as l FROM EMPLOYEE group by empId having l > 10;
psql:commands.sql:15: ERROR: column "l" does not exist
LINE 1: ...ength(name) as l FROM EMPLOYEE group by empId having l > 10;To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working