Repository navigation
feat: relation literal & from_csv - #1014
Conversation
265700e to
2f0623f
Compare
c59ee94 to
274d78c
Compare
|
I've rebased and added ad-hoc impl for RQ relation literals. The test I added should be removed, it's just for testing this part of the compiler before frontend is done. |
|
About the frontend: I don't think that we can squeeze this behavior into Currently, from has this signature: func from<table> `default_db.source`<table> -> nullWe would need a way of having these signatures: func from<table> `default_db.source`<table> inline:false -> null
func from<table> `default_db.source`<string> inline:true -> nullSome languages support this, but I don't like it that much. I would rather have two different functions: func from_csv<table> csv<string> -> null |
I'm certainly OK with trying this. It was nice to have a very small number of transforms; I can imagine if someone wants to add some data they type But OTOH |
|
(and thanks for rebasing!) |
|
How about making this a type of Where I usually need this type of thing is for mapping categoricals or enums to a description so it's usually on a RHS of a join. I currently use dbt seed tables for this but these kind of inline definitions would be neat. What are the pros and cons of implementing this via repeated SELECT vs VALUES statements? I just tried to find some online playgrounds to try this out on and it seems VALUES needs a slightly different syntax for MySQL. I don't know about BigQuery and Snowflake. Looks like VALUES might be less widely supported so SELECT is a better choice. The following works in Postgresql and Sqlite: SELECT *
FROM (
VALUES
(1, 'large'),
(2, 'medium'),
(3, 'small')
) as t0MySQL SELECT *
FROM (
VALUES
ROW(1, 'large'),
ROW(2, 'medium'),
ROW(3, 'small')
) as t0 |
This would be valid with |
|
Apologies, I hadn't caught up on all the discussion in #286 before my previous comment. @aljazerzen Thanks for the table example - it's succinct and ergonomic. @max-sixty I concur your with your concern about the increase in cardinality with SELECT * FROM 'test.csv';are possible and a user might expect to have to use Given that this is about reading inline data from a string, how about a name like from_string kind:{csv,json,yaml,...} dataSo the original example would look like: from_string kind:csv """
a,b,c
1,2,3
4,5,6
"""
filter [a > 2]Other possible names to consider for the The DuckDB csv file case was partially covered in #286 with the mention of a 'file://' prefix in the table/URI name. Another option to consider would be a |
|
Done |
264cfa2 to
bfeb722
Compare
|
I did a rebase again and prepared some pointers:
|
e09dcd8 to
7a56f1b
Compare
7a56f1b to
8117536
Compare
|
Thanks for pushing this over the line, sorry I let it linger. Does it work already? I couldn't immediately get it to work in the playground. I can add some tests and docs if so. |
|
Oh, I forgot to commit a test: |
|
Sorry, in #286 I got the impression we were going to go with |
|
Whoops, you're right. It's easy to change though. |
|
Awesome @aljazerzen ! It works great |
This would complete #286
It currently would have syntax like:
The functions for parsing & translating the expression are done, but I still need to allow
fromto take more than just a table name. I could either do that here on on top of thesemanticbranch. The most general approach would be to allow a general expression in thefromclause, which would involve lots of changes which may overlap withsemantic.What do folks think of the prql syntax? There are alternatives discussed in #286.