-
Notifications
You must be signed in to change notification settings - Fork 219
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
fix(prqlc): allow prqlc compile | duckdb
#2594
Conversation
for more information, see https://pre-commit.ci
(By the way, I think a combination of prqlc and the DuckDB CLI seems more Unix-like and a better path than using the prql-query CLI with DuckDB built in......) (Related to PRQL/prql-query#22) prqlc compile --target sql.duckdb | duckdb --json >output.json |
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.
Excellent, thanks a lot!
I added a couple of comments & suggestions, but otherwise good to go
```sh | ||
$ prqlc compile | duckdb | ||
from `penguins.csv` | ||
take 3 |
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.
Hmmm, this doesn't work so well on mine — does it for you?
I think maybe we write the Ctrl-d
to stdout?
prqlc compile | duckdb
from `penguins.csv`
take 3
Error: near line 1: Parser Error: syntax error at or near "Enter"
LINE 1: Enter PRQL, then ctrl-d:
^
(Is there a way of retaining the query? I worry this approach is OK but loses the query on each run. But it's still reasonable to show the example)
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 that the prqlc
you are using was not built from this PR. (the prompt message is different)
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 of retaining the query?
I believe the query will remain visible in the terminal as shown in this README, and I have verified that it works with bash and fish on Linux and PowerShell on Windows.
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 that the
prqlc
you are using was not built from this PR. (the prompt message is different)
Sorry, you're correct, apologies
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 believe the query will remain visible in the terminal as shown in this README, and I have verified that it works with bash and fish on Linux and PowerShell on Windows.
Yes!
A total aside — something @snth and I discussed on the dev call was building a TUI, similar to the playground, where typing a query would pipe through to duckdb on each keystroke, could be a good way of exploring a dataset from the terminal
@@ -292,7 +292,7 @@ impl Command { | |||
// it's confusing whether it's waiting for input or not. This | |||
// offers the prompt. | |||
if input.is_stdin() && atty::is(atty::Stream::Stdin) { | |||
println!("Enter PRQL, then ctrl-d:\n"); | |||
println!("# Enter PRQL, then press ctrl-d or ctrl-z (windows) to compile:\n"); |
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.
println!("# Enter PRQL, then press ctrl-d or ctrl-z (windows) to compile:\n"); | |
eprintln!("# Enter PRQL, then press ctrl-d or ctrl-z (windows) to compile:\n"); |
...I think this will solve the issue above
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.
FYI we could use this approach to print the correct string:
prql/prql-compiler/prqlc/src/cli.rs
Line 508 in e32c586
#[cfg(not(unix))] |
I do think this is a great pattern, agree. |
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 good.
Thanks for your reviews! I think I have addressed most of the comments, so I will merge this. |
Fix comments displayed in interactive mode and make interactive mode output valid SQL output.
(It also fixes #2569)
This PR allows PRQL to be executed interactively by piping
prqlc compile
toduckdb
,sqlite3
, etc.I have also added a note to the prqlc README on how to use the
prqlc compile
command, which I believe is the minimum required to try prqlc.And this README also has been changed to appear in the book.