You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Dmitry Lychagin (JIRA)" <ji...@apache.org> on 2018/05/22 18:40:00 UTC

[jira] [Commented] (ASTERIXDB-2390) Cannot resolve ambiguous alias reference

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

Dmitry Lychagin commented on ASTERIXDB-2390:
--------------------------------------------

This works as designed.

't' is not in scope after the GROUP BY that's why the first query fails.

the second query works because group by expression can be used as is in the select clause: SELETT x+y GROUP BY x+y, even if 'x' and 'y' are out of scope after the GROUP BY.  

For more information see appendix_3_resolution.md in [https://asterix-gerrit.ics.uci.edu/#/c/2653/]   

 

 

> Cannot resolve ambiguous alias reference
> ----------------------------------------
>
>                 Key: ASTERIXDB-2390
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-2390
>             Project: Apache AsterixDB
>          Issue Type: Bug
>            Reporter: Taewoo Kim
>            Priority: Major
>
> The following query generates a CompilationException.
> {code:java}
> drop dataverse twitter if exists;
> create dataverse twitter if not exists;
> use twitter;
> create type typeUser if not exists as open {
> id: int64,
> name: string,
> screen_name : string,
> profile_image_url : string,
> lang : string,
> location: string,
> create_at: date,
> description: string,
> followers_count: int32,
> friends_count: int32,
> statues_count: int64
> };
> create type typePlace if not exists as open{
> country : string,
> country_code : string,
> full_name : string,
> id : string,
> name : string,
> place_type : string,
> bounding_box : rectangle
> };
> create type typeGeoTag if not exists as open {
> stateID: int32,
> stateName: string,
> countyID: int32,
> countyName: string,
> cityID: int32?,
> cityName: string?
> };
> create type typeTweet if not exists as open {
> create_at : datetime,
> id: int64,
> text: string,
> in_reply_to_status : int64,
> in_reply_to_user : int64,
> favorite_count : int64,
> coordinate: point?,
> retweet_count : int64,
> lang : string,
> is_retweet: boolean,
> hashtags : {{ string }} ?,
> user_mentions : {{ int64 }} ? ,
> user : typeUser,
> place : typePlace?,
> geo_tag: typeGeoTag
> };
> create dataset ds_tweet(typeTweet) if not exists primary key id with filter on create_at with {"merge-policy":{"name":"prefix","parameters":{"max-mergable-component-size":536870912, "max-tolerance-component-count":5}}};
> create index text_idx if not exists on ds_tweet(text) type fulltext;{code}
>  
> Query:
> {code:java}
> USE twitter;
> SELECT spatial_cell(get_points(t.place.bounding_box)[0], create_point(0.0,0.0),1.0,1.0) AS cell, count(*) AS cnt FROM ds_tweet t
> WHERE ftcontains(t.text, ['rain'], {'mode':'any'}) AND t.place.bounding_box IS NOT unknown 
> AND t.create_at >= datetime('2017-02-25T00:00:00') AND t.create_at < datetime('2017-02-26T00:00:00') 
> GROUP BY cell;{code}
>  
> Exception:
> {code:java}
> Cannot resolve ambiguous alias reference for undefined identifier t in [#1, $cell] [CompilationException]
> {code}
>  
> The same query that doesn't generate an exception:
> {code:java}
> USE twitter;
> SELECT spatial_cell(get_points(t.place.bounding_box)[0], create_point(0.0,0.0),1.0,1.0), count(*) AS cnt FROM ds_tweet t
> WHERE ftcontains(t.text, ['rain'], {'mode':'any'}) AND t.place.bounding_box IS NOT unknown 
> AND t.create_at >= datetime('2017-02-25T00:00:00') AND t.create_at < datetime('2017-02-26T00:00:00') 
> GROUP BY spatial_cell(get_points(t.place.bounding_box)[0], create_point(0.0,0.0),1.0,1.0);
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)