-
Notifications
You must be signed in to change notification settings - Fork 706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(functions): add new function: map_pick #15573
base: main
Are you sure you want to change the base?
Conversation
Currently, it has been implemented:
|
|_, _, _| Value::Scalar(()), | ||
); | ||
|
||
registry.register_passthrough_nullable_2_arg( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since map_pick
has a variable number of arguments, it's better to implement this function using the factory function.
You can refer to these Factory functions as examples
https://github.com/datafuselabs/databend/blob/main/src/query/functions/src/scalars/string_multi_args.rs#L88
https://github.com/datafuselabs/databend/blob/main/src/query/functions/src/scalars/string_multi_args.rs#L247
https://github.com/datafuselabs/databend/blob/main/src/query/functions/src/scalars/geo.rs#L311
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, I have implemented: map_pick(map, keys...)
. However, at the same time, is it possible to directly remove the register_passthrough_nullable_2_arg
, and also need to support ArrayType args in the factory method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, please remove register_passthrough_nullable_2_arg
, and support array type in the factory.
0f8276d
to
b3bff22
Compare
|_, _, _| Value::Scalar(()), | ||
); | ||
|
||
registry.register_passthrough_nullable_2_arg( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, please remove register_passthrough_nullable_2_arg
, and support array type in the factory.
b3bff22
to
bacdd71
Compare
76e52ea
to
0b75c3e
Compare
return None; | ||
} | ||
|
||
if !matches!(args_type[0], DataType::Map(_) | DataType::EmptyMap) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check args_type[0].remove_nullable()
, as the type may be nullable map.
_ => None, | ||
}; | ||
let key_match = match args_type.len() { | ||
2 => args_type.get(1).map_or(false, |t| match t { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the arguments number is two, the second argument may be an array type or a key type.
}; | ||
let key_match = match args_type.len() { | ||
2 => args_type.get(1).map_or(false, |t| match t { | ||
DataType::Array(_) => inner_key_type.map_or(false, |key_type| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the data type may be nullable array, we need use remove_nullable
function to get the inner type.
_ => unreachable!(), | ||
}, | ||
ValueRef::Column(Column::Map(c)) => { | ||
KvPair::<GenericType<0>, GenericType<1>>::try_downcast_column(&c.values).unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the column may be a nullable map column
builder.put_item((k.clone(), v.clone())); | ||
} | ||
} | ||
builder.commit_row(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those code logic seems not correct, arg.as_scalar()
will panic if the value is a column. and the builder need to work for every row, not only the first value.
Hi @hanxuanliang It's been a long time since last update, have you made any progress recently? |
I'm sorry that the issue has been delayed recently due to personal matters. I will finish the following pr content at the weekend |
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
part of #15295
Tests
Type of change
This change is