nukep / llamadb Goto Github PK
View Code? Open in Web Editor NEW[Not maintained] A SQL database written in Rust
License: Other
[Not maintained] A SQL database written in Rust
License: Other
Currently, INSERT
only works with simple number or string expressions; it cannot fold expressions into a single variant value.
The goal is to be able to run:
INSERT INTO mytable VALUES (5 * 4, NULL), (0, (SELECT avg(x) FROM othertable));
It'd be useful for simple logic tests and fiddling:
SELECT 'Hello' || 'World' AS message, 5 * '6';
/*
-------------------
| message | _0 |
-------------------
| HelloWorld | 30 |
-------------------
*/
I'm electing not to use dummy tables like DUAL
. :)
Columns should only be able to be omitted from INSERT
if the column:
DEFAULT
constraint, with a provided default valueNULL
=
, <>
, <
, <=
, >
, >=
+
, -
, *
, /
-
AND
OR
NOT
||
EXISTS
BETWEEN
... AND
IN
CASE
IS NULL
IS NOT NULL
LIKE
The goal is to be able to run:
INSERT INTO table_a SELECT count(*), avg(a) FROM table_b GROUP BY category;
This is a rather frustrating bug/limitation for those of us who like to copy and paste multi-lined text into the CLI. If a multi-line string is pasted, only the first line will be inputted.
rust-linenoise
is used to drive the CLI input. Enabling multi-line mode with linenoise::set_multiline(1);
doesn't seem to have any effect on my machine (64-bit Linux, using gnome-terminal).
To guarantee that SQL queries actually do as they're told, a very thorough test suite needs to be added.
Sqllogictest may be worth looking into: https://www.sqlite.org/sqllogictest/doc/trunk/about.wiki
The goal is to be able to run:
CREATE TABLE mytable (
id U32 INC,
name VARCHAR
);
INSERT INTO mytable (name) VALUES ('Alex'), ('Bob'), ('Caroline');
SELECT * FROM mytable;
/*
-----------------
| id | name |
-----------------
| 0 | Alex |
| 1 | Bob |
| 2 | Caroline |
-----------------
*/
Aliases for INC
: AUTOINCREMENT
These are in place until their features are complete.
SELECT avg(milliseconds) FROM track;
currently compiles into:
(temp-group-by :source_id 1
(scan `track` :source_id 0
(yield
(column-field :source_id 0 :column_offset 0)
(column-field :source_id 0 :column_offset 1)
(column-field :source_id 0 :column_offset 2)
(column-field :source_id 0 :column_offset 3)
(column-field :source_id 0 :column_offset 4)
(column-field :source_id 0 :column_offset 5)
(column-field :source_id 0 :column_offset 6)
(column-field :source_id 0 :column_offset 7)
(column-field :source_id 0 :column_offset 8)))
(group-by-values)
(yield
(avg :source_id 1
(column-field :source_id 1 :column_offset 6))))
The temp-group-by
creates a redundant temporary group, when simply using the table's group could suffice. This could be done with a new scan-group
function or similar.
(scan-group `track` :source_id 0
(yield
(avg :source_id 0
(column-field :source_id 0 :column_offset 6))))
Currently, all joins are executed using nested scans. This can obviously be bad for performance.
This would need to be implemented at the query compiler at the optimization stage.
Rust's data structures obviously can't be committed to disk, so a cache-friendly file format should be implemented.
STRING
VARCHAR
Ux
, where x is >= 8 and <= 64, and is a multiple 8.
Ix
, where x is >= 8 and <= 64, and is a multiple 8.
I32
: INT
or INTEGER
F64
DOUBLE
byte[]
byte[N]
UUID
JSON
BCRYPT
SCRYPT
PBKDF2
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
INNER JOIN
can currently be emulated with a traditional Cartesian + WHERE
join.
It would be nice to allow for the INNER JOIN
syntax as an alternative for those who prefer it (such as myself!).
OUTER JOIN
cannot currently be emulated. The only way to get an outer join is to implement the syntax.
I don't feel that LlamaDB is at a point where it can serve as a standalone library yet. The library crate is currently a bunch of hacks that expose internals such as parser modules.
This issue needs to wait on #4 so that developers have a somewhat reasonable API to work with, as well as a file-based DB. tempdb won't be around for long!
Until then, the llamadb
crate has been reserved on crates.io.
Nice-to-haves for the library:
sql!()
macro that statically validates and compiles the SQL query (to an extent).
llamadb> create table sup(id int);
Created (0.000s).
llamadb> select b from sup;
execution error: ambiguous column name: b
NULL
PRIMARY KEY
FOREIGN KEY
UNIQUE
CHECK
DEFAULT
List of functions to implement
COUNT(*)
COUNT
SUM
AVG
GROUP_CONCAT
MIN
MAX
ABS
LENGTH
ROUND
FLOOR
CEIL
TRUNC
TYPEOF
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.