binder/expr: parse literal to expected type in frontend #7320
Labels
component/common
Common components, such as array, data chunk, expression.
component/frontend
Protocol, parsing, binder.
type/feature
Milestone
Some types do not have a dedicated literal syntax (e.g.
1
,true
,interval '1' hour
,array[]
) and can only be created by casting from string, includingdate
,timestamp
,timestamptz
,time
andbytea
.This cast expr is actually unnecessary. We can parse it to a literal of this type directly, just like how we handles typed
null
below:risingwave/src/frontend/src/expr/function_call.rs
Lines 118 to 132 in 68b0111
Basically,
if child.is_null() { Ok(Literal::new(None, target).into()) }
can be replaced by a more general form:if child.is_unknown() { Ok(Literal::new(_???_, target()).into()) }
The missing part should be refactored from how we cast from string to a target type, maybe
DataType::parse(&self, v: &str, timezone: &str) -> ScalarImpl
. We also need to pass session timezone intonew_cast
somehow ...The text was updated successfully, but these errors were encountered: