Taewoo Kim created ASTERIXDB-2296:
-------------------------------------

             Summary: 
AbstractIntroduceAccessMethodRule.getFieldNameFromSubTree() cannot handle 
AUnionType
                 Key: ASTERIXDB-2296
                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-2296
             Project: Apache AsterixDB
          Issue Type: Bug
            Reporter: Taewoo Kim


DDL
{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":134217728, 
"max-tolerance-component-count":10}
  }
};

create index text_idx if not exists on ds_tweet(text) type fulltext;
{code}
The following SQL++ query doesn't work based on the above DDL. This is because 
"place" is an optional field so that its type if AUnionType that contains 
ARecordType, not ARecordType itself.
{code:java}
select t.`place`.`bounding_box` as `place.bounding_box`,t.`user`.`id` as 
`user.id`,t.`id` as `id`,
t.`coordinate` as `coordinate`,t.`create_at` as `create_at`
from twitter.ds_tweet t
where t.`create_at` >= datetime('2018-02-22T10:53:07.888Z') and t.`create_at` < 
datetime('2018-02-22T18:50:39.301Z')
and ftcontains(t.`text`, ['francisco'], {'mode':'all'}) and 
t.`geo_tag`.`stateID` in [ 37,51,24,11 ]
order by t.`create_at` desc
limit 2147483647
offset 0;
{code}
An exception:
{code:java}
11:23:01.827 [QueryTranslator] INFO 
org.apache.asterix.app.translator.QueryTranslator - 
org.apache.asterix.om.types.AUnionType cannot be cast to 
org.apache.asterix.om.types.ARecordType
java.lang.ClassCastException: org.apache.asterix.om.types.AUnionType cannot be 
cast to org.apache.asterix.om.types.ARecordType
at 
org.apache.asterix.optimizer.rules.am.AbstractIntroduceAccessMethodRule.getFieldNameFromSubTree(AbstractIntroduceAccessMethodRule.java:877)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.AbstractIntroduceAccessMethodRule.fillFieldNamesInTheSubTree(AbstractIntroduceAccessMethodRule.java:973)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:412)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:327)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:327)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:327)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:327)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:327)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:327)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:327)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.checkAndApplyTheSelectTransformation(IntroduceSelectAccessMethodRule.java:327)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.optimizer.rules.am.IntroduceSelectAccessMethodRule.rewritePre(IntroduceSelectAccessMethodRule.java:167)
 ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:91)
 ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at 
org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialFixpointRuleController.rewriteWithRuleCollection(SequentialFixpointRuleController.java:53)
 ~[algebricks-compiler-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at 
org.apache.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.runOptimizationSets(HeuristicOptimizer.java:102)
 ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at 
org.apache.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.optimize(HeuristicOptimizer.java:82)
 ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at 
org.apache.hyracks.algebricks.compiler.api.HeuristicCompilerFactoryBuilder$1$1.optimize(HeuristicCompilerFactoryBuilder.java:90)
 ~[algebricks-compiler-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at 
org.apache.asterix.api.common.APIFramework.compileQuery(APIFramework.java:269) 
~[asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.app.translator.QueryTranslator.rewriteCompileQuery(QueryTranslator.java:1897)
 ~[asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.app.translator.QueryTranslator.lambda$handleQuery$20(QueryTranslator.java:2373)
 [asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.app.translator.QueryTranslator$$Lambda$141/916493385.compile(Unknown
 Source) [asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.app.translator.QueryTranslator.createAndRunJob(QueryTranslator.java:2496)
 [asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.app.translator.QueryTranslator.deliverResult(QueryTranslator.java:2406)
 [asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.app.translator.QueryTranslator.handleQuery(QueryTranslator.java:2385)
 [asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.asterix.app.translator.QueryTranslator.compileAndExecute(QueryTranslator.java:381)
 [asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at org.apache.asterix.api.http.server.ApiServlet.post(ApiServlet.java:168) 
[asterix-app-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
at 
org.apache.hyracks.http.server.AbstractServlet.handle(AbstractServlet.java:92) 
[hyracks-http-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at 
org.apache.hyracks.http.server.HttpRequestHandler.handle(HttpRequestHandler.java:71)
 [hyracks-http-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at 
org.apache.hyracks.http.server.HttpRequestHandler.call(HttpRequestHandler.java:56)
 [hyracks-http-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at 
org.apache.hyracks.http.server.HttpRequestHandler.call(HttpRequestHandler.java:37)
 [hyracks-http-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
[?:1.8.0]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
[?:1.8.0]
at java.lang.Thread.run(Thread.java:744) [?:1.8.0]{code}
 



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

Reply via email to