cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DuyHai Doan <doanduy...@gmail.com>
Subject Re: UDF/UDA for json data aggregation
Date Wed, 16 Nov 2016 22:08:06 GMT
"Can we do something like this" --> Yes but requires a lot of coding

"can we import java classes from thirdparty jars for parsing/updating json
in UDF defined" --> No because the reasoning behind this limitation is: IF
you need to import third-party jars for your UDF/UDA, it means that the
computation is quite complex and consequently it may be a bad idea to
execute complex processing server-side.

On Wed, Nov 16, 2016 at 10:16 PM, techpyaasa . <techpyaasa@gmail.com> wrote:

> Hi all,
>
> Like to use UDF/UDA in c*-2.2 & above to aggregate attibutes values in a
> json data.
>
> For example below table.
>
>
> *"CREATE  TABLE test ( id bigint , time1 bigint , jsonData text , PRIMARY
> KEY(id,time1));*
>
>
>
> *cqlsh:test> INSERT INTO test (id , time1 , jsonData ) VALUES ( 1, 123,
> '{"node1":{"attr1":"91","attr2":"1","attr3":"333"},"node2":{"attr4":"1.01","attr5":"1.231","attr6":"1.12"}}');*
>
>
> *cqlsh:test> INSERT INTO test (id , time1 , jsonData ) VALUES ( 2, 345,
> '{"node1":{"attr1":"22","attr2":"4","attr3":"111"},"node2":{"attr4":"2.01","attr5":"3.231","attr6":"2.112"}}');*
> *cqlsh:test> INSERT INTO test (id , time1 , jsonData ) VALUES ( 3, 333,
> '{"node1":{"attr1":"17","attr2":"56","attr3":"167"},"node2":{"attr4":"1.11","attr5":"2.31","attr6":"3.112"}}');"*
>
>
> Using UDF/UDA , I want attributes values of json data to be aggregated
> something like below
>
> *"select json_aggr(jsonData) from test; //SUM*
>
>
> *{"node1":{"attr1":"130","attr2":"61","attr3":"611"},"node2":{"attr4":"4.13","attr5":"6.772","attr6":"6.344"}}"*
>
> //130=91+22+17 etc.,
>
>
> Can we do something like this , can we import java classes from thirdparty
> jars for parsing/updating json in UDF defined? And how?
> Can somebody please provide outline code for this?
>
> Thanks,
> Techpyaasa
>

Mime
View raw message