arcadedb icon indicating copy to clipboard operation
arcadedb copied to clipboard

SQL: aggregate functions with single argument not processing modifiers

Open gramian opened this issue 3 years ago • 2 comments

ArcadeDB Server v23.3.1 (build da609e411ccf28afeab01015ad6c2ecca1dadb3d/1680693032550/main)

Running on Mac OS X 12.6.4 - OpenJDK 64-Bit Server VM Homebrew

The results of aggregate functions with a single argument (either literal or type) do not handle modifiers. It works as expected when using two arguments.

Expected behavior

LIST
1
INTEGER
INTEGER

Actual behavior

[1,2,3,4]
[1,2,3,4]
10
4

Steps to reproduce

CREATE DOCUMENT TYPE doc;
INSERT INTO doc (num) VALUES (1), (2), (3), (4);
SELECT unionall(num).type() FROM doc;
SELECT unionall(num)[0] FROM doc;
SELECT sum(num).type() FROM doc;
SELECT max(num).type() FROM doc;

gramian avatar Apr 17 '23 07:04 gramian

I tried looking into a selection of aggregating SQL functions to look for a pattern, but I couldn't find any explaining this error definitely. Here are my findings:

  • sum (execute) returns an Object holding a:
    • Single parameter: Number
    • Multiple parameters: Number
  • max (execute) returns an Object holding a:
    • Single parameter: Object
    • Multiple parameters: Object
  • unionAll (execute) returns an Object holding a:
    • Single parameter: ArrayList<Object>
    • Multiple parameters: MultiIterator<>

gramian avatar Apr 25 '23 18:04 gramian

Reproduced.

lvca avatar May 02 '23 15:05 lvca