You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jonahgao (via GitHub)" <gi...@apache.org> on 2023/07/25 06:04:42 UTC

[GitHub] [arrow-datafusion] jonahgao opened a new pull request, #7080: Add Utf8->Binary type coercion for comparison

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

   # 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.
   -->
   
   Partial fix for #7039.
   
   # Rationale for this change
   The following casts should be safe:
   - Utf8 -> Binary | LargeBinary
   - LargetUtf8 | Binary -> LargeBinary
   
   
   <!--
    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@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb merged pull request #7080: Add Utf8->Binary type coercion for comparison

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #7080:
URL: https://github.com/apache/arrow-datafusion/pull/7080


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


[GitHub] [arrow-datafusion] jonahgao commented on a diff in pull request #7080: Add Utf8->Binary type coercion for comparison

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


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -766,6 +767,23 @@ fn string_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType>
     }
 }
 
+/// Coercion rules for Binaries: the type that both lhs and rhs can be
+/// casted to for the purpose of a computation
+fn binary_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
+    use arrow::datatypes::DataType::*;
+    match (lhs_type, rhs_type) {
+        (Binary, Binary) | (Utf8, Binary) | (Binary, Utf8) => Some(Binary),
+        (LargeBinary, LargeBinary)
+        | (Binary, LargeBinary)
+        | (LargeBinary, Binary)
+        | (Utf8, LargeBinary)
+        | (LargeBinary, Utf8)
+        | (LargeUtf8, LargeBinary)
+        | (LargeBinary, LargeUtf8) => Some(LargeBinary),

Review Comment:
   Updated. Thank you @jackwener :heart: 



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


[GitHub] [arrow-datafusion] jonahgao commented on pull request #7080: Add Utf8->Binary type coercion for comparison

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

   > Thanks @jonahgao ❤️
   > 
   > I took the liberty of merging up from main to get a fix for CI failures and pushed a small sql level test in sqllogictests
   
   Thank you @alamb  ❤️


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


[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #7080: Add Utf8->Binary type coercion for comparison

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


##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -766,6 +767,23 @@ fn string_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType>
     }
 }
 
+/// Coercion rules for Binaries: the type that both lhs and rhs can be
+/// casted to for the purpose of a computation
+fn binary_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
+    use arrow::datatypes::DataType::*;
+    match (lhs_type, rhs_type) {
+        (Binary, Binary) | (Utf8, Binary) | (Binary, Utf8) => Some(Binary),
+        (LargeBinary, LargeBinary)
+        | (Binary, LargeBinary)
+        | (LargeBinary, Binary)
+        | (Utf8, LargeBinary)
+        | (LargeBinary, Utf8)
+        | (LargeUtf8, LargeBinary)
+        | (LargeBinary, LargeUtf8) => Some(LargeBinary),

Review Comment:
   we can use 
   ```rs
   (LargeBinary, Utf8 | LargeUtf8 | Binary | LargeBinary) | (Utf8 | LargeUtf8 | Binary | LargeBinary, LargeBinary)
   ```



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