Uploaded image for project: 'Apache AsterixDB'
  1. Apache AsterixDB
  2. ASTERIXDB-2437

Index-only plan cannot be generated for a composite index if both fields are used and only one field is returned.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When there is a composite index,  if both fields are used in the select condition and only one field is returned, the compiler generates an exception.

       

      DDL and query:

      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;
      
      create index create_at_status_count_idx on ds_tweet(user.create_at, user.statues_count);
      
      select value count(first.create_at) from (
      select t.user.create_at, t.user.statues_count, t.id from ds_tweet t
      where
            t.user.create_at   >=
            date_from_unix_time_in_days(10000) and
            t.user.create_at   <
            date_from_unix_time_in_days(12000) and
                t.user.statues_count  >= 0 and
                t.user.statues_count  <  1000000
      ) first;
      

       

      Exception:

      org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Could not infer type for variable '$$57'.
      at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.visitVariableReferenceExpression(SetClosedRecordConstructorsRule.java:170) ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
      at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.visitVariableReferenceExpression(SetClosedRecordConstructorsRule.java:77) ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
      at org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression.accept(VariableReferenceExpression.java:93) ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
      at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.visitFunctionCallExpression(SetClosedRecordConstructorsRule.java:150) ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
      at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.visitFunctionCallExpression(SetClosedRecordConstructorsRule.java:77) ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
      at org.apache.hyracks.algebricks.core.algebra.visitors.AbstractConstVarFunVisitor.visitScalarFunctionCallExpression(AbstractConstVarFunVisitor.java:39) ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
      at org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression.accept(ScalarFunctionCallExpression.java:55) ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
      at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.visitFunctionCallExpression(SetClosedRecordConstructorsRule.java:150) ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
      at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.visitFunctionCallExpression(SetClosedRecordConstructorsRule.java:77) ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
      at org.apache.hyracks.algebricks.core.algebra.visitors.AbstractConstVarFunVisitor.visitScalarFunctionCallExpression(AbstractConstVarFunVisitor.java:39) ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
      at org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression.accept(ScalarFunctionCallExpression.java:55) ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
      at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.transform(SetClosedRecordConstructorsRule.java:91) ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]
      at org.apache.hyracks.algebricks.core.algebra.operators.logical.SelectOperator.acceptExpressionTransform(SelectOperator.java:83) ~[algebricks-core-0.3.4-SNAPSHOT.jar:0.3.4-SNAPSHOT]
      at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule.rewritePost(SetClosedRecordConstructorsRule.java:70) ~[asterix-algebra-0.9.4-SNAPSHOT.jar:0.9.4-SNAPSHOT]

       

       

       

        Attachments

          Activity

            People

            • Assignee:
              wangsaeu Taewoo Kim
              Reporter:
              wangsaeu Taewoo Kim
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: