-
Notifications
You must be signed in to change notification settings - Fork 209
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
Schemaless data support #1046
Schemaless data support #1046
Conversation
Convert Row to enum with Vec and Map variants. Make column_defs in Schema optional.
Pull Request Test Coverage Report for Build 3775416308
💛 - Coveralls |
e.g. CREATE TABLE Foo; INSERT INTO Foo VALUES ('{ "a": "hello", "b": true }'), ('{ "a": 100 }'); SELECT a FROM Foo;
if columns are not provided, then now it prints without empty brackets. e.g. CREATE TABLE Foo; -- columns: vec![]
…and (&[String], &DataRow)
Also add sample test cases to test-suite
Query planner does not work for schemaless data for now. TBD in following works.
… Row::Map variant
3e819d6
to
0717139
Compare
1e9a2e1
to
14442b1
Compare
ShowIndexes always returns the shape of Row::Vec
d3aa525
to
9d10471
Compare
"SELECT | ||
Player.id AS player_id, | ||
Player.name AS player_name, | ||
Item.obj['cost'] AS item_cost |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we cannot unnest nested Map if identical key has both Map and other type
gluesql> CREATE TABLE Items;
Table created
gluesql> INSERT INTO Items VALUES ('{"a": {"x": 1}}');
1 row inserted
gluesql> INSERT INTO Items VALUES ('{"a": 1}');
1 row inserted
gluesql> SELECT * FROM Items;
| a |
|-------|
| [MAP] |
| 1 |
gluesql> SELECT a['x'] FROM Items limit 1;
| a['x'] |
|--------|
| 1 |
gluesql> SELECT a['x'] FROM Items;
[error] selector requires MAP or LIST types
We may need some function like get_type(columnName)
?
SELECT
CASE
WHEN get_type(a) == 'MAP' THEN a['x']
ELSE a
END
FROM Items;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds nice to have a new function that can retrieve the type of value.
Then, how about TYPEOF
..?
SELECT
CASE
WHEN TYPEOF(a) = 'MAP' THEN a['x']
ELSE a
END
FROM Items;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that!
TYPEOF sounds better 👍
.as_str()); | ||
|
||
test!( | ||
"SELECT name, dex, rare FROM Item WHERE id = 100", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to filter with Map like this?
gluesql> SELECT * FROM Item WHERE obj = '{"cost": 3000}';
-- currently 0 rows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PartialEq between Value::Map(_)
s is implemented so it can be supported. we can consider using CAST
for now.
SELECT * FROM Item WHERE obj = CAST('{ "cost": 3000 }' AS MAP);
Not supported yet, we need to add MAP
cast to Value::try_cast_from_literal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems good overall. It was an interesting piece of work! thank you!
Convert Row to enum with Vec and Map variants.
Make column_defs in Schema optional.
..
e.g.