Skip to content

Enable custom aggregate functions (take 2) #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Sep 8, 2022
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
24a6a12
initial commit.
Jul 3, 2020
fad9ba6
documentation
llimllib Sep 5, 2022
d191caa
remove no-longer-valid type
llimllib Sep 5, 2022
0d937a7
close over state initialization for performance
llimllib Sep 5, 2022
8fd3f8a
link documentation in comment
llimllib Sep 5, 2022
ba733ba
more testing
llimllib Sep 5, 2022
9e6b462
run tests if they're main
llimllib Sep 6, 2022
573afa7
accept a single arg
llimllib Sep 6, 2022
a3abdcb
this kind of works but I'm abandoning this branch
llimllib Sep 6, 2022
9daf01f
a middle road sqlite3_agg_context solution
llimllib Sep 6, 2022
ec5c72b
try out auto-updating state
llimllib Sep 6, 2022
a927950
improve quantile test, add multiple agg test
llimllib Sep 6, 2022
e643bd9
add a null to the test
llimllib Sep 6, 2022
2cbdb0e
acorn fails to parse ||=, whatever
llimllib Sep 6, 2022
b9ccd48
make eslint happy
llimllib Sep 6, 2022
ac548d4
make initial_value an argument
llimllib Sep 7, 2022
bf22aa1
test step and finalize exceptions
llimllib Sep 7, 2022
55858e9
add memory leak test
llimllib Sep 7, 2022
9a0c185
update docs to current interface
llimllib Sep 7, 2022
2445107
delete state in exception handlers
llimllib Sep 7, 2022
5b62cf6
remove null state
llimllib Sep 7, 2022
062f147
return init function and document object
llimllib Sep 7, 2022
7aff1ae
more tests and update back to init function
llimllib Sep 7, 2022
67f85e5
update redefinition test for new interface
llimllib Sep 7, 2022
b8692d4
update README to match fixed signature
llimllib Sep 7, 2022
b41e5cf
more consistent test formatting
llimllib Sep 7, 2022
d257bba
Update README.md
llimllib Sep 7, 2022
e82c286
clarify what exactly the result will contain
llimllib Sep 7, 2022
b65457c
Update README.md
lovasoa Sep 7, 2022
8d2c2e0
Update README.md
lovasoa Sep 7, 2022
f8f4a7c
Update README.md
lovasoa Sep 7, 2022
bdaa1b6
Update README.md
lovasoa Sep 7, 2022
e86d7ff
Update README.md
lovasoa Sep 7, 2022
423fc36
Improve documentation and type annotations
lovasoa Sep 8, 2022
f8e7bd3
ignore documentation in eslintrc
lovasoa Sep 8, 2022
799ebcd
reduce code size
lovasoa Sep 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add a null to the test
  • Loading branch information
llimllib committed Sep 6, 2022
commit e643bd9cfa8baa78c56922c05e886e9fa35bec7d
8 changes: 5 additions & 3 deletions test/test_aggregate_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ exports.test = function (SQL, assert) {
);

db.exec("CREATE TABLE test (col);");
db.exec("INSERT INTO test VALUES (1), (2), (3);");
db.exec("INSERT INTO test VALUES (1), (2), (3), (null);");
var result = db.exec("SELECT sum(col) FROM test;");
assert.equal(result[0].values[0][0], 6, "Simple aggregate function.");

db.create_aggregate(
"percentile", {
init: function () { return { vals: [], pctile: null }; }, // init
step: function (state, value, pctile) {
state.pctile = pctile;
state.vals.push(value);
if (value && !isNaN(value)) {
state.pctile = pctile;
state.vals.push(value);
}
return state;
},
finalize: function (state) {
Expand Down