StarRocks / starrocks

The world's fastest open query engine for sub-second analytics both on and off the data lakehouse. With the flexibility to support nearly any scenario, StarRocks provides best-in-class performance for multi-dimensional analytics, real-time analytics, and ad-hoc queries. A Linux Foundation project.
https://starrocks.io
Apache License 2.0
9k stars 1.81k forks source link

Support for lateral column alias reference #41044

Open miguelgilmartinez opened 9 months ago

miguelgilmartinez commented 9 months ago

Feature request

Feature description

Allow SELECT queries to reference a previous column alias within the running query on the following columns.

SELECT 1 AS one, 2 AS two, one + two AS three;

Would return:

one two three
1   2   3   

Some databases with this feature:

murphyatwork commented 8 months ago

Thanks @miguelgilmartinez , that's a good proposal to simplify the SQL.

Until 3.2 StarRocks doesn't support this feature, but you can get a workaround through the subquery, like select one + two as three from (select 1 as one, 2 as two) t.

We would consider make it a general solution in the future.

github-actions[bot] commented 2 months ago

We have marked this issue as stale because it has been inactive for 6 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to StarRocks!

kzk2000 commented 2 months ago

Not stale at all - still highly relevant I believe…