You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2023/11/18 17:02:28 UTC

[PR] Check file_name instead of path when checking for expected file exten… [arrow-datafusion]

andygrove opened a new pull request, #8265:
URL: https://github.com/apache/arrow-datafusion/pull/8265

   …sion
   
   ## 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 https://github.com/apache/arrow-datafusion/issues/8264
   
   ## 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.  
   -->
   
   Fix check for expected file extension to use `file_name` instead of `path`, which could include a trailing `/`.
   
   ## 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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

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

   @Dandandan After applying this fix I was able to run queries in Ballista from your df33 branch.


-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #8265:
URL: https://github.com/apache/arrow-datafusion/pull/8265#discussion_r1398269752


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -859,7 +859,7 @@ impl SessionContext {
         // check if the file extension matches the expected extension
         for path in &table_paths {
             let file_name = path.prefix().filename().unwrap_or_default();
-            if !path.as_str().ends_with(&option_extension) && file_name.contains('.') {
+            if !file_name.ends_with(&option_extension) && file_name.contains('.') {

Review Comment:
   I think this check is just ill-formed, if the ListingTableUrl is to a directory containing a `.` this check will reject it. I'm not sure what this check is here for tbh...



-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove closed pull request #8265: Use file_name instead of path when checking for expected file extension
URL: https://github.com/apache/arrow-datafusion/pull/8265


-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #8265:
URL: https://github.com/apache/arrow-datafusion/pull/8265#discussion_r1398483148


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -859,7 +859,7 @@ impl SessionContext {
         // check if the file extension matches the expected extension
         for path in &table_paths {
             let file_name = path.prefix().filename().unwrap_or_default();
-            if !path.as_str().ends_with(&option_extension) && file_name.contains('.') {
+            if !file_name.ends_with(&option_extension) && file_name.contains('.') {

Review Comment:
   `ListingTableUrl` is a DataFusion concept, perhaps your checkout is behind main?



-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on code in PR #8265:
URL: https://github.com/apache/arrow-datafusion/pull/8265#discussion_r1398374204


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -859,7 +859,7 @@ impl SessionContext {
         // check if the file extension matches the expected extension
         for path in &table_paths {
             let file_name = path.prefix().filename().unwrap_or_default();
-            if !path.as_str().ends_with(&option_extension) && file_name.contains('.') {
+            if !file_name.ends_with(&option_extension) && file_name.contains('.') {

Review Comment:
   ```suggestion
               if (!path.as_str().ends_with(option_extension.clone().as_str())
                   && !path.is_collection())
                   || (!path
                       .as_str()
                       .ends_with((option_extension.clone() + "/").as_str())
                       && path.is_collection())
              {
   ```
   If the path ends with a forward slash `/`, then check the extension with another forward slash `/`. Otherwise, simply check the extension.



-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #8265:
URL: https://github.com/apache/arrow-datafusion/pull/8265#discussion_r1398481779


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -859,7 +859,7 @@ impl SessionContext {
         // check if the file extension matches the expected extension
         for path in &table_paths {
             let file_name = path.prefix().filename().unwrap_or_default();
-            if !path.as_str().ends_with(&option_extension) && file_name.contains('.') {
+            if !file_name.ends_with(&option_extension) && file_name.contains('.') {

Review Comment:
   That doesn't compile for me. Perhaps this method isn't available in the version of arrow-rs that we are currently using? 
   
   ```
   no method named `is_collection` found for reference `&ListingTableUrl` in the current scope
   ```



-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

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

   Closing this in favor of https://github.com/apache/arrow-datafusion/pull/8267


-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #8265:
URL: https://github.com/apache/arrow-datafusion/pull/8265#discussion_r1398269889


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -859,7 +859,7 @@ impl SessionContext {
         // check if the file extension matches the expected extension
         for path in &table_paths {
             let file_name = path.prefix().filename().unwrap_or_default();
-            if !path.as_str().ends_with(&option_extension) && file_name.contains('.') {
+            if !file_name.ends_with(&option_extension) && file_name.contains('.') {

Review Comment:
   ```suggestion
               if !file_name.ends_with(&option_extension) && !path.is_collection() {
   ```
   Perhaps?



-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on code in PR #8265:
URL: https://github.com/apache/arrow-datafusion/pull/8265#discussion_r1398374204


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -859,7 +859,7 @@ impl SessionContext {
         // check if the file extension matches the expected extension
         for path in &table_paths {
             let file_name = path.prefix().filename().unwrap_or_default();
-            if !path.as_str().ends_with(&option_extension) && file_name.contains('.') {
+            if !file_name.ends_with(&option_extension) && file_name.contains('.') {

Review Comment:
   ```suggestion
               if (!path.as_str().ends_with(option_extension.clone().as_str())
                   && !path.is_collection())
                   || (!path
                       .as_str()
                       .ends_with((option_extension.clone() + "/").as_str())
                       && path.is_collection())
              {
   ```
   If the path ends with a forward slash `/`, then check the extension with another forward slash `/`. Otherwise, simply check the extension.



-- 
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@arrow.apache.org

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


Re: [PR] Use file_name instead of path when checking for expected file extension [arrow-datafusion]

Posted by "Weijun-H (via GitHub)" <gi...@apache.org>.
Weijun-H commented on PR #8265:
URL: https://github.com/apache/arrow-datafusion/pull/8265#issuecomment-1817817745

   > This probably regression after #7972 We should add a test with dot in the folder name
   > 
   > @Weijun-H
   
   I added the test for the directory with `.` in #8267


-- 
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@arrow.apache.org

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