You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[substrait] [sqllogictest] Null cast is not valid #16272
The conversion that fails is the right hand side of the predicate, specifically right: Literal(NULL, None). We correctly identify that the literal is null.
DataType::Null => internal_err!("Null cast is not valid"),
I think for this to work properly, we have to know the actual type of the null, since substrait nulls must be typed. For example if we modify the .slt to the following
query I rowsort
select column1 from VALUES (1) where column1 = (NULL::INT)
----
I can't figure out how to un-assign myself but I don't think I have the time to continue on this. For whoever picks this up here are some ideas about how to resolve this
Add support for untyped NULL to substrait.
Perform a pass over the Datafusion logical plan to add type information to untyped NULLs. It's possible that this is already implemented elsewhere in Datafusion and then we can just re-use that logic. Otherwise I think it will be a bit non-trivial to implement this in general.
Activity
jkosh44 commentedon Aug 16, 2025
take
jkosh44 commentedon Aug 16, 2025
Here's a more minimal .slt repro
jkosh44 commentedon Aug 17, 2025
The failure happens when converting the DF logical plan into substrait. The logical plan of the above query looks like
The conversion that fails is the right hand side of the predicate, specifically
right: Literal(NULL, None). We correctly identify that the literal is null.datafusion/datafusion/substrait/src/logical_plan/producer/expr/literal.rs
Lines 54 to 67 in 8f15991
However, when we see that the type of the null is
NULL, we return an error.datafusion/datafusion/substrait/src/logical_plan/producer/types.rs
Lines 34 to 44 in 8f15991
I think for this to work properly, we have to know the actual type of the null, since substrait nulls must be typed. For example if we modify the .slt to the following
it works fine.
jkosh44 commentedon Sep 26, 2025
I can't figure out how to un-assign myself but I don't think I have the time to continue on this. For whoever picks this up here are some ideas about how to resolve this
gene-bordegaray commentedon Oct 14, 2025
take
fix: null cast not valid in substrait round trip (#18414)
fix: null cast not valid in substrait round trip (apache#18414)