Commit Graph

66 Commits

Author SHA1 Message Date
PThorpe92
5c207618a7 Fix extensions py test 2025-11-09 11:35:57 -05:00
PThorpe92
30de27b8c6 Add test in extensions.py for virtual table renaming 2025-11-09 11:07:43 -05:00
Diego Reis
ff11ba08c7 Makes tests pass 2025-09-30 09:41:54 -03:00
Diego Reis
8e60d64518 rename limbo -> turso 2025-09-29 22:33:39 -03:00
danawan
468046c654 translit and script 2025-09-26 15:20:27 +07:00
danawan
189caa5d5d rsoundex 2025-09-25 16:10:34 +07:00
danawan
54a95a0b55 add caverphone 2025-09-25 10:25:12 +07:00
danawan
815f0ffe25 add phonetic and soundex 2025-09-24 13:58:19 +07:00
danawan
80508910ea ruff check --fix 2025-09-23 13:28:13 +07:00
danawan
16b706a8d4 add sqlean fuzzy string distances 2025-09-23 11:49:41 +07:00
Piotr Rzysko
f3cbc382ce Support external aggregate functions wrapped in expressions
Handled in the same way as in `prepare_one_select_plan` for bare
function calls. In `prepare_one_select_plan`, however, resolving
external scalar functions is performed unnecessarily twice.
2025-09-02 08:22:36 +02:00
Piotr Rzysko
0a85883ee2 Support external aggregate functions in GROUP BY 2025-08-31 12:02:11 +02:00
Piotr Rzysko
d1a91a63e6 Extract TVF-related tests to TCL
These tests verify interactions between the database engine and TVFs.
They happen to use generate_series, but they are not intended to test
the behavior of any specific extension. Tests that verify generate_series
specific behavior remain in extensions.py.
2025-08-15 21:06:30 +02:00
Piotr Rzysko
20ea079679 Add framework for testing extensions in TCL
There is a distinction between tests that verify extension-specific
behavior and tests that verify interactions between the database engine
and extensions. Previously, both types of tests were kept in extensions.py.
With this new framework, we can extract the latter type of tests from
extensions.py into TCL. This cleans up extensions.py and provides
compatibility testing with SQLite at no extra cost.

To demonstrate the framework’s usage, tests verifying the handling of
virtual tables were extracted to TCL.

In the future, we may consider moving extension-specific tests to TCL as
well, especially those that have counterparts in SQLite or sqlean.
2025-08-15 21:06:27 +02:00
PThorpe92
ae22af29cd Fix pragma module list tests 2025-08-11 12:13:47 -04:00
Lucas Forato
673cfdbc0f test: include tests in extensions.py 2025-08-11 08:42:08 -03:00
Preston Thorpe
f55d34a3db Merge 'Fix panic on loading extension on brand new connection' from Preston Thorpe
Closes #2476

Closes #2477
2025-08-06 23:44:38 -04:00
PThorpe92
ae99edf4a6 Adjust test to test for behavior of loading extension on brand new connection 2025-08-06 16:55:54 -04:00
bit-aloo
84316d9206 fix python lint 2025-08-06 12:02:20 +05:30
bit-aloo
b26a58f652 update extension.py with regexp_replace test 2025-08-05 20:36:09 +05:30
Piotr Rzysko
99f87c07c1 Support column references in table-valued function arguments
This change extends table-valued function support by allowing arguments
to be column references, not only literals.

Virtual tables can now reject a plan by returning an error from
best_index (e.g., when a TVF argument references a table that appears
later in the join order). The planner using this information excludes
invalid plans during join order search.
2025-08-05 05:48:28 +02:00
Piotr Rzysko
82491ceb6a Integrate virtual tables with optimizer
This change connects virtual tables with the query optimizer.
The optimizer now considers virtual tables during join order search
and invokes their best_index callbacks to determine feasible access
paths.

Currently, this is not a visible change, since none of the existing
extensions return information indicating that a plan is invalid.
2025-08-05 05:48:28 +02:00
Piotr Rzysko
6a4cf02a90 Fix computation of argv_index in best_index
The `filter` methods for extensions affected by this fix expect arguments
to be passed in a specific order. For example, `generate_series` assumes
that if the `start` argument exists, it is always passed to `filter`
first. If `start` does not exist, then `stop` is passed first — but
`stop` must never come before `start`.

Previously, this was not guaranteed: `best_index` relied on constraints
being passed in the order matching `filter`'s expectations.
2025-08-04 19:38:45 +02:00
Iaroslav Zeigerman
6f63327320 fix overlooked tests 2025-07-26 04:51:44 -07:00
PThorpe92
3358e85889 Update py tests for new error msg 2025-07-23 17:05:46 -04:00
Piotr Rzysko
30ae6538ee Treat table-valued functions as tables
With this change, the following two queries are considered equivalent:
```sql
SELECT value FROM generate_series(5, 50);
SELECT value FROM generate_series WHERE start = 5 AND stop = 50;
```
Arguments passed in parentheses to the virtual table name are now
matched to hidden columns.

Column references are still not supported as table-valued function
arguments. The only difference is that previously, a query like:
```sql
SELECT one.value, series.value
FROM (SELECT 1 AS value) one, generate_series(one.value, 3) series;
```
would cause a panic. Now, it returns a proper error message instead.

Adding support for column references is more nuanced for two main
reasons:
- We need to ensure that in joins where a TVF depends on other tables,
those other tables are processed first. For example, in:
```sql
SELECT one.value, series.value
FROM generate_series(one.value, 3) series, (SELECT 1 AS value) one;
```
the one table must be processed by the top-level loop, and series must
be nested.
- For outer joins involving TVFs, the arguments must be treated as ON
predicates, not WHERE predicates.
2025-07-14 07:16:53 +02:00
Piotr Rzysko
44b1b1852a Fix referencing virtual table predicates
We need to enumerate first and filter afterward — not the other way
around — because we later use the indexes produced by `enumerate` to
access the original `predicates` slice.
2025-07-14 07:16:53 +02:00
Piotr Rzysko
319cdbe3af Don't use search for virtual tables
Previously, the test queries added in this commit would fail with:
thread 'main' panicked at core/schema.rs:129:34:
not implemented
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:74:14
   2: core::panicking::panic
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:148:5
   3: limbo_core::schema::Table::get_root_page
             at ./core/schema.rs:129:34
   4: limbo_core::translate::main_loop::init_loop
             at ./core/translate/main_loop.rs:260:44
   5: limbo_core::translate::emitter::emit_query
             at ./core/translate/emitter.rs:568:5
   6: limbo_core::translate::emitter::emit_program_for_select
             at ./core/translate/emitter.rs:496:5
   7: limbo_core::translate::emitter::emit_program
             at ./core/translate/emitter.rs:187:31
   8: limbo_core::translate::select::translate_select
             at ./core/translate/select.rs:82:5
   9: limbo_core::translate::translate_inner
             at ./core/translate/mod.rs:241:13
  10: limbo_core::translate::translate
             at ./core/translate/mod.rs:95:17
  11: limbo_core::Connection::run_cmd
             at ./core/lib.rs:416:31
  12: <limbo_core::QueryRunner as core::iter::traits::iterator::Iterator>::next
             at ./core/lib.rs:916:22
  13: limbo::app::Limbo::run_query
             at ./cli/app.rs:442:27
  14: limbo::app::Limbo::handle_input_line
             at ./cli/app.rs:544:13
  15: limbo::main
             at ./cli/main.rs:51:31
  16: core::ops::function::FnOnce::call_once
2025-07-14 07:16:53 +02:00
Piotr Rzysko
000d70f1f3 Propagate info about hidden columns 2025-07-14 07:16:53 +02:00
Pekka Enberg
7f91768ff6 core/translate: Unify no such table error messages
We're now mixing different error messages, which makes compatibility
testing pretty hard. Unify on a single, SQLite compatible error message
"no such table".
2025-07-07 11:10:46 +03:00
pedrocarlo
c5bed21dff fix python test import naming 2025-07-03 02:15:08 -03:00
PThorpe92
297cbbf726 Rename Limbo -> Turso in python tests 2025-07-02 10:57:46 -04:00
Pekka Enberg
eb0de4066b Rename limbo_ext crate to turso_ext 2025-06-29 12:14:08 +03:00
PThorpe92
b655ac8267 Remove tests that dynamically load generate_series extension 2025-06-27 09:50:15 -04:00
Piotr Rzysko
dda1ee86e2 Fix ruff errors 2025-06-21 19:32:16 +02:00
Jussi Saurio
d0f9df1f97 Merge 'Improve extension compatibility testing' from Piotr Rżysko
Extracted from https://github.com/tursodatabase/limbo/pull/1727.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1741
2025-06-21 19:09:33 +03:00
pedrocarlo
80ccca8827 ruff lint fix 2025-06-20 15:59:03 -03:00
Piotr Rzysko
9d54d9baf5 Add compatibility test for generate_series 2025-06-14 05:26:11 +02:00
Piotr Rzysko
c4fa715036 Add test SQLite KV extension
This extension mimics Limbo's kv_store and is used in tests to verify
that Limbo and SQLite handle extensions in a compatible way.
2025-06-14 05:26:10 +02:00
Piotr Rzysko
d1d8ead475 Add support for pragma table-valued functions 2025-06-01 10:25:42 +02:00
Jussi Saurio
b843ad0a58 Add INSERT INTO ... SELECT * FROM generate_series() regression test 2025-05-27 10:54:55 +03:00
PThorpe92
c5d364064a Add python tests for xConnect behavior and testing extension 2025-05-24 14:49:59 -04:00
Piotr Rzysko
ad9d044a04 Add CSV extension 2025-05-21 09:22:59 +02:00
Jussi Saurio
6926d7b931 testing/py: rename debug_print() to run_debug() 2025-05-12 10:52:13 +03:00
Piotr Rzysko
d5984445a9 Fix panic on CREATE VIRTUAL TABLE IF NOT EXISTS by halting VM properly
Fixes a runtime panic caused by failing to halt the virtual machine
after executing CREATE VIRTUAL TABLE IF NOT EXISTS.

Previously resulted in:
thread 'main' panicked at core/vdbe/mod.rs:408:52:
index out of bounds: the len is 3 but the index is 3
2025-05-11 21:21:18 +02:00
Piotr Rzysko
fdffbc9534 Ensure virtual table name uniqueness 2025-05-11 21:21:18 +02:00
Preston Thorpe
d837f89d74 Merge branch 'main' into vtab_schema 2025-04-28 22:09:10 -04:00
PThorpe92
d02900294e Remove 2nd shell in vtab tests, fix expr translation in main loop 2025-04-17 14:01:45 -04:00
pedrocarlo
d71029cda7 Overhaul in printing using rich 2025-04-15 12:50:35 -03:00
pedrocarlo
58e091cb23 setup uv for limbo 2025-04-15 12:45:46 -03:00