Skip to content

Leave text out of AVG to close #2763 - #3011

Open
mateuscmtropical wants to merge 1 commit into
AlaSQL:developfrom
mateuscmtropical:fix-2763-avg-text
Open

mateuscmtropical wants to merge 1 commit into
AlaSQL:developfrom
mateuscmtropical:fix-2763-avg-text

Conversation

@mateuscmtropical

Copy link
Copy Markdown
Contributor

Closes #2763

What was wrong

AVG added each value with _SUM += (y || 0) and counted every value that is not NULL. Text was joined into the sum ('12' + '3' is '123') and counted, so AVG of '12' and '3' gave 61.5.

What changed

AVG now takes only numbers and BigInts, in the first row and in the rows after it. Other values are left out of the sum and the count, as the issue asks. When no value is a number, AVG gives no value. Dates keep their current handling.

Found while testing: SUM still joins text that comes after a number (SUM of 3 and '12' gives '312'). It ignores text only when the text comes first. I left SUM alone here. Happy to open an issue for it.

Tests

test/test2763.js covers text before and after a number, only text, text in a group, and numbers, NULL and BigInt. The first three fail on develop.

yarn test-only gives 2555 pass. The only failures are the 5 Test 418 cases that load files from the internet.

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.

AVG over text joins the strings: AVG of '12' and '3' gives 61.5

2 participants