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

Can not infer type for variable exception when execute nest group by query

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: COMP - Compiler
    • Labels:
      None

      Description

      Hi,

      We can use the TinySocial dataset as an example.

      for $t in dataset TweetMessages
      group by $d:= get-hour($t.send-time) with $t
      return { "hour": $d,  "count": count($t),
      "finer":  for $k in $t 
                     group by $min:= get-minute($k.create_at) with $k
                      order by $min 
                      return {  "minute": $min, "sum": count($k)}
      }
      

      The optimizer won't compile it and throw the following exception:

      SEVERE: Could not infer type for variable '$$19'.
      592110 org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Could not infer type for variable '$$19'.
      592111   at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.visitVariableReferenceExpression(SetClosedRecordConstructorsRule.java:       173)
      592112   at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.visitVariableReferenceExpression(SetClosedRecordConstructorsRule.java:       79)
      592113   at org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression.accept(VariableReferenceExpression.java:102)
      592114   at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule$SettingClosedRecordVisitor.transform(SetClosedRecordConstructorsRule.java:93)
      592115   at org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator.acceptExpressionTransform(GroupByOperator.java:214)
      592116   at org.apache.asterix.optimizer.rules.SetClosedRecordConstructorsRule.rewritePost(SetClosedRecordConstructorsRule.java:72)
      592117   at org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:125)
      592118   at org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:99)
      592119   at org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:99)
      592120   at org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:99)
      592121   at org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController.rewriteOperatorRef(AbstractRuleController.java:99)
      592122   at org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialFixpointRuleController.rewriteWithRuleCollection(SequentialFixpointRuleController.java:53)
      592123   at org.apache.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.runOptimizationSets(HeuristicOptimizer.java:95)
      592124   at org.apache.hyracks.algebricks.core.rewriter.base.HeuristicOptimizer.optimize(HeuristicOptimizer.java:82)
      592125   at org.apache.hyracks.algebricks.compiler.api.HeuristicCompilerFactoryBuilder$1$1.optimize(HeuristicCompilerFactoryBuilder.java:87)
      592126   at org.apache.asterix.api.common.APIFramework.compileQuery(APIFramework.java:289)
      592127   at org.apache.asterix.aql.translator.QueryTranslator.rewriteCompileQuery(QueryTranslator.java:1896)
      592128   at org.apache.asterix.aql.translator.QueryTranslator.handleQuery(QueryTranslator.java:2470)
      592129   at org.apache.asterix.aql.translator.QueryTranslator.compileAndExecute(QueryTranslator.java:384)
      592130   at org.apache.asterix.api.http.servlet.APIServlet.doPost(APIServlet.java:148)
      

        Attachments

          Activity

            People

            • Assignee:
              buyingyi Yingyi Bu
              Reporter:
              javierjia Jianfeng Jia
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: