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

Add examples of DataFrame::write* methods without S3 dependency #8606

Merged
merged 5 commits into from
Dec 22, 2023

Conversation

devinjdangelo
Copy link
Contributor

Which issue does this PR close?

Closes #8551

Rationale for this change

We currently do not have an example of DataFrame::write_table, nor other DataFrame::write* methods which do not depend on an external S3 bucket.

What changes are included in this PR?

Adds examples of DataFrame::write_table and other write* methods using LocalFileSystem object store.

Are these changes tested?

Via existing tests

Are there any user-facing changes?

No

async fn main() -> Result<(), DataFusionError> {
let ctx = SessionContext::new();
let local = Arc::new(LocalFileSystem::new_with_prefix("./").unwrap());
let local_url = Url::parse("file://local").unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can simplify this by removing the LocalFileSystem register. We can show the default behavior here, and how to extend in S3 example. Let's make the first-time user climb the stairs one by one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that is definitely simpler.

Copy link
Contributor

@metesynnada metesynnada 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 the effort. LGTM.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @devinjdangelo -- I think this looks great and thank you for doing it.

Can you you please also add an entry to the readme here: https://github.com/apache/arrow-datafusion/tree/main/datafusion-examples#single-process ?

.write_table("test", DataFrameWriteOptions::new())
.await?;

df.clone()
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it would be valuable to update one of these options showing DataFrameWriteOptions

something like

// you can use DataFrameWriteOptions to control how the dataframe output is created
// for example: 
....

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed up an update with a DataFrameWriteOptions example and added the new example to the README file

@metesynnada metesynnada merged commit fd121d3 into apache:main Dec 22, 2023
22 checks passed
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you everyone 🚀

df.clone()
.write_csv(
"./datafusion-examples/test_csv/",
// DataFrameWriteOptions contains options which control how data is written
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

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.

Add a simple example of using DataFrame::write_table to the Datafusion examples?
4 participants