Yes, this is by design.I believe that the SQL standard set the rules.

It’s not that surprising that ‘=‘ has different behavior than ordering-based 
comparisons such as ‘>’. Consider: given a DATE value d, and a TIMESTAMP value 
t, it is reasonable to ask ‘is t > d?’ but less reasonable to ask ‘does t = d?'

> On Jan 10, 2022, at 6:35 PM, Zou Dan <zoud...@163.com> wrote:
> 
> Hi community,
> I recently ran into a problem that when we disable type coercion by 
> SqlValidator#setEnableTypeCoercion(false),
> there will be two different behaviors between '>' and '=':
> 1. '>' between character and numeric (e.g. '1' > 1), the character will be 
> implicitly converted to numeric
> 2. '=' between character and numeric (e.g. '1' = 1), the character will `not` 
> be implicitly converted to numeric
> I find the reason is that the SqlOperandTypeChecker.Consistency for 
> SqlStdOperatorTable.GREATER_THAN is `COMPARE` while
> SqlStdOperatorTable.EQUALS is `LEAST_RESTRICTIVE`.
> Is this by design?

Reply via email to