comphead commented on code in PR #18653:
URL: https://github.com/apache/datafusion/pull/18653#discussion_r2524319913
##########
datafusion/functions/src/unicode/substr.rs:
##########
@@ -70,14 +74,30 @@ impl Default for SubstrFunc {
impl SubstrFunc {
pub fn new() -> Self {
+ let string =
Coercion::new_exact(TypeSignatureClass::Native(logical_string()));
+ let int64 = Coercion::new_implicit(
+ TypeSignatureClass::Native(logical_int64()),
+ vec![TypeSignatureClass::Native(logical_int32())],
+ NativeType::Int64,
+ );
Self {
- signature: Signature::user_defined(Volatility::Immutable)
- .with_parameter_names(vec![
- "str".to_string(),
- "start_pos".to_string(),
- "length".to_string(),
- ])
- .expect("valid parameter names"),
+ signature: Signature::one_of(
+ vec![
+ TypeSignature::Coercible(vec![string.clone(),
int64.clone()]),
+ TypeSignature::Coercible(vec![
Review Comment:
👍
##########
datafusion/functions/src/unicode/substr.rs:
##########
@@ -70,14 +74,30 @@ impl Default for SubstrFunc {
impl SubstrFunc {
pub fn new() -> Self {
+ let string =
Coercion::new_exact(TypeSignatureClass::Native(logical_string()));
+ let int64 = Coercion::new_implicit(
+ TypeSignatureClass::Native(logical_int64()),
+ vec![TypeSignatureClass::Native(logical_int32())],
+ NativeType::Int64,
+ );
Self {
- signature: Signature::user_defined(Volatility::Immutable)
- .with_parameter_names(vec![
- "str".to_string(),
- "start_pos".to_string(),
- "length".to_string(),
- ])
- .expect("valid parameter names"),
+ signature: Signature::one_of(
+ vec![
+ TypeSignature::Coercible(vec![string.clone(),
int64.clone()]),
+ TypeSignature::Coercible(vec![
+ string.clone(),
+ int64.clone(),
+ int64.clone(),
+ ]),
+ ],
+ Volatility::Immutable,
+ )
+ .with_parameter_names(vec![
Review Comment:
would be even nice to refactor such blocks in future so param names and
types put together like
```
f.withNames("str", "str_pos").withTpyes("string", "i64")
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]