Skip to content

Make -NULL, +NULL and ABS(NULL) NULL so aggregates skip them to close #2767 - #2993

Open
mateuscmtropical wants to merge 1 commit into
AlaSQL:developfrom
mateuscmtropical:fix-2767-unary-null
Open

mateuscmtropical wants to merge 1 commit into
AlaSQL:developfrom
mateuscmtropical:fix-2767-unary-null

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Closes #2767

-x, +x and ABS(x) gave NaN (or -0 for a null from parameter data) when x is NULL. COUNT and AVG count any value that is not NULL, so COUNT(-x) counted the NULL row and AVG(-x) divided by 3 instead of 2.

  • Unary - and + in src/50expression.js now give undefined when the operand is NULL or undefined. A number literal such as -1 compiles as before.
  • ABS in src/55functions.js does the same.

test/test2767.js covers COUNT, COUNT(DISTINCT ...), AVG and SUM over these expressions, null and undefined from parameter data, and values and constants as before. The tests fail on develop and pass with the change. yarn test-only gives 2554 pass. The only failures are the 5 Test 418 cases that load data from the internet, and they fail the same way on develop in my environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COUNT and AVG count NULL rows when the argument is -x, +x or ABS(x)

2 participants