alamb opened a new issue #1179:
URL: https://github.com/apache/arrow-datafusion/issues/1179


   **Describe the bug**
   
   Bug is that datafusion SQL treats a literal `NULL` as though it is typed 
`ScalarValue::Utf8(None)`
   
   So then if you try to compare null to a column that is not a scalar 
DataFusion goes 💥 
   
   **To Reproduce**
   (I *love* the new `VALUES` feature that @Jimexist added)
   
   ```sql
   > select * from (VALUES (1, 'foo' ,2.3), (2, 'bar', 5.4)) as t;
   +---------+---------+---------+
   | column1 | column2 | column3 |
   +---------+---------+---------+
   | 1       | foo     | 2.3     |
   | 2       | bar     | 5.4     |
   +---------+---------+---------+
   2 rows in set. Query took 0.004 seconds.
   > select column1 < null from (VALUES (1, 'foo' ,2.3), (2, 'bar', 5.4)) as t;
   Plan("'Int64 < Utf8' can't be evaluated because there isn't a common type to 
coerce the types to")
   > select column2 < null from (VALUES (1, 'foo' ,2.3), (2, 'bar', 5.4)) as t;
   ArrowError(ExternalError(Internal("compute_utf8_op_scalar for 'lt' failed to 
cast literal value NULL")))
   > select column3 < null from (VALUES (1, 'foo' ,2.3), (2, 'bar', 5.4)) as t;
   Plan("'Float64 < Utf8' can't be evaluated because there isn't a common type 
to coerce the types to")
   ```
   
   **Expected behavior**
   All three queries should return 1 column, 2 rows with all values null;
   
   | result |
   | ------|
   | NULL |
   | NULL |
   
   
   **Additional context**
   
   This came up in the context of IOx where we are doing partial evaluation (on 
something that is like at the partition level) where references to columns may 
be rewritten into `null`s. See more details on  
https://github.com/influxdata/influxdb_iox/issues/883
   


-- 
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]


Reply via email to