asterixdb-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Malarout, Namrata (398M-Affiliate)" <Namrata.Malar...@jpl.nasa.gov>
Subject Re: Aggregate function on collection of ordered list
Date Mon, 07 Dec 2015 17:57:20 GMT
Hi,

Wail, thanks for looking into it and explaining the use of for. I will be following the issue.
However, working with my sample data  may be a little more tricky. I have a couple hundred
of records which contain such nested ordered lists. I would like to perform an aggregation
over all the values across all the records. Any suggestions on how to do it?

Mike, thanks for understanding :) Appreciate all the help.
-Namrata

From: Michael Carey <mjcarey@ics.uci.edu<mailto:mjcarey@ics.uci.edu>>
Reply-To: "users@asterixdb.incubator.apache.org<mailto:users@asterixdb.incubator.apache.org>"
<users@asterixdb.incubator.apache.org<mailto:users@asterixdb.incubator.apache.org>>
Date: Monday, December 7, 2015 at 7:28 AM
To: "users@asterixdb.incubator.apache.org<mailto:users@asterixdb.incubator.apache.org>"
<users@asterixdb.incubator.apache.org<mailto:users@asterixdb.incubator.apache.org>>,
"dev@asterixdb.incubator.apache.org<mailto:dev@asterixdb.incubator.apache.org>" <dev@asterixdb.incubator.apache.org<mailto:dev@asterixdb.incubator.apache.org>>
Subject: Re: Aggregate function on collection of ordered list

+ Looping in the dev list to try and get fast attention to the fix, if it's easy!
(I know that Namarata's under time pressure in a NASA bakeoff exercise. :-))

On 12/7/15 4:59 AM, Wail Alkowaileet wrote:
It's an easy fix...
Thanks for reporting that.

I reported it in https://issues.apache.org/jira/browse/ASTERIXDB-1216

On Mon, Dec 7, 2015 at 3:33 PM, Wail Alkowaileet <wael.y.k@gmail.com<mailto:wael.y.k@gmail.com>>
wrote:
Hi Namrata,

The best way to think of for in lists is to think it works as foreach in java.
So ..
in your first query, it should be like:

let $l := [[1.2, 2.3, 3.4],[6,3,7,2]]
for $x in $l // for each list in the outer list
return {"avg”: avg($y)}

However, I tried it and it seems that there is a bug for applying aggregation on nested open
field.

I'll look into it to see if it's an easy fix



On Mon, Dec 7, 2015 at 2:52 PM, Malarout, Namrata (398M-Affiliate) <Namrata.Malarout@jpl.nasa.gov<mailto:Namrata.Malarout@jpl.nasa.gov>>
wrote:
Hi,

I am trying to perform avg, sum, min and max functions on a collection of ordered lists. An
example is:
 let $l := [[1.2, 2.3, 3.4],[6,3,7,2]]

return {"avg”: avg($l)}

I have tried both avg and sql-avg. But I get the following error:
 Cannot compute AVG for values of type ORDEREDLIST [NotImplementedException].

I’ve attached the sample data that I’m working with (sample.adm). My AQL query to find
the average of analysis_error looks like:


use dataverse Test;

for $f in dataset sample

where not(is-null($f.analysis_error))

return avg($f.analysis_error);

The error seen is as follows:

Type of argument in function-call: asterix:avg, Args:[function-call: asterix:field-access-by-name,
Args:[%0->$$0, AString: {analysis_error}]] should be a collection type instead of ANY [AlgebricksException]


I would like to know what is the correct syntax to find the average. Appreciate the help.

Thanks,

Namrata






--

Regards,
Wail Alkowaileet



--

Regards,
Wail Alkowaileet


Mime
View raw message