[ 
https://issues.apache.org/jira/browse/ASTERIXDB-1560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15404685#comment-15404685
 ] 

Yingyi Bu commented on ASTERIXDB-1560:
--------------------------------------

[~dtabass],  here is why we get this error message:

SELECT u.name AS uname, m.message AS message
FROM GleambookUsers u
UNNEST GleambookMessages m
WHERE m.authorId = user.id;

Since the symbol "user" is not defined, the compiler tries to resolve "user" as 
abbreviatory field accesses (since we support implicit variable references 
similar to SQL-92).   Since the type of GleambookUsers and GleambookMessages 
are open, "user" could potentially be a field of records from either dataset:

Possibility 1:
SELECT u.name AS uname, m.message AS message
FROM GleambookUsers u
UNNEST GleambookMessages m
WHERE m.authorId = u.user.id;

Possibility 2:
SELECT u.name AS uname, m.message AS message
FROM GleambookUsers u
UNNEST GleambookMessages m
WHERE m.authorId = m.user.id;

Therefore, it complains that there could ambiguous alias reference for "user", 
i.e.:
u.user or m.user

Best,
Yingyi

> Misleading SQL++ error message when variables are  undefined
> ------------------------------------------------------------
>
>                 Key: ASTERIXDB-1560
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1560
>             Project: Apache AsterixDB
>          Issue Type: Bug
>          Components: AsterixDB, Error Reporting
>            Reporter: Michael J. Carey
>            Assignee: Yingyi Bu
>            Priority: Minor
>
> This query:
>     SELECT u.name AS uname, m.message AS message
>     FROM GleambookUsers u
>     UNNEST GleambookMessages m
>     WHERE m.authorId = user.id;
> Yields this error message:
>     Cannot resolve ambiguous alias (variable) reference for identifier user 
> [AlgebricksException]
> The reference is undefined, not ambiguous, in this case.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to