Presto Administration : Presto Server Administration : Upgrade to New Versions of Presto and Migrate Artifacts : Migrate Mashups That Use RAQL for 3.7 : Updates for Alias References in Select Clauses
Updates for Alias References in Select Clauses
In the previous release, you could define column aliases in the Select clause and refer to that alias in subsequent column definitions within that same clause. For example:
select symbol, open, close, (open + close) as expr1,
(expr1 / 2) as expr2 , (expr2 * 100) as expr3
from stocks
The definitions of the expr2 and expr3 columns use references to the expr1 and expr2 columns that are aliases defined earlier in this same Select clause.
This is not legal for SQL and is no longer supported in RAQL. If you have alias references within the same Select clause where the alias is defined, you must correct the query.
There are two methods to correct this syntax:
*Replace the illegal reference to the alias with an exact duplicate of the expression for this alias. From the previous example, this would change the query to:
select symbol, open, close, (open + close) as expr1,
((open + close)/2) as expr2,
(((open + close)/2) * 100) as expr3
from stocks
*Use subqueries to define the alias in an earlier step.
So another option for the previous example would be:
select symbol, open, close, expr1, expr2, (expr2 * 100) as expr3
from (
select symbol, open, close, expr1, (expr1 / 2) as expr2
from (
select symbol, open, close, (open + close) as expr1
from stocks
)
)
Copyright © 2006-2015 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback