pdeva opened a new issue #7584: Cant refer to variables declared inside sql statements for post aggregations URL: https://github.com/apache/incubator-druid/issues/7584 ### Affected Version 0.14.0-iap4 ### Description I am trying to use fields declared using `AS` to perform postaggregations. In this example I declare `memTotal` and `memUsed` and try to use it to calculate `pct` However this *does not* work: ```sql SELECT "cluster", sum ("mem_limit") as memTotal, sum ("mem_used") as memUsed, (memUsed*100.0/memTotal) as pct /*this causes problems*/ FROM "metrics" WHERE "__time" >= TIMESTAMP '2019-04-30 20:17:46' AND "__time" < TIMESTAMP '2019-04-30 20:17:48' group by "cluster" ``` resulting in exception: ``` Bad Request: Unknown exception: org.apache.calcite.runtime.CalciteContextException: From line xxx: Column 'memUsed' not found in any table ``` Instead I need to repeat the `sum ("mem_used")` everywhere... So this works, but i with redundant code for `memTotal` and `memUsed` for `pct` ```sql SELECT "cluster", sum ("mem_limit") as memTotal, sum ("mem_used") as memUsed, (sum ("mem_used")*100.0/sum ("mem_limit")) as pct /*need to repeat sum calculation here*/ FROM "metrics" WHERE "__time" >= TIMESTAMP '2019-04-30 20:17:46' AND "__time" < TIMESTAMP '2019-04-30 20:17:48' group by "cluster" ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
