You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/08 06:29:13 UTC
[GitHub] [arrow-datafusion] Jimexist opened a new pull request #289: Add csv mode to datafusion cli
Jimexist opened a new pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289
# Which issue does this PR close?
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
Closes #.
# Rationale for this change
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
# What changes are included in this PR?
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
# Are there any user-facing changes?
If there are user-facing changes then we may require documentation to be updated before approving the PR.
If there are any breaking changes to public APIs, please add the `breaking change` label.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist commented on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist commented on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835144674
this shall pave the way for finally merging #281
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist edited a comment on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist edited a comment on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835337364
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q
+-----+-------+--------------------+
| num | arith | cos |
+-----+-------+--------------------+
| 1 | 3 | 0.8775825618903728 |
+-----+-------+--------------------+
1 rows in set. Query took 0 seconds.
```
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q -- --format table
+-----+-------+--------------------+
| num | arith | cos |
+-----+-------+--------------------+
| 1 | 3 | 0.8775825618903728 |
+-----+-------+--------------------+
1 rows in set. Query took 0 seconds.
```
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q -- --format csv
num,arith,cos
1,3,0.8775825618903728
1 rows in set. Query took 0 seconds.
```
```
cargo run --release --bin datafusion-cli -q -- --help
DataFusion 4.0.0-SNAPSHOT
DataFusion is an in-memory query engine that uses Apache Arrow as the memory model. It supports executing SQL queries
against CSV and Parquet files as well as querying directly against in-memory data.
USAGE:
datafusion-cli [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --batch-size <batch-size> The batch size of each query, or use DataFusion default
-p, --data-path <data-path> Path to your data, default to current directory
-f, --file <file> Execute commands from file, then exit
--format <format> Output format (possible values: table, csv) [default: table]
```
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q -- --format tsv
error: Invalid value for '--format <format>': Format 'tsv' not supported
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist edited a comment on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist edited a comment on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835337364
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q
+-----+-------+--------------------+
| num | arith | cos |
+-----+-------+--------------------+
| 1 | 3 | 0.8775825618903728 |
+-----+-------+--------------------+
1 rows in set. Query took 0 seconds.
```
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q -- --format table
+-----+-------+--------------------+
| num | arith | cos |
+-----+-------+--------------------+
| 1 | 3 | 0.8775825618903728 |
+-----+-------+--------------------+
1 rows in set. Query took 0 seconds.
```
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q -- --format csv
num,arith,cos
1,3,0.8775825618903728
1 rows in set. Query took 0 seconds.
```
```
cargo run --release --bin datafusion-cli -q -- --help
DataFusion 4.0.0-SNAPSHOT
DataFusion is an in-memory query engine that uses Apache Arrow as the memory model. It supports executing SQL queries
against CSV and Parquet files as well as querying directly against in-memory data.
USAGE:
datafusion-cli [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --batch-size <batch-size> The batch size of each query, or use DataFusion default
-p, --data-path <data-path> Path to your data, default to current directory
-f, --file <file> Execute commands from file, then exit
--format <format> Output format (possible values: table, csv) [default: table]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] codecov-commenter commented on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835151273
# [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#289](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (66bcfc4) into [master](https://codecov.io/gh/apache/arrow-datafusion/commit/b8805d4f44d4da8f16069d93ab342dc6f082ca07?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b8805d4) will **decrease** coverage by `0.17%`.
> The diff coverage is `0.00%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/arrow-datafusion/pull/289/graphs/tree.svg?width=650&height=150&src=pr&token=JXwWBKD3D9&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
- Coverage 76.19% 76.01% -0.18%
==========================================
Files 140 141 +1
Lines 23595 23650 +55
==========================================
Hits 17978 17978
- Misses 5617 5672 +55
```
| [Impacted Files](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [datafusion-cli/src/format/print\_format.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/289/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi1jbGkvc3JjL2Zvcm1hdC9wcmludF9mb3JtYXQucnM=) | `0.00% <0.00%> (ø)` | |
| [datafusion-cli/src/main.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/289/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi1jbGkvc3JjL21haW4ucnM=) | `0.00% <0.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b8805d4...66bcfc4](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist commented on a change in pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist commented on a change in pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#discussion_r628736917
##########
File path: datafusion-cli/src/main.rs
##########
@@ -51,6 +56,20 @@ pub async fn main() {
.validator(is_valid_batch_size)
.takes_value(true),
)
+ .arg(
+ Arg::with_name("file")
+ .help("Execute commands from file, then exit")
+ .short("f")
+ .long("file")
+ .validator(is_valid_file)
+ .takes_value(true),
+ )
+ .arg(
Review comment:
I'm following `psql` convention. Deviation from that is okay but would be a thoughtful decision.
So far `psql` is a bit messy because you can have `csv`, `aligned` which is table, `unaligned` which is `|` separated values. In an ideal world we should strive for `csv`, `table`, `json`, `row-json` which is basically transposed json, and some more. WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist commented on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist commented on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835142913
```
❯ cargo run --release --bin datafusion-cli -q -- --help
DataFusion 4.0.0-SNAPSHOT
DataFusion is an in-memory query engine that uses Apache Arrow as the memory model. It supports executing SQL queries
against CSV and Parquet files as well as querying directly against in-memory data.
USAGE:
datafusion-cli [FLAGS] [OPTIONS]
FLAGS:
--csv Switches to CSV (Comma-Separated Values) output mode.
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --batch-size <batch-size> The batch size of each query, or use DataFusion default
-p, --data-path <data-path> Path to your data, default to current directory
-f, --file <file> Execute commands from file, then exit
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist commented on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist commented on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835337364
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q
+-----+-------+--------------------+
| num | arith | cos |
+-----+-------+--------------------+
| 1 | 3 | 0.8775825618903728 |
+-----+-------+--------------------+
1 rows in set. Query took 0 seconds.
```
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q -- --format table
+-----+-------+--------------------+
| num | arith | cos |
+-----+-------+--------------------+
| 1 | 3 | 0.8775825618903728 |
+-----+-------+--------------------+
1 rows in set. Query took 0 seconds.
```
```
❯ echo 'select 1 num, 1 + 2 arith, cos(0.5) cos;' | cargo run --release --bin datafusion-cli -q -- --format csv
num,arith,cos
1,3,0.8775825618903728
1 rows in set. Query took 0 seconds.
```
cargo run --release --bin datafusion-cli -q -- --help
DataFusion 4.0.0-SNAPSHOT
DataFusion is an in-memory query engine that uses Apache Arrow as the memory model. It supports executing SQL queries
against CSV and Parquet files as well as querying directly against in-memory data.
USAGE:
datafusion-cli [OPTIONS]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --batch-size <batch-size> The batch size of each query, or use DataFusion default
-p, --data-path <data-path> Path to your data, default to current directory
-f, --file <file> Execute commands from file, then exit
--format <format> Output format (possible values: table, csv) [default: table]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist commented on a change in pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist commented on a change in pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#discussion_r628747103
##########
File path: datafusion-cli/src/main.rs
##########
@@ -51,6 +56,20 @@ pub async fn main() {
.validator(is_valid_batch_size)
.takes_value(true),
)
+ .arg(
+ Arg::with_name("file")
+ .help("Execute commands from file, then exit")
+ .short("f")
+ .long("file")
+ .validator(is_valid_file)
+ .takes_value(true),
+ )
+ .arg(
Review comment:
comment addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] codecov-commenter edited a comment on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835151273
# [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#289](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3f3de23) into [master](https://codecov.io/gh/apache/arrow-datafusion/commit/a947f11a8c0558c7301931a6c35a07de396d2463?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a947f11) will **decrease** coverage by `0.15%`.
> The diff coverage is `0.00%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/arrow-datafusion/pull/289/graphs/tree.svg?width=650&height=150&src=pr&token=JXwWBKD3D9&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
- Coverage 76.16% 76.01% -0.16%
==========================================
Files 140 141 +1
Lines 23603 23650 +47
==========================================
Hits 17978 17978
- Misses 5625 5672 +47
```
| [Impacted Files](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [datafusion-cli/src/format/print\_format.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/289/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi1jbGkvc3JjL2Zvcm1hdC9wcmludF9mb3JtYXQucnM=) | `0.00% <0.00%> (ø)` | |
| [datafusion-cli/src/main.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/289/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi1jbGkvc3JjL21haW4ucnM=) | `0.00% <0.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a947f11...3f3de23](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on a change in pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#discussion_r628730469
##########
File path: datafusion-cli/src/main.rs
##########
@@ -51,6 +56,20 @@ pub async fn main() {
.validator(is_valid_batch_size)
.takes_value(true),
)
+ .arg(
+ Arg::with_name("file")
+ .help("Execute commands from file, then exit")
+ .short("f")
+ .long("file")
+ .validator(is_valid_file)
+ .takes_value(true),
+ )
+ .arg(
Review comment:
I can imagine other formats in the future other than CSV and pretty (for example, JSON using the Arrow json writer)
What would you think about making the option `--format=csv` rather than `--csv`, to leave room for future formats?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] codecov-commenter edited a comment on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835151273
# [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#289](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f113486) into [master](https://codecov.io/gh/apache/arrow-datafusion/commit/d0a4552dcf07316acaa8ade7feabe5c9165f3a48?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d0a4552) will **decrease** coverage by `0.08%`.
> The diff coverage is `0.00%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/arrow-datafusion/pull/289/graphs/tree.svg?width=650&height=150&src=pr&token=JXwWBKD3D9&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
- Coverage 76.07% 75.99% -0.09%
==========================================
Files 140 141 +1
Lines 23632 23657 +25
==========================================
Hits 17978 17978
- Misses 5654 5679 +25
```
| [Impacted Files](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [datafusion-cli/src/format/print\_format.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/289/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi1jbGkvc3JjL2Zvcm1hdC9wcmludF9mb3JtYXQucnM=) | `0.00% <0.00%> (ø)` | |
| [datafusion-cli/src/main.rs](https://codecov.io/gh/apache/arrow-datafusion/pull/289/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGF0YWZ1c2lvbi1jbGkvc3JjL21haW4ucnM=) | `0.00% <0.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [d0a4552...f113486](https://codecov.io/gh/apache/arrow-datafusion/pull/289?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist commented on pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist commented on pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#issuecomment-835142807
```
❯ cargo run --release --bin datafusion-cli -q -- --csv
> select 1 num, sin(1) sin, cos(1) cos, 1+2 sum;
num,sin,cos,sum
1,0.8414709848078965,0.5403023058681398,3
1 rows in set. Query took 0 seconds.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Dandandan commented on a change in pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Dandandan commented on a change in pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#discussion_r628737157
##########
File path: datafusion-cli/src/main.rs
##########
@@ -51,6 +56,20 @@ pub async fn main() {
.validator(is_valid_batch_size)
.takes_value(true),
)
+ .arg(
+ Arg::with_name("file")
+ .help("Execute commands from file, then exit")
+ .short("f")
+ .long("file")
+ .validator(is_valid_file)
+ .takes_value(true),
+ )
+ .arg(
Review comment:
I would think at this moment we don't need to be compatible with `psql` per se regarding the command line arguments. So `--format=csv` would be a bit more user friendly I would say
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] Jimexist commented on a change in pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
Jimexist commented on a change in pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#discussion_r628744402
##########
File path: datafusion-cli/src/format/print_format.rs
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Print format variants
+use arrow::csv::writer::WriterBuilder;
+use datafusion::arrow::record_batch::RecordBatch;
+use datafusion::arrow::util::pretty;
+use datafusion::error::Result;
+use std::io::{Read, Seek, SeekFrom};
+use tempfile::tempfile;
+
+/// Allow records to be printed in different formats
+#[derive(Debug, Clone)]
+pub enum PrintFormat {
+ Csv,
+ Aligned,
+}
+
+impl PrintFormat {
+ /// print the batches to stdout using the specified format
+ pub fn print_batches(&self, batches: &[RecordBatch]) -> Result<()> {
+ match self {
+ PrintFormat::Csv => {
+ // utilizing a temp file so that we can leverage the arrow csv writer
Review comment:
thanks for the example!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb merged pull request #289: Add print format param and support for csv print format to datafusion cli
Posted by GitBox <gi...@apache.org>.
alamb merged pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] alamb commented on a change in pull request #289: Add csv mode to datafusion cli
Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #289:
URL: https://github.com/apache/arrow-datafusion/pull/289#discussion_r628730249
##########
File path: datafusion-cli/src/format/print_format.rs
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Print format variants
+use arrow::csv::writer::WriterBuilder;
+use datafusion::arrow::record_batch::RecordBatch;
+use datafusion::arrow::util::pretty;
+use datafusion::error::Result;
+use std::io::{Read, Seek, SeekFrom};
+use tempfile::tempfile;
+
+/// Allow records to be printed in different formats
+#[derive(Debug, Clone)]
+pub enum PrintFormat {
+ Csv,
+ Aligned,
+}
+
+impl PrintFormat {
+ /// print the batches to stdout using the specified format
+ pub fn print_batches(&self, batches: &[RecordBatch]) -> Result<()> {
+ match self {
+ PrintFormat::Csv => {
+ // utilizing a temp file so that we can leverage the arrow csv writer
Review comment:
I don't think you need to use an actual `tempfile` here. You can probably print directly to a `Vec<u8>` in memory. Here is an example of how to do so from IOx:
https://github.com/influxdata/influxdb_iox/blob/411cf134e9087198f74fe78ccb3c62e16344bf2f/influxdb_iox_client/src/format.rs#L133-L143
##########
File path: datafusion-cli/src/format/print_format.rs
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Print format variants
+use arrow::csv::writer::WriterBuilder;
+use datafusion::arrow::record_batch::RecordBatch;
+use datafusion::arrow::util::pretty;
+use datafusion::error::Result;
+use std::io::{Read, Seek, SeekFrom};
+use tempfile::tempfile;
+
+/// Allow records to be printed in different formats
+#[derive(Debug, Clone)]
+pub enum PrintFormat {
+ Csv,
+ Aligned,
+}
+
+impl PrintFormat {
+ /// print the batches to stdout using the specified format
+ pub fn print_batches(&self, batches: &[RecordBatch]) -> Result<()> {
+ match self {
+ PrintFormat::Csv => {
+ // utilizing a temp file so that we can leverage the arrow csv writer
+ // ideally the upstream shall take a more generic trait
+ let mut file = tempfile()?;
+ {
+ let builder = WriterBuilder::new().has_headers(true);
+ let mut writer = builder.build(&file);
+ batches
+ .iter()
+ .for_each(|batch| writer.write(batch).unwrap());
Review comment:
I think it would be good to return the error here rather than calling `unwrap()`
##########
File path: datafusion-cli/src/format/print_format.rs
##########
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Print format variants
+use arrow::csv::writer::WriterBuilder;
+use datafusion::arrow::record_batch::RecordBatch;
+use datafusion::arrow::util::pretty;
+use datafusion::error::Result;
+use std::io::{Read, Seek, SeekFrom};
+use tempfile::tempfile;
+
+/// Allow records to be printed in different formats
+#[derive(Debug, Clone)]
+pub enum PrintFormat {
+ Csv,
+ Aligned,
+}
+
+impl PrintFormat {
+ /// print the batches to stdout using the specified format
+ pub fn print_batches(&self, batches: &[RecordBatch]) -> Result<()> {
+ match self {
+ PrintFormat::Csv => {
+ // utilizing a temp file so that we can leverage the arrow csv writer
+ // ideally the upstream shall take a more generic trait
+ let mut file = tempfile()?;
+ {
+ let builder = WriterBuilder::new().has_headers(true);
+ let mut writer = builder.build(&file);
+ batches
+ .iter()
+ .for_each(|batch| writer.write(batch).unwrap());
+ }
+ let mut data = String::new();
+ file.seek(SeekFrom::Start(0))?;
+ file.read_to_string(&mut data)?;
+ println!("{}", data);
+ }
+ PrintFormat::Aligned => pretty::print_batches(batches)?,
Review comment:
FWIW I called this format `Pretty` when I was doing something similar in IOx -- I don't think it is really important, however
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org