-
Notifications
You must be signed in to change notification settings - Fork 32
Support "COPY FROM/TO PROGRAM '...' WITH (format parquet)" #146
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #146 +/- ##
==========================================
+ Coverage 90.84% 91.03% +0.18%
==========================================
Files 92 95 +3
Lines 10442 10759 +317
==========================================
+ Hits 9486 9794 +308
- Misses 956 965 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/arrow_parquet/uri_utils.rs
Outdated
|
|
||
| // permission check is not needed for stdin/out | ||
| if uri_info.stdio_tmp_fd.is_some() { | ||
| if uri_info.stdio_tmp_fd.is_some() && !is_program { |
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.
when would you have stdin + program?
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 is fine (we use tmp file as intermediate step for both stdio and program) let me rename it to reduce confusion.
| pipe().unwrap_or_else(|e| panic!("Failed to create command pipe: {e}")); | ||
|
|
||
| #[cfg(unix)] | ||
| let mut command = Command::new("/bin/sh") |
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.
can we use the same functions that COPY uses?
78499b6 to
2778946
Compare
pgguru
left a comment
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 pretty good overall; one q, mainly to fill in some of my Rust gaps.
|
|
||
| // Write temp file to pipe file | ||
| std::io::copy(&mut file, &mut pipe_file) | ||
| .unwrap_or_else(|e| panic!("Failed to copy file to command stdin: {e}")); |
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'm not great at Rust, so there may be some semantic misunderstanding here, but how does this differ from .expect(), just no access to the underlying value for the message?
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.
std::io::copy returns Result. We want to extract error to also print it via unwrap_or_else. We cannot do that with expect.
2778946 to
36bf1c8
Compare
Now it is possible to use programs with
COPY table TO/FROM PROGRAM '...' WITH (format parquet)syntax.e.g.
Similar to how we support
COPY TO/FROM stdin/stdout WITH(format parquet), we use a temp file as intermediate file and finally we copy from/to program's stdout/stdin by piping the temp file.Closes #147.