Minor: return NULL for range and generate_series#10275
Conversation
| TypeSignature::Exact(vec![Int64, Int64]), | ||
| TypeSignature::Exact(vec![Int64, Int64, Int64]), | ||
| TypeSignature::Exact(vec![Date32, Date32, Interval(MonthDayNano)]), | ||
| TypeSignature::Any(3), |
There was a problem hiding this comment.
Does this mean we need to find a new kind of signature that accepts either one exact type or null 🤔
There was a problem hiding this comment.
I think it would be better to have a new Signature. Maybe I can add more signatures in the following PR along with dealing #10200
There was a problem hiding this comment.
I'm thinking of something like
TypeSignature::ExactOrNull(valid_types) => {
current_types.iter().map(|t| {
if t != &DataType::Null {
valid_types.clone()
} else {
vec![DataType::Null]
}
})
}
There was a problem hiding this comment.
Yeah, that would be fine. I'll add a ticket to record it
alamb
left a comment
There was a problem hiding this comment.
Thank you @Lordworms and @jayzhan211 -- looks good to me
FWIW I also verified that returning NULL is consistent with DuckDB:
D select generate_series(DATE '1992-09-01', NULL, INTERVAL '1' YEAR);
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ generate_series(CAST('1992-09-01' AS DATE), NULL, to_years(CAST(trunc(CAST('1' AS DOUBLE)) AS INTEGER))) │
│ int32 │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────┘| } | ||
| } | ||
|
|
||
| make_udf_function!( |
There was a problem hiding this comment.
is this just an accidental left over copy?
There was a problem hiding this comment.
Yes, there might be some other left things
| } | ||
| } | ||
|
|
||
| make_udf_function!( |
There was a problem hiding this comment.
Likewise this looks like an accidental copy too -- here is the other copy:
datafusion/datafusion/functions-array/src/range.rs
Lines 102 to 163 in 0ea9bc6
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
|
thanks @Lordworms and @alamb |
Which issue does this PR close?
Closes #10269
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?