Xikui Wang created ASTERIXDB-2412:
-------------------------------------

             Summary: Extract common expr should not be applied to JOIN
                 Key: ASTERIXDB-2412
                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-2412
             Project: Apache AsterixDB
          Issue Type: Bug
            Reporter: Xikui Wang


{code}
drop dataverse Coffee if exists;
create dataverse Coffee;
use Coffee;


create type CoffeeType as {
    id: string,
    location: point
};

create type FollowersType as {
    user_id: string,
    twitter_id: string,
    followers: [string]
};

create dataset Coffee(CoffeeType)
    primary key id;

create dataset Followers(FollowersType)
    primary key user_id;


create type CoffeeUser as closed {
    id: int64,
    id_str: string
};

create type Tweet as open {
    id: int64,
    user: CoffeeUser,
    timestamp_ms: string
};

create dataset Tweets (Tweet)
primary key id;


select * from Tweets t
let followers = (select * from Tweets f where 
spatial_intersect(create_circle(create_point(f.place.bounding_box.coordinates[0][0][0],f.place.bounding_box.coordinates[0][0][1]),5.0),
create_circle(create_point(t.place.bounding_box.coordinates[0][0][0],t.place.bounding_box.coordinates[0][0][1]),5.0))),
sb = (select value s.location from Coffee s where 
spatial_intersect(create_circle(create_point(t.place.bounding_box.coordinates[0][0][0],t.place.bounding_box.coordinates[0][0][1]),5.0),s.location));
{code}

The above query wouldn't work as the ExtractCommonExpressionsRule extracts the 
common exprs in the two LeftOutterJoin operators and pulls the join condition 
in the second op. Let alone this is wrong for the LOJ case, the cost for adding 
cartesian product is much higher than evaluating the same expr. twice. This 
should be fixed.



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

Reply via email to