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

[GitHub] [arrow-datafusion] jayzhan211 opened a new pull request, #6607: Array cast

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

   # 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 #6558.
   
   # 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.  
   -->
   BuiltinScalarFunction::MakeArray with different kinds of DataType is not supported yet
   
   # 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.
   -->
   BuiltinScalarFunction::MakeArray use `array()` in `datafusion/physical-expr/src/array_expressions.rs`, we support casting internally in `array_array()`. 
   
   Type coercion is based on `datafusion_expr::comparison_coercion`
   Cast is based on `arrow-cast`
   
   # 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)?
   -->
   
   unit tests are added
   sqllogictest for float is added
   
   `make_array(Int64(1), Int32(2))` is not included in sqllogictest, since Int64() is not supported yet and not trivial for me to support in this PR, also no other way to differentiate value from int64 and int32.
   
   ```
   External error: query failed: DataFusion error: Error during planning: Invalid function 'int64'.
   Did you mean 'atan'?
   [SQL] select make_array(Int64(1))
   at tests/sqllogictests/test_files/array.slt:213
   ```
   
   # 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] jayzhan211 commented on pull request #6607: Support internal cast for BuiltinScalarFunction::MakeArray

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

   Let me add some tests


-- 
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] jayzhan211 commented on pull request #6607: Support internal cast for BuiltinScalarFunction::MakeArray

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

   @izveigor  Ready for review, thanks


-- 
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 #6607: Support internal cast for BuiltinScalarFunction::MakeArray

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


-- 
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 commented on a diff in pull request #6607: Support internal cast for BuiltinScalarFunction::MakeArray

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


##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -85,7 +87,18 @@ fn array_array(args: &[ArrayRef]) -> Result<ArrayRef> {
         ));
     }
 
-    let data_type = args[0].data_type();
+    let data_type = args

Review Comment:
   I think we are trying to avoid casting in the physical-exprs and instead want to cast in the `analyze` pass (so the rest of the optimizer passes see the correct types)
   
   I think this is the relevant code: 
   
   https://github.com/apache/arrow-datafusion/blob/071a2a6dfd43b3b225fce1af8838fa95c79f9ede/datafusion/optimizer/src/analyzer/type_coercion.rs#L389-L397
   
   Perhaps it needs to be taught about array arguments 🤔 
   



-- 
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 commented on a diff in pull request #6607: Support internal cast for BuiltinScalarFunction::MakeArray

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


##########
datafusion/optimizer/src/analyzer/type_coercion.rs:
##########
@@ -602,6 +603,39 @@ fn coerce_arguments_for_signature(
         .collect::<Result<Vec<_>>>()
 }
 
+fn coerce_arguments_for_fun(

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

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


[GitHub] [arrow-datafusion] alamb commented on pull request #6607: Support internal cast for BuiltinScalarFunction::MakeArray

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

   > LGTM. If you have more time, you can add more sql logic tests.
   
   Specifically, I think adding coverage for NULL and arrays would be helpful:
   
   ```sql
   select make_array(null, 1.0)
   ```
   
   ```sql
   select make_array(1.0, '2', null)
   ```
   
   ```sql
   create table foo (x int, y double) as values (1, 2.0);
   select make_array(x, y) from foo;
   ```


-- 
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 commented on pull request #6607: Support internal cast for BuiltinScalarFunction::MakeArray

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

   I plan to merge this PR tomorrow, unless @jayzhan211  would like more time to add tests


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