Henrik Ingo
c354219675
Add Nyrkiö change point detection to 'cargo bench' workflow
...
This adds a separate push-only.yml workflow. For now pull request
API wasn't integrated yet, so shouldn't run on PRs.
disable cargo color
2025-01-21 03:03:27 +02:00
Pekka Enberg
876788588b
github: Fix Python release workflow
2025-01-19 13:42:00 +02:00
Pekka Enberg
0abb917604
Limbo 0.0.13
2025-01-19 13:30:56 +02:00
Pekka Enberg
466bc8be0c
Merge 'npm packaging for node and web' from Elijah Morgan
...
Add web support to npm package.
**Still a WIP need to do some cleanup still**
I assumed it is better to keep the server code and web code together in
the same package (bigger download number). It took quite a bit of
experimentation but the ultimate experience is
node - commonjs
```js
const { Database } = require("limbo-wasm/node");
```
web - module
```js
const worker = new Worker(new URL('limbo-wasm/web/limbo-worker.js', import.meta.url), { type: 'module' });
```
Like I said this took a lot of experimentation on my part as this is my
first time trying to create an npm package let alone that mixes commonjs
and modules.
The structure is an npm workspace with two sub packages (web and node).
```
node
├── dist
│ ├── README.md
│ ├── index.d.ts
│ ├── index.js
│ ├── index_bg.wasm
│ ├── index_bg.wasm.d.ts
│ └── snippets
│ └── limbo-wasm-d1562e55b90f5289
│ └── node
│ └── src
│ └── vfs.js
├── package.json
└── src
└── vfs.js
web
├── dist
│ ├── README.md
│ ├── index.d.ts
│ ├── index.js
│ ├── index_bg.wasm
│ ├── index_bg.wasm.d.ts
│ └── snippets
│ └── limbo-wasm-d1562e55b90f5289
│ └── web
│ └── src
│ └── web-vfs.js
├── html
│ ├── index.html
│ ├── limbo-opfs-test.html
│ └── limbo-test.html
├── node_modules
├── package.json
├── playwright.config.js
├── src
│ ├── limbo-worker.js
│ ├── opfs-interface.js
│ ├── opfs-sync-proxy.js
│ ├── opfs-worker.js
│ ├── opfs.js
│ └── web-vfs.js
├── test
│ ├── helpers.js
│ ├── limbo.test.js
│ ├── opfs.test.js
│ └── setup.js
└── vite.config.js
```
The output of wasm-pack gets put in <web/node>dist
JS code moves into <web/node>src/
Tests move under web/test
The npm package looks like (you can see I need to cleanup some of the
stuff that gets included).
```
-rw-r--r-- 0 0 0 195 Oct 26 1985 package/web/html/index.html
-rw-r--r-- 0 0 0 2733 Oct 26 1985 package/web/html/limbo-opfs-test.html
-rw-r--r-- 0 0 0 162 Oct 26 1985 package/web/html/limbo-test.html
-rw-r--r-- 0 0 0 632 Oct 26 1985 package/web/test/helpers.js
-rw-r--r-- 0 0 0 18128 Oct 26 1985 package/node/dist/index.js
-rw-r--r-- 0 0 0 21732 Oct 26 1985 package/web/dist/index.js
-rw-r--r-- 0 0 0 1836 Oct 26 1985 package/web/src/limbo-worker.js
-rw-r--r-- 0 0 0 2108 Oct 26 1985 package/web/test/limbo.test.js
-rw-r--r-- 0 0 0 1764 Oct 26 1985 package/web/src/opfs-interface.js
-rw-r--r-- 0 0 0 3409 Oct 26 1985 package/web/src/opfs-sync-proxy.js
-rw-r--r-- 0 0 0 1430 Oct 26 1985 package/web/src/opfs-worker.js
-rw-r--r-- 0 0 0 3976 Oct 26 1985 package/web/src/opfs.js
-rw-r--r-- 0 0 0 4502 Oct 26 1985 package/web/test/opfs.test.js
-rw-r--r-- 0 0 0 269 Oct 26 1985 package/web/playwright.config.js
-rw-r--r-- 0 0 0 0 Oct 26 1985 package/web/test/setup.js
-rw-r--r-- 0 0 0 519 Oct 26 1985 package/node/dist/snippets/limbo-wasm-d1562e55b90f5289/node/src/vfs.js
-rw-r--r-- 0 0 0 519 Oct 26 1985 package/node/src/vfs.js
-rw-r--r-- 0 0 0 608 Oct 26 1985 package/web/vite.config.js
-rw-r--r-- 0 0 0 435 Oct 26 1985 package/web/dist/snippets/limbo-wasm-d1562e55b90f5289/web/src/web-vfs.js
-rw-r--r-- 0 0 0 435 Oct 26 1985 package/web/src/web-vfs.js
-rw-r--r-- 0 0 0 146 Oct 26 1985 package/web/node_modules/.vite/deps/_metadata.json
-rw-r--r-- 0 0 0 309 Oct 26 1985 package/node/package.json
-rw-r--r-- 0 0 0 671 Oct 26 1985 package/package.json
-rw-r--r-- 0 0 0 23 Oct 26 1985 package/web/node_modules/.vite/deps/package.json
-rw-r--r-- 0 0 0 602 Oct 26 1985 package/web/package.json
-rw-r--r-- 0 0 0 153 Oct 26 1985 package/web/node_modules/.vite/vitest/results.json
-rw-r--r-- 0 0 0 1296 Oct 26 1985 package/node/dist/README.md
-rw-r--r-- 0 0 0 1296 Oct 26 1985 package/README.md
-rw-r--r-- 0 0 0 1296 Oct 26 1985 package/web/dist/README.md
-rw-r--r-- 0 0 0 1217 Oct 26 1985 package/node/dist/index_bg.wasm.d.ts
-rw-r--r-- 0 0 0 1217 Oct 26 1985 package/web/dist/index_bg.wasm.d.ts
-rw-r--r-- 0 0 0 449 Oct 26 1985 package/node/dist/index.d.ts
-rw-r--r-- 0 0 0 2554 Oct 26 1985 package/web/dist/index.d.ts
-rw-r--r-- 0 0 0 2215065 Oct 26 1985 package/node/dist/index_bg.wasm
-rw-r--r-- 0 0 0 2213889 Oct 26 1985 package/web/dist/index_bg.wasm
```
resolves #624
Closes #657
2025-01-19 12:53:21 +02:00
Pekka Enberg
ef1e0ae282
Add vanity badges to README.md
2025-01-19 12:44:56 +02:00
Pekka Enberg
246ffec9d0
Update badges in README
2025-01-19 12:36:26 +02:00
Pekka Enberg
f5e5428d45
Merge 'Syntactic improvements' from Jorge López Tello
...
This is a purely syntactic PR. It doesn't change behavior, just rewrites
some loops and removes unneeded parts, like lifetime annotations and
references. Mainly because the Clippy and IDE warnings get annoying.
Don't worry about the number of commits, I just separated based on type
of change.
Closes #732
2025-01-19 12:17:28 +02:00
Pekka Enberg
5851d6643a
Revert "core: Move re-exports at top of lib.rs"
...
This reverts commit c8a979eb4b . It
conflicts with a cleanup PR I am about to merge.
2025-01-19 12:17:06 +02:00
Pekka Enberg
c8a979eb4b
core: Move re-exports at top of lib.rs
...
Clean up the code a bit by moving re-exports at the top of lib.rs to
make them more visible to the reader.
2025-01-19 11:34:59 +02:00
Pekka Enberg
0561ff1545
Merge 'Fix scalar API in extensions, add documentation and error handling' from Preston Thorpe
...
Closes #728
Changes the API to one macro/annotation on the relevant function
```rust
#[scalar(name = "uuid4_str", alias = "gen_random_uuid")]
fn uuid4_str(_args: &[Value]) -> Value {
let uuid = uuid::Uuid::new_v4().to_string();
Value::from_text(uuid)
}
register_extension! {
scalars: { uuid4_str, uuid4 }
}
```
The only downside of this, is that for functions that use their
arguments, because this is not a trait, there is not really a way of
enforcing the function signature like there is with the other way.
Documentation has been added for this in the `scalar` macro, so
hopefully will not be an issue.
Also this PR cleans up the Aggregate API by changing the `args` and
`name` functions to constant associated types, as well as adds some
error handling and documentation.
```rust
impl AggFunc for Median {
type State = Vec<f64>;
const NAME: &'static str = "median";
const ARGS: i32 = 1;
fn step(state: &mut Self::State, args: &[Value]) {
if let Some(val) = args.first().and_then(Value::to_float) {
state.push(val);
}
}
//.. etc
```
Closes #735
2025-01-19 09:53:31 +02:00
Pekka Enberg
3e28541b53
Merge 'Fix null compare operations not giving null' from Vrishabh
...
In limbo when we do any compare operations like `Eq, gt, lt, gte, lte`
with nulls , we were actually giving the result as true where as sqlite3
gives null. This is because if we had a null, we were incorrectly going
to conditional branch and not increment program by 1. Also the sqlite
generates `ZeroOrNull` op in these cases
(https://github.com/sqlite/sqlite/blob/version-3.45.3/src/expr.c#L4644 )
but we were generating a Integer instruction. The below outputs can give
a clearer picture.
This PR aims to fix this.
sqlite3 output
```
SQLite version 3.48.0
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select 8 = null;
sqlite> select 8 > null;
sqlite> explain select 8 > null;
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Init 0 6 0 0
1 Integer 1 1 0 0
2 Gt 3 4 2 64
3 ZeroOrNull 2 1 3 0
4 ResultRow 1 1 0 0
5 Halt 0 0 0 0
6 Integer 8 2 0 0
7 Null 0 3 0 0
8 Goto 0 1 0 0
sqlite> explain select 8 = null;
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Init 0 6 0 0
1 Integer 1 1 0 0
2 Eq 3 4 2 64
3 ZeroOrNull 2 1 3 0
4 ResultRow 1 1 0 0
5 Halt 0 0 0 0
6 Integer 8 2 0 0
7 Null 0 3 0 0
8 Goto 0 1 0 0
```
Limbo Output
```
Limbo v0.0.12
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
limbo> select 8 = null;
1
limbo> select 8 > null;
1
limbo> explain select 8 > null;
addr opcode p1 p2 p3 p4 p5 comment
---- ----------------- ---- ---- ---- ------------- -- -------
0 Init 0 8 0 0 Start at 8
1 Integer 8 2 0 0 r[2]=8
2 Null 0 3 0 0 r[3]=NULL
3 Integer 1 1 0 0 r[1]=1
4 Gt 2 3 6 0 if r[2]>r[3] goto 6
5 Integer 0 1 0 0 r[1]=0
6 ResultRow 1 1 0 0 output=r[1]
7 Halt 0 0 0 0
8 Transaction 0 0 0 0
9 Goto 0 1 0 0
limbo> explain select 8 = null;
addr opcode p1 p2 p3 p4 p5 comment
---- ----------------- ---- ---- ---- ------------- -- -------
0 Init 0 8 0 0 Start at 8
1 Integer 8 2 0 0 r[2]=8
2 Null 0 3 0 0 r[3]=NULL
3 Integer 1 1 0 0 r[1]=1
4 Eq 2 3 6 0 if r[2]==r[3] goto 6
5 Integer 0 1 0 0 r[1]=0
6 ResultRow 1 1 0 0 output=r[1]
7 Halt 0 0 0 0
8 Transaction 0 0 0 0
9 Goto 0 1 0 0
limbo>
```
Limbo Output with this PR
```
Limbo v0.0.12
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
limbo> select 8 = null;
limbo> select 8 > null;
limbo> explain select 8 > null;
addr opcode p1 p2 p3 p4 p5 comment
---- ----------------- ---- ---- ---- ------------- -- -------
0 Init 0 8 0 0 Start at 8
1 Integer 8 2 0 0 r[2]=8
2 Null 0 3 0 0 r[3]=NULL
3 Integer 1 1 0 0 r[1]=1
4 Gt 2 3 6 0 if r[2]>r[3] goto 6
5 ZeroOrNull 2 1 3 0 ((r[2]=NULL)|(r[3]=NULL)) ? r[1]=NULL : r[1]=0
6 ResultRow 1 1 0 0 output=r[1]
7 Halt 0 0 0 0
8 Transaction 0 0 0 0
9 Goto 0 1 0 0
limbo> explain select 8 = null;
addr opcode p1 p2 p3 p4 p5 comment
---- ----------------- ---- ---- ---- ------------- -- -------
0 Init 0 8 0 0 Start at 8
1 Integer 8 2 0 0 r[2]=8
2 Null 0 3 0 0 r[3]=NULL
3 Integer 1 1 0 0 r[1]=1
4 Eq 2 3 6 0 if r[2]==r[3] goto 6
5 ZeroOrNull 2 1 3 0 ((r[2]=NULL)|(r[3]=NULL)) ? r[1]=NULL : r[1]=0
6 ResultRow 1 1 0 0 output=r[1]
7 Halt 0 0 0 0
8 Transaction 0 0 0 0
9 Goto 0 1 0 0
```
Closes #733
2025-01-19 09:09:12 +02:00
Pekka Enberg
cdcc98540a
cargo fmt
2025-01-19 08:52:01 +02:00
Pekka Enberg
e2efdf724e
Merge 'Fix panics on invalid aggregate function arguments' from Krishna Vishal
...
This pull request fixes panics when there's an aggregate function call
with too few or too many arguments.
Closes #726
2025-01-19 08:51:55 +02:00
Krishna Vishal
5cf78b7d54
chore: clippy remove unused imports
2025-01-19 07:18:31 +05:30
Krishna Vishal
acad562c07
Remove unnecessary Result
2025-01-19 06:50:00 +05:30
Krishna Vishal
870a2ea802
clean up
2025-01-19 06:40:40 +05:30
Krishna Vishal
fa0503f0ce
1. Changes to extension.py
...
2. chore: cargo fmt
2025-01-19 04:58:05 +05:30
Krishna Vishal
31856315fe
Fix merge conflicts
2025-01-19 04:45:14 +05:30
Krishna Vishal
6173aeeb3b
1. Fix merge conflicts
...
2. change tests for extensions to return error instead of null (Preston)
2025-01-19 04:39:25 +05:30
Krishna Vishal
ca097b1972
Remove unused import
2025-01-19 04:35:21 +05:30
Krishna Vishal
027803aabf
Refactor code
2025-01-19 04:35:21 +05:30
Krishna Vishal
68553904c7
Converted the unconditional unwrap to a match which handles the case when the function is COUNT and args are None and replaces the args. Solves https://github.com/tursodatabase/limbo/issues/725
2025-01-19 04:35:21 +05:30
Krishna Vishal
776aecbce0
1. All aggregate functions now validate their args and return Parse error for wrong number of args.
...
2. Unknown functions now return `no such function: unknown_function`
2025-01-19 03:00:18 +05:30
PThorpe92
bcd3ae2bd7
Add documentation to core/ext and relevant macros
2025-01-18 16:04:28 -05:00
PThorpe92
9c47379927
Fix deref null ptr in Debug impl on external types
2025-01-18 15:23:33 -05:00
PThorpe92
956320b7d0
Fix scalar API in extensions, add some error handling
2025-01-18 15:19:35 -05:00
Elijah Morgan
74ddc42df0
Add back integration tests
...
Fix package.json for better imports vs web/nodejs
Fix examples and integration tests
2025-01-18 15:01:16 -05:00
Krishna Vishal
ed5c8ddcf0
Remove unused import
2025-01-19 01:02:46 +05:30
Krishna Vishal
4c1f4d71d6
Refactor code
2025-01-19 01:02:41 +05:30
Krishna Vishal
bff3af6326
Converted the unconditional unwrap to a match which handles the case when the function is COUNT and args are None and replaces the args. Solves https://github.com/tursodatabase/limbo/issues/725
2025-01-19 01:02:37 +05:30
psvri
e16b3491c4
Fix null compares giving incorrect results
2025-01-19 00:44:38 +05:30
psvri
554244209d
Add Null comparision tests
2025-01-19 00:39:10 +05:30
Jorge López
e5faa3273a
syntactic changes: remove unused self dependency to appease to our Clippy overlord...
2025-01-18 19:36:32 +01:00
Jorge López
9b8baa7895
syntactic changes: adds default impl to Parameters based on new(), fixes Clippy warn https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
2025-01-18 19:21:50 +01:00
Jorge López
f7001b974a
syntactic changes: weird issue with a previous commit. More unwrap() -> ?
2025-01-18 19:20:12 +01:00
Jorge López
50852f36f8
syntactic changes: semantics, call is_empty instead of manually checking the size
2025-01-18 19:20:12 +01:00
Jorge López
3da813b260
syntactic changes: use if let .. else instead of checking for is_none() and calling unwrap()
2025-01-18 19:20:12 +01:00
Jorge López
9c1d890d59
syntactic changes: 2 typos I missed earlier
2025-01-18 19:20:11 +01:00
Jorge López
3da7d8cb79
syntactic changes: Markdown semantics
2025-01-18 19:20:11 +01:00
Jorge López
0d6e6a0aa4
syntactic changes: use Result::unwrap_or() instead of manual match
2025-01-18 19:20:11 +01:00
Jorge López
00c503dcf5
syntactic changes: lift return out of ifs
2025-01-18 19:20:11 +01:00
Jorge López
90a14a7bc7
syntactic changes: replace explicit while let Some in iterator with for..in loop (see https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator )
2025-01-18 19:20:11 +01:00
Jorge López
683125fefb
syntactic changes: factor duplicated code into helper function that can be reused
2025-01-18 19:20:11 +01:00
Jorge López
bbe3cded38
syntactic changes: use f64::INFINITY instead of deprecated std::f64::INFINITY
2025-01-18 19:20:11 +01:00
Jorge López
cfff4dd21c
syntactic changes: fix typos in comments
2025-01-18 19:20:11 +01:00
Jorge López
e4ab2fb273
syntactic changes: rewrite loop with while
2025-01-18 19:19:49 +01:00
Jorge López
07970468bd
syntactic changes: remove unneeded parentheses
2025-01-18 18:45:05 +01:00
Jorge López
218a2e6dda
syntactic changes: remove unneeded mut, lifetimes,references that get instantaneously dereferenced and casts
2025-01-18 18:43:47 +01:00
Pekka Enberg
4a41736f89
Merge 'Implement IsNot operator' from Vrishabh
...
This PR adds support for IsNot Operator which was not working as shown
below.
```
❯ ./target/debug/limbo
Limbo v0.0.12
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
limbo> select 1 is not 0;
thread 'main' panicked at core\translate\expr.rs:626:40:
not yet implemented: IsNot
stack backtrace:
```
Closes #731
2025-01-18 19:39:57 +02:00
Jorge López
2cc8cb9ad8
syntactic changes: use assert_eq!() instead of assert!() for equality comparisons
2025-01-18 18:37:50 +01:00