Skip to content

ALIAS hides the original column name in CASE with a window function #6769

@javier

Description

@javier

To reproduce

Go to demo and run this query (it works):

select timestamp, price as p,
case when price > 1  then price
 when price < 1  then -p
 END
 from fx_trades;

As you can see, I can reference the price column either by the original name or by the p alias inside the WHEN statements. All good

Now, let's add a window function inside the WHEN and try to use the unaliased price name. Oh, no! invalid column: price

select timestamp, price as p,
case when price > lag(price) OVER (ORDER BY timestamp) then price
 END
 from fx_trades;

But I can still reference the column by the p alias.

 select timestamp, price as p,
case when price > lag(price) OVER (ORDER BY timestamp) then p
 END
 from fx_trades;

This looks like a bug to me

QuestDB version:

9.3.2

OS, in case of Docker specify Docker and the Host OS:

Public questdb demo box

File System, in case of Docker specify Host File System:

ext4

Full Name:

Javier Ramirez

Affiliation:

QuestDB

Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?

  • Yes, I have

Additional context

No response

Metadata

Metadata

Assignees

Labels

BugIncorrect or unexpected behaviorSQLIssues or changes relating to SQL execution

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions