discord9 commented on code in PR #15854:
URL: https://github.com/apache/datafusion/pull/15854#discussion_r2067801065


##########
datafusion/substrait/src/logical_plan/producer.rs:
##########
@@ -1590,6 +1590,21 @@ pub fn from_cast(
     schema: &DFSchemaRef,
 ) -> Result<Expression> {
     let Cast { expr, data_type } = cast;
+    // since substrait Null must be typed, so if we see a cast(null, dt), we 
make it a typed null
+    if let Expr::Literal(lit) = expr.as_ref() {
+        if lit.is_null() {

Review Comment:
   > To further clarify, at the SQL/Relational level
   > 
   > ```sql
   > SELECT null::text[], array[]::text[]
   > 
   > text | array
   > ---- | --
   > null | {}
   > ```
   > 
   > we can distinguish between casting a null literal to a compound type, and 
the empty version of that compound type.
   > 
   > [dbfiddle](https://www.db-fiddle.com/f/cH7Hwk6mHnm3rgy7wXG4Yq/47)
   
   Oh I didn't realize `is_null` do extra things other than matches with 
`ScalarValue::Null`, I shall only match `ScalarValue::Null` then



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to