gluesql / gluesql Goto Github PK
View Code? Open in Web Editor NEWGlueSQL is quite sticky. It attaches to anywhere.
Home Page: https://gluesql.org/docs
License: Apache License 2.0
GlueSQL is quite sticky. It attaches to anywhere.
Home Page: https://gluesql.org/docs
License: Apache License 2.0
But after the first release
Love this project.
Have a lot of sql database dumps I want to have for verification
A separate bin project can't refer to locally libraries.
But a rough approach is to introduce tests for loading sql from a file instead of inline strings
Give me a hint where to start in my downloaded glusql-main
CREATE TABLE Foo (
id INTEGER DEFAULT 1
);
For now, create sql query is accepted but not working.
Modification in row.rs is required.
Hej,
Sorry for all issues. Not complaining. Love the SQL and in Rust!
But browsing into my swedish testdabase on recipes and it's categories
the output is not ordered on column 2.
(We have the same sort order in Swedish as in any Latin-1 countries)
"select * from category where categoryid > 50 order by 2;"
53 "Fläskkött" ""
54 "Vegetarisk" ""
55 "Pastej" ""
56 "Gratäng" ""
57 "Finskt" ""
58 "Kassler" ""
There are now 3 errors types.
nom-sql
)GlueSQL
itself.Currently I'm using Unreachable
prefix for the second case.
And how about 3?
Maybe Conflict
prefix?
Though some custom storages don't need ALTER TABLE syntaxes, they still need to add it.
impl AlterTable for CustomStorage {}
It looks unnecessary but required.
In execute.rs
,
pub fn execute<T: 'static + Debug, U: Store<T> + StoreMut<T> + AlterTable>(
...
...
If trait alias feature ships on stable Rust then, we can improve the code above like this.
#[cfg(feature = "alter-table")]
trait Storage<T: 'static + Debug> = Store<T> + StoreMut<T> + AlterTable>
#[cfg(not(feature = "alter-table"))]
trait Storage<T: 'static + Debug> = Store<T> + StoreMut<T>>
pub fn execute<T: 'static + Debug, U: Storage>(
...
...
It is blocked by this issue: rust-lang/rust#41517
Looking forward to see trait alias in stable Rust.
Apologies if you've covered this somewhere already, or if this ought to be asked of sled
, but are arrays planned?
SELECT * FROM Foo WHERE name IS NULL;
SELECT * FROM Bar WHERE name IS NOT NULL;
DROP Table Something;
Currently, GlueSQL support only single value insertion for INSERT
query.
INSERT INTO TableA VALUES (100, "Foo");
This issue is for supporting multiple value insertion using single INSERT query, like this below:
INSERT INTO TableA VALUES (100, "Hello"), (200, "World"), (300, "GOOOOOD");
After finishing #7
Make WebAssembly build and test using MemoryStorage.
It's required to make JavaScript interface. 🔢
Is a command line interface planned? I liked playing around with the web interface but there doesn't seem to be something equivalent for the terminal?
SELECT 1 + 2 FROM TableA;
This kind of query above should be supported!
There exists two store traits: Store
and StoreMut
.
Plan is adding new Alter
store trait, but this time, Alter
trait will be optional.
Provide 3 SQL statements
enum Evaluated
can be quite confusing for newcomers, it's required to have some explanation of this.
Use source code doc comments feature.
Then, someone wants to contributor can see that in source code or by cargo doc --document-private-items
.
Problem with insert of text.
Insert into tableA values ("WORKS BUT NOT STANDARD" , 'STANDARD BUT IS NOT ACCEPTED');
Most exports from other databases uses SingleQuotedString. More Standard SQL.
Seems like expressions with SingleQuotedString works
Related to #80 - due to long threads, it's hard to recognize what exact task is, so let's use this issue.
input:
SELECT a, b AS foo, SUM(id) AS bar FROM TableA;
output:
vec!["a", "foo", "bar"]
This issue is adding a new function get_projection_aliases
to src/parse.rs
which takes sqlparser::ast::Query
reference and return column aliases, Vec<String>
fn get_projection_aliases(query: &sqlparser::ast::Query) -> Vec<String>
CREATE TABLE Test (id INTEGER, name INTEGER NULL);
INSERT INTO Test VALUES (100);
Then error occurs on insert query.
{"Row":"Unreachable"}
It is reachable but unreachable!
SELECT COUNT(*) FROM TableA;
SELECT count(*) FROM TableA;
both should work but the second one is not working.
IF NOT EXISTS
syntax is not supported yet.
Let's make it work.
In the Usage Section it would be better to explicitly put all imports necesary instead of the glob imports as they tend to hurt readability.
related to #56
There doesn't exist place for adding conditional statement tests cases which are used in WHERE
clause.
It's obviously better to have, let's add src/tests/filter.rs
, like blend
.
filter.rs
check_expr function is stateless, so we can easily add test cases to reach all possible branches.
It would be good to start from renaming src/tests/between.rs
to src/tests/filter.rs
.
I can only imagine how large a feature this is but I wanted to put it out there. MVCC Transaction support would empower developer's to prevent reading and writing inconsistent data to gluesql.
I'm guessing however that this is currently blocked on Sled's lack of transactional scan support inside TransactionTrees(?)
Following WHERE
clauses are not supported now.
SELECT * FROM TableA WHERE +1 = 1;
SELECT * FROM TableA WHERE -1 = -1;
Proper place to add test cases would be in src/tests/filter.rs
.
src/executor/evaluate/evaluated.rs
There are a few panic!()
uses in evaluated.rs
.
I used panic!()
because currently there's no way to reach that branches.
But it's better not to use panic, replace those to managed unreachable error types.
SELECT * FROM TableA WHERE amount BETWEEN 1 AND 100
SELECT 1 + 1 FROM Test;
Above works, but...
SELECT 1 FROM Test;
This doesn't work with this error [Blend Error] "FieldDefinitionNotSupported"
For now, GlueSQL supports 2 join types, INNER JOIN
and LEFT OUTER JOIN
.
RIGHT OUTER JOIN
Implementation can be a bit more tough, but all modifications required to change is in a single file, 198 lines of codes.
It can be a sort of quite fun programming quiz.
pub enum Value {
I64(i64),
String(String),
}
Now GlueSQL
only has 2 value types.
Let's add two more types,
Bool(bool)
Real(f64)
Then It looks enough for the first release.
It would be very nice for people like me who would like to be notified about version updates, without necessarily having to be notified about issues and PRs 🥰
Currently the only supported storage is SledStorage
.
But it can't be built for Web
.
So, make the MemoryStorage
and use it for WebAssembly build.
For example,
UPDATE TableA SET v1 = v1 + 1
is not supported because current GlueSQL
does not support this arithmetic operator.
Let's make it.
GlueSQL fetches data and convert each row into struct named Context
.
FilterContext
contains the row from join and nested select.
BlendContext
does similar role but it does not need to include nested selected row on where
clause.
Currently linked list is used but it's better to replace those into vector.
Linked list assumes that total number of items are not predictable, but in this case, it is not.
It is certainly pre-calculated from AST made from sql query.
So, it means it's possible to specify the length of context at first, like using this.. Vec::with_capacity(10)
.
But let's start with simply replacing data structure, from linked list to vector.
At this point, it would be good to start with using im-rc
This is not urgent issue, but it should be done in... some day.
Comparing to Join
, it's just a simple task.
Let's implement it before the first release!
Let's get it.
CREATE TABLE Test (id INTEGER);
INSERT INTO Test VALUES (100, 200);
below insertion query should report an error but it is accepted.
Current Row
struct cares lack of values or columns but not handling more values properly.
NULLABLE
should be supported in the first release.
👍
Allow Nullable keyword in CREATE
and apply to Value
and join works.
Current blend.rs
does not support Join
queries.
It only takes the first node of BlendContext
linked list, but it should handle all properly.
And I also need to some kind of macro
for helping value comparison test.
There's an example in basic.rs
.
let res = helper.run("select id from test").expect("select");
assert_eq!(res, Payload::Select(vec![Row(vec![Value::I64(1)])]));
Make a macro to shorten and readify this: Payload::Select(vec![Row(vec![Value::I64(1)])])
.
It also requires storage code changes.
one in here, sled_storage
.
The others are in gluesql-js : memory-storage and web-storage.
Prior work is done by @ryanhossain9797
#70
Have made some programming around select.
It's a little bit complicated and column names is missing I think.
In order to make glusql competitive to JS, sqlite, PHP and more
I think something like the following is required
Some kind of Displayselected instead od Selected
The outermost SELECT could get this result.
But of course not for an INSERT .. SELECT ...
A: Usage is: iter over colnames in order to display them in order
B: Usage on whole row is: 'simple' item for all column values
C: Usage on columns in a row
let cell = arow[colname.iter().position(|&x| x == "THECOLNAME")
Below is some pseudo Rust for data definitions
All is immutable
enum DisplayCell
{
Str {value:&str},
Int {value:i64},
Float {value:f64},
Empty, // null
Bool {value:&str} // 'true', 'false' or 1,0 for language independancy
}
struct DisplayRow
{
arow:Vec
}
struct Displayselected
{
headers:Vec<&str>,
rows:Vec
}
CREATE TABLE foolish (first INTEGER, second ANYTHING_ACCEPTED);
Perhaps
Checks in execute.rs
fn prepare
and match Statement::CreateTable { name, columns, .. }
Have made some programming around select in Rust
It's a little bit complicated and column names is missing I think.
In order to make gluesql competitive to (sqlite and mysql and more ) using (JS, C/C++, PHP, Java and more)
I think something like the following is required for Rust at least
(and C using gluesql. wow!)
A: Usage is: iter over colnames in order to display them in order
B: Usage on whole row is: 'simple' item for all column values
C: Usage on columns in a row
I think it's important to get a value for a named column in a 'active row'
(From my own experience)
let value = get_value_from_column_named(colnam, some_context);
SELECT user.* FROM item LEFT JOIN user ON user.id = item.user_id;
SELECT * FROM item LEFT JOIN user ON user.id = item.user_id;
Above 2 queries work but,
SELECT Item.* FROM item LEFT JOIN user ON user.id = item.user_id;
This one fails.
[ERR] { "Blend": { "TableNotFound": "item" } }
Blend failed to find table alias.
INSERT INTO TableA VALUES ("asdf");
INSERT INTO TableA VALUES ('asdf');
"asdf"
works but 'asdf'
is not accepted which should be not a problem at all.
Current
Payload::Insert(Vec<Row>)
Expected
Payload::Insert(usize)
Let's simply return a number of inserted rows.
assert_eq!(Value::I64(100), Value::OptI64(Some(100)))
// it fails
PartialEq
for Value
must be implemented manually, but for now, it is applied by using #[derive(PartialEq)]
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.