Skip to content
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

sqlite: add aggregate function #56600

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

geeksilva97
Copy link
Contributor

@geeksilva97 geeksilva97 commented Jan 14, 2025

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Jan 14, 2025
@cjihrig
Copy link
Contributor

cjihrig commented Jan 20, 2025

Also, tests and docs are needed.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 11, 2025

@geeksilva97 are you still planning to work on this?

@geeksilva97
Copy link
Contributor Author

@geeksilva97 are you still planning to work on this?

Hi @cjihrig . Yes, I plan to continue this. The last few weeks have been tough though. If nobody beats me I plan to get this done by April.

@geeksilva97 geeksilva97 added the wip Issues and PRs that are still a work in progress. label Mar 15, 2025
@geeksilva97 geeksilva97 force-pushed the sqlite-aggregate-function branch 7 times, most recently from beaf983 to 70dff34 Compare March 19, 2025 13:00
@geeksilva97 geeksilva97 marked this pull request as ready for review March 19, 2025 13:01
@geeksilva97 geeksilva97 force-pushed the sqlite-aggregate-function branch from 70dff34 to f4e4869 Compare March 19, 2025 13:17
Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 74.35897% with 70 lines in your changes missing coverage. Please review.

Project coverage is 90.21%. Comparing base (1de917b) to head (1f34c9e).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sqlite.cc 74.35% 45 Missing and 25 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56600      +/-   ##
==========================================
- Coverage   90.23%   90.21%   -0.03%     
==========================================
  Files         629      630       +1     
  Lines      184903   185388     +485     
  Branches    36223    36283      +60     
==========================================
+ Hits       166853   167239     +386     
- Misses      11010    11079      +69     
- Partials     7040     7070      +30     
Files with missing lines Coverage Δ
src/node_sqlite.h 70.00% <ø> (ø)
src/node_sqlite.cc 77.81% <74.35%> (-0.68%) ⬇️

... and 55 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@geeksilva97
Copy link
Contributor Author

I got an implementation that works. I need to add tests and clean up the code.

@geeksilva97 geeksilva97 force-pushed the sqlite-aggregate-function branch 3 times, most recently from cd3f0aa to 22da3ad Compare March 20, 2025 19:56
@geeksilva97 geeksilva97 changed the title sqlite: add aggregate function [wip] sqlite: add aggregate function Mar 20, 2025
@geeksilva97 geeksilva97 force-pushed the sqlite-aggregate-function branch from 22da3ad to 9badd9b Compare March 20, 2025 20:59
@geeksilva97 geeksilva97 force-pushed the sqlite-aggregate-function branch from 9badd9b to 7a0459a Compare March 22, 2025 01:33
LocalVector<Value> js_argv(isolate);
js_argv.emplace_back(Local<Value>::New(isolate, agg->value));

for (int i = 0; i < argc; ++i) {
Copy link
Contributor Author

@geeksilva97 geeksilva97 Mar 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware of this duplication. I have good expectations for #57571 and then this duplication will be resolved.

Comment on lines +1206 to +1201
THROW_ERR_INVALID_ARG_TYPE(env->isolate(),
"The \"options.start\" argument must be a "
"function or a primitive value.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message doesn't seem good. Would anybody have a better suggestion?

options.start can be any valid JS value or a function that returns any JS value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, maybe undefined is a valid value here?

@geeksilva97 geeksilva97 force-pushed the sqlite-aggregate-function branch from 7a0459a to 1f34c9e Compare March 22, 2025 01:37
@geeksilva97
Copy link
Contributor Author

Looks like the deterministic flag doesn't have an impact on aggregate functions (ref: https://sqlite.org/forum/info/10f2e7bcbdd5cfcac978e665815367aad175d407c19d9f9b4c1034f31b4a010a)

I tried a couple of queries to get it under test but I couldn't. Maybe anyone in @nodejs/sqlite would know?

(tagging since the team didn't exist when this PR was opened as a draft)

@geeksilva97 geeksilva97 changed the title [wip] sqlite: add aggregate function sqlite: add aggregate function Mar 22, 2025
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave this another quick skim, but I think we should wait for #57571 to land first before doing a more thorough review.

Looks like the deterministic flag doesn't have an impact on aggregate functions

We can probably drop it from the API then. If anyone ever comes along with a real use case (which there doesn't appear to be one), we can add it in the future.

Local<Value> start_v = Local<Value>::New(isolate, start_);
if (start_v->IsFunction()) {
auto fn = start_v.As<Function>();
TryCatch try_catch(isolate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this TryCatches since it seems like it is only being used to detect pending exceptions, and that can be done without TryCatch.

Comment on lines +1206 to +1201
THROW_ERR_INVALID_ARG_TYPE(env->isolate(),
"The \"options.start\" argument must be a "
"function or a primitive value.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, maybe undefined is a valid value here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. wip Issues and PRs that are still a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

node:sqlite: sqlite module should provide wrapper for sqlite3_create_window_function api
5 participants