Apache Jena Aggregate multiple expressions

78 views Asked by At

For the following data.ttl file:

A SAVINGS_1 200
A SAVINGS_2 300
A SAVINGS_3 370
A EMAIL emailidone
B SAVINGS_1 400
B SAVINGS_2 300
B SAVINGS_3 100
B EMAIL emailidtwo
C SAVINGS_1 200
C SAVINGS_2 600

The query:

SELECT ?NAME ?SAVINGS_1_VALUE ?SAVINGS_2_VALUE ?SAVINGS_3_VALUE WHERE { 
                                                                  ?NAME SAVINGS_1 ?SAVINGS_1_VALUE .
                                                                  ?NAME SAVINGS_2 ?SAVINGS_2_VALUE .
                                                                  ?NAME SAVINGS_3 ?SAVINGS_3_VALUE .
                                                                  ?NAME EMAIL ?email . }

Gives Output:

NAME  SAVINGS_1_VALUE  SAVINGS_2_VALUE  SAVINGS_3_VALUE
 A      200                 300              370
 B      400                 300              100
     

Is there a way to calculate the MAXIMUM of SAVINGS_1, SAVINGS_2 and SAVINGS_3 for individuals A, B and C who also has EMAIL using JENA ARQ Processor?

The expected query output would be

Expected Query output: NAME  SAVINGS_1_VALUE  SAVINGS_2_VALUE   SAVINGS_3_VALUE  MAXIMUM
                         A      200                 300              370           370
                         B      400                 300              100           400
                     
                     

MAX() function takes in only one argument, it can calculate the maximum of ?SAVINGS_1_VALUE or maximum of ?SAVINGS_2_VALUE and so on. Is there a way to evaluate maximum of ?SAVINGS_1_VALUE, ?SAVINGS_2_VALUE, ?SAVINGS_3_VALUE projections and add the result as another column? If the existing Jena Processor is not able to achieve this then what could be possible extension points to achieve this? Custom Aggregators also seem to evaluate on individual variable expression.

Note: There are multiples of variable expressions on which I want to evaluate this! So bind (if ... Is not an option for me to achieve this!

0

There are 0 answers