Skip to content

Bugfix: Remove df-cli specific SQL statment options before executing with DataFusion #8426

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Dec 6, 2023

Conversation

devinjdangelo
Copy link
Contributor

@devinjdangelo devinjdangelo commented Dec 5, 2023

Which issue does this PR close?

Closes #8421

Rationale for this change

See issue (PR in datafusion caused regression in datafusion-cli when using datafusion-cli specific SQL statement options)

What changes are included in this PR?

Any arbitrary SQL statement option parsed in datafusion-cli is removed if found before executing the plan.

Are these changes tested?

Yes, modified existing datafusion-cli unit test to make sure FileTypeWriterOptions::build will not throw an error when passing ObjectStore related datafusion-cli options.

Are there any user-facing changes?

No

@devinjdangelo devinjdangelo mentioned this pull request Dec 5, 2023
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.

I like this approach -- thank you @devinjdangelo

) -> Result<AmazonS3Builder> {
let bucket_name = get_bucket_name(url)?;
let mut builder = AmazonS3Builder::from_env().with_bucket_name(bucket_name);

if let (Some(access_key_id), Some(secret_access_key)) = (
cmd.options.get("access_key_id"),
cmd.options.get("secret_access_key"),
cmd.options.remove("access_key_id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a very subtle change -- maybe we can add a comment explaining why these options are removed

Likewise below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some comments explaining why the keys are removed/plan made mutable within datafusion-cli.

I also updated one of the unit tests to invoke FileTypeWriterOptions::build to test for this issue in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you

@devinjdangelo devinjdangelo marked this pull request as ready for review December 6, 2023 13:23
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.

Looks great to me -- thank you @devinjdangelo

@@ -221,10 +221,12 @@ async fn exec_and_print(
| LogicalPlan::Analyze(_)
);

if let LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) = &plan {
// Note that cmd is a mutable reference so that create_external_table function can remove all
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

) -> Result<AmazonS3Builder> {
let bucket_name = get_bucket_name(url)?;
let mut builder = AmazonS3Builder::from_env().with_bucket_name(bucket_name);

if let (Some(access_key_id), Some(secret_access_key)) = (
cmd.options.get("access_key_id"),
cmd.options.get("secret_access_key"),
cmd.options.remove("access_key_id"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you

@alamb alamb merged commit 99bf509 into apache:main Dec 6, 2023
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Dec 15, 2023
…with DataFusion (apache#8426)

* remove df-cli specific options from create external table options

* add test and comments

* cargo fmt

* merge main

* cargo toml format
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create s3 failed
2 participants