izveigor commented on code in PR #6662:
URL: https://github.com/apache/arrow-datafusion/pull/6662#discussion_r1237559594
##########
datafusion/physical-expr/src/array_expressions.rs:
##########
@@ -56,20 +67,29 @@ macro_rules! new_builder {
macro_rules! array {
($ARGS:expr, $ARRAY_TYPE:ident, $BUILDER_TYPE:ident) => {{
- // downcast all arguments to their common format
- let args =
- downcast_vec!($ARGS,
$ARRAY_TYPE).collect::<Result<Vec<&$ARRAY_TYPE>>>()?;
-
- let builder = new_builder!($BUILDER_TYPE, args[0].len());
+ let builder = new_builder!($BUILDER_TYPE, $ARGS[0].len());
let mut builder =
- ListBuilder::<$BUILDER_TYPE>::with_capacity(builder, args.len());
+ ListBuilder::<$BUILDER_TYPE>::with_capacity(builder, $ARGS.len());
+
// for each entry in the array
- for index in 0..args[0].len() {
- for arg in &args {
- if arg.is_null(index) {
- builder.values().append_null();
- } else {
- builder.values().append_value(arg.value(index));
+ for index in 0..$ARGS[0].len() {
Review Comment:
Your arguments seem reasonable.
I have two ideas regarding the introduction of this feature:
1) Cast all nulls to other data types:
```
select make_array(1, Null, 2 Null);
----
1, 0, 2, 0
```
2) Ignore nulls:
```
select make_array(1, Null, 2, Null);
----
1, 2
```
What do you think of these approaches @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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]