neilconway commented on issue #15161:
URL: https://github.com/apache/datafusion/issues/15161#issuecomment-3923244192

   > when comparing a numeric column (int or float) with a string literal, cast 
the string literal to the column's numeric type, not the other way around.
   
   I don't think making type coercion behave differently for literals vs. 
columns (of the same type) is the right approach.
   
   I think @alamb's comment above is well-put:
   
   > I agree we should split the coercion rules for union and binary comparison
   
   For UNION (and CASE, coercion within an IN list, maybe other situations), we 
want to find the most general type that might be able to hold both values. So 
we want numeric -> string.
   
   Otherwise, we want string -> numeric. In an expression like `numeric_col < 
'500'`, the user obviously intends a numeric comparison. And an expression like 
`numeric_col < 'foo'` is invalid and we can safely reject it.
   
   So we need two different sets of type coercion rules, one for UNION, CASE, 
and maybe a few other situations, and a different set of rules for the rest of 
the time.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to