[ 
https://issues.apache.org/jira/browse/ASTERIXDB-1727?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

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

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

Here is the query:
{noformat}
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 
}
{noformat}

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

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

Here is the query:
{noformat}
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 
}
{noformat}


> Adding grouping hint breaks the query
> -------------------------------------
>
>                 Key: ASTERIXDB-1727
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1727
>             Project: Apache AsterixDB
>          Issue Type: Bug
>            Reporter: Pouria
>            Assignee: Yingyi Bu
>
> The following query works fine with no hint. Adding a hint to use hash-based 
> group-by breaks it with the following error:
> {noformat}
> Variable $$43 could not be found in any input schema. [AlgebricksException]
> {noformat}
> Here is the query:
> {noformat}
> 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 
> }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to