You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "liamzwbao (via GitHub)" <gi...@apache.org> on 2025/06/22 17:00:24 UTC

[PR] datafusion-cli: Use correct S3 region if it is not specified [datafusion]

liamzwbao opened a new pull request, #16502:
URL: https://github.com/apache/datafusion/pull/16502

   ## 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 #16306.
   
   ## 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 these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## 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 `api 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.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] datafusion-cli: Use correct S3 region if it is not specified [datafusion]

Posted by "liamzwbao (via GitHub)" <gi...@apache.org>.
liamzwbao commented on PR #16502:
URL: https://github.com/apache/datafusion/pull/16502#issuecomment-3002260982

   Hi @alamb, this PR is ready for review! 
   
   One concern here is whether it is acceptable to test against a bucket outside of datafusion, but I couldn’t find a good way to test region retry against local minio.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] datafusion-cli: Use correct S3 region if it is not specified [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #16502:
URL: https://github.com/apache/datafusion/pull/16502#issuecomment-3002266142

   Thanks @liamzwbao  -- I'll put this one on my review queue for tomorrow


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] datafusion-cli: Use correct S3 region if it is not specified [datafusion]

Posted by "liamzwbao (via GitHub)" <gi...@apache.org>.
liamzwbao commented on code in PR #16502:
URL: https://github.com/apache/datafusion/pull/16502#discussion_r2167939780


##########
datafusion-cli/src/exec.rs:
##########
@@ -231,10 +231,24 @@ pub(super) async fn exec_and_print(
         let adjusted =
             AdjustedPrintOptions::new(print_options.clone()).with_statement(&statement);
 
-        let plan = create_plan(ctx, statement).await?;
+        // Only clone the statement if it's a CreateExternalTable

Review Comment:
   Sure, I also feel like putting the logic here hurts the readability. 
   
   I searched in the code and looks like it's probably ok to always clone the statement here, so I simplify the logic in the `exec_and_print` to make it a bit clearer.
   
   Also created an issue #16559 to encapsulate the logic in a followup PR



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] datafusion-cli: Use correct S3 region if it is not specified [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #16502:
URL: https://github.com/apache/datafusion/pull/16502#discussion_r2167502727


##########
datafusion-cli/src/exec.rs:
##########
@@ -231,10 +231,24 @@ pub(super) async fn exec_and_print(
         let adjusted =
             AdjustedPrintOptions::new(print_options.clone()).with_statement(&statement);
 
-        let plan = create_plan(ctx, statement).await?;
+        // Only clone the statement if it's a CreateExternalTable

Review Comment:
   This logic is pretty specific to S3 and `create_table` -- inlining it here obscures the rest of the control flow that is happening.
   
   Is there any way we can encapsulate these special cases somewhere? 
   
   Perhaps something like 
   ```rust
   struct StatementExecutor {
     statement: DFStatement 
     ...
     // should we automatically look up the region of a failed s3 request?
      retry_region: bool,
   }
   impl StatementExecutor {
     async fn execute(&mut self) {}
   }
   ```
   
   Then this loop could look something like
   ```for statement in statements {
     StatementExecutor::new(ctx, print_options).await?;
   }
   ```
   ?
     
   



##########
datafusion-cli/src/exec.rs:
##########
@@ -231,10 +231,24 @@ pub(super) async fn exec_and_print(
         let adjusted =
             AdjustedPrintOptions::new(print_options.clone()).with_statement(&statement);
 
-        let plan = create_plan(ctx, statement).await?;
+        // Only clone the statement if it's a CreateExternalTable

Review Comment:
   I think then we would have a place to put `retry-region` 



##########
datafusion-cli/src/object_storage.rs:
##########
@@ -32,15 +32,28 @@ use aws_config::BehaviorVersion;
 use aws_credential_types::provider::error::CredentialsError;
 use aws_credential_types::provider::{ProvideCredentials, SharedCredentialsProvider};
 use log::debug;
-use object_store::aws::{AmazonS3Builder, AwsCredential};
+use object_store::aws::{AmazonS3Builder, AmazonS3ConfigKey, AwsCredential};
 use object_store::gcp::GoogleCloudStorageBuilder;
 use object_store::http::HttpBuilder;
 use object_store::{ClientOptions, CredentialProvider, ObjectStore};
 use url::Url;
 
+#[cfg(not(test))]
+use object_store::aws::resolve_bucket_region;

Review Comment:
   👍 



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] datafusion-cli: Use correct S3 region if it is not specified [datafusion]

Posted by "liamzwbao (via GitHub)" <gi...@apache.org>.
liamzwbao commented on code in PR #16502:
URL: https://github.com/apache/datafusion/pull/16502#discussion_r2167939780


##########
datafusion-cli/src/exec.rs:
##########
@@ -231,10 +231,24 @@ pub(super) async fn exec_and_print(
         let adjusted =
             AdjustedPrintOptions::new(print_options.clone()).with_statement(&statement);
 
-        let plan = create_plan(ctx, statement).await?;
+        // Only clone the statement if it's a CreateExternalTable

Review Comment:
   Sure, I also feel like putting the logic here hurts the readability. 
   
   I searched in the code and looks like it's probably ok to always clone the statement here, so I simplify the logic in the `exec_and_print` to make it a bit clearer.
   
   I can revert to the previous version if you think that one is better.
   
   Also created an issue #16559 to encapsulate the logic in a followup PR



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org