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

Adding grouping hint breaks the query

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      The following query works fine with no hint. Adding a hint to use hash-based group-by breaks it with the following error:

      Variable $$43 could not be found in any input schema. [AlgebricksException]
      

      Here is the query:

      let $customer := {{ {"cid" : 1}, {"cid" : 2} }}
      
      let $orders := {{ 
      	{"oid": 100, 
      	"ocid" : 1, 
      	"priority" : 10,
      	 "class" : "A",
      	 "items" : [{"price" : 1000}, { "price" : 2000}]
      	},
      	{"oid": 200, 
      	"ocid" : 2, 
      	"priority" : 20,
      	 "class" : "A",
      	 "items" : [{"price" : 2000}, {"price" : 3000}]
      	}
      }}
      
      for $c in $customer
      for $o in $orders
      where
        $c.cid = $o.ocid 
      for $i in $o.items
      /*+ hash*/
      group by $o_orderid := $o.oid, $o_class := $o.class, $o_priority := $o.priority
        with $i
      let $price := sum (
        for $t in $i 
        return 
          $t.price
      )
      order by $price desc, $o_class
      return {  
        "o_orderkey": $o_orderid,
        "price": $price,
        "o_class": $o_class,
        "o_priority": $o_priority 
      }
      

      Attachments

        Activity

          People

            wangsaeu Taewoo Kim
            pouria Pouria Pirzadeh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: