You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Comment from Jorge Leitão(jorgecarleitao) @ 2020-10-23T06:03:45.335+0000:
Could you describe what is the use-case? E.g. in which situation does that improve readability over the having the column name, or in which case does the column name not work?
Comment from Pavel Tiunov(paveltiunov) @ 2020-10-23T06:41:53.205+0000:
Hey [~jorgecarleitao]! Thanks for the quick turnaround. The use case is usually to support grouping by complex expressions. For example
{code:java}
SELECT date_trunc(convert_tz(`page_views__time_hour`, 'America/Los_Angeles'), 'week') `page_views__time_week`, sum(`page_views__count`) `page_views__count` FROM page_views GROUP BY date_trunc(convert_tz(`page_views__time_hour`, 'America/Los_Angeles'), 'week') LIMIT 10000
{code}
becomes
{code:java}
SELECT date_trunc(convert_tz(`page_views__time_hour`, 'America/Los_Angeles'), 'week') `page_views__time_week`, sum(`page_views__count`) `page_views__count` FROM page_views GROUP BY 1 LIMIT 10000
{code}
Calculated columns can be pretty complex and it usually just bloats up the SQL significantly. I believe it's beneficial to have this feature as most of the modern query engines have it.
Comment from Jorge Leitão(jorgecarleitao) @ 2020-10-23T08:00:39.544+0000:
Thanks for the example, [~paveltiunov] . makes sense
Meanwhile, I think that you can use <{{expression> AS name}} and {{GROUP BY name}} .
Activity
alamb commentedon Apr 26, 2021
Comment from Jorge Leitão(jorgecarleitao) @ 2020-10-23T06:03:45.335+0000:
Comment from Pavel Tiunov(paveltiunov) @ 2020-10-23T06:41:53.205+0000:
Hey [~jorgecarleitao]! Thanks for the quick turnaround. The use case is usually to support grouping by complex expressions. For example {code:java} SELECT date_trunc(convert_tz(`page_views__time_hour`, 'America/Los_Angeles'), 'week') `page_views__time_week`, sum(`page_views__count`) `page_views__count` FROM page_views GROUP BY date_trunc(convert_tz(`page_views__time_hour`, 'America/Los_Angeles'), 'week') LIMIT 10000 {code} becomes {code:java} SELECT date_trunc(convert_tz(`page_views__time_hour`, 'America/Los_Angeles'), 'week') `page_views__time_week`, sum(`page_views__count`) `page_views__count` FROM page_views GROUP BY 1 LIMIT 10000 {code} Calculated columns can be pretty complex and it usually just bloats up the SQL significantly. I believe it's beneficial to have this feature as most of the modern query engines have it.Comment from Jorge Leitão(jorgecarleitao) @ 2020-10-23T08:00:39.544+0000:
Thanks for the example, [~paveltiunov] . makes sense Meanwhile, I think that you can use <{{expression> AS name}} and {{GROUP BY name}} .jychen7 commentedon Apr 28, 2021
I was trying to fix it, then find out actually
expression AS name, GROUP BY namewill raise errorso I create #215 and try to fix #215 first
alamb commentedon Apr 28, 2021
Thanks @jychen7
feat: Add license header by spotless:apply automatically (apache#110)