Skip to content
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

#62 Added cli tool to export data in a csv format #85

Merged
merged 2 commits into from
Apr 19, 2024

Conversation

klangner
Copy link
Contributor

This tool is quite useful for me. In the futuree I plan to add support for selecting the columns and saving as json

@WenyXu WenyXu requested a review from Jefffrey April 18, 2024 15:58
Copy link
Collaborator

@WenyXu WenyXu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

struct Cli {
/// Path to the orc file
file: PathBuf,
/// Output file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe need to enhance doc here to indicate it outputs to stdout if not provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

let cli = Cli::parse();
let f = File::open(&cli.file)?;
let output_writer: Box<dyn io::Write> = if let Some(output) = cli.output {
Box::new(File::create(output).unwrap())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Box::new(File::create(output).unwrap())
Box::new(File::create(output)?)

Let's take advantage of the Result return type 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Box::new(io::stdout())
};

let reader = ArrowReaderBuilder::try_new(f).unwrap().build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let reader = ArrowReaderBuilder::try_new(f).unwrap().build();
let reader = ArrowReaderBuilder::try_new(f)?.build();

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@klangner klangner requested a review from Jefffrey April 19, 2024 07:18
Copy link
Collaborator

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this 👍

@Jefffrey Jefffrey merged commit 98b4a1e into datafusion-contrib:main Apr 19, 2024
9 checks passed
waynexia pushed a commit that referenced this pull request Oct 24, 2024
* #62 Added cli tool to export data in a csv format

* CR fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants