clintropolis opened a new pull request, #16593:
URL: https://github.com/apache/druid/pull/16593

   ### Description
   This PR changes `EqualityFilter` and `TypedInfilter` numeric match values 
against string columns to now use `StringComparators.NUMERIC` instead of 
converting the numeric values directly to string for pure string equality. 
   
   This effectively is an implicit cast of the `STRING` values to the numeric 
match value type, which is consistent with the casts which are eaten in the SQL 
layer, as well as "classic" druid behavior where we do our best with what we 
are given.
   
   The added tests to cover numeric equality matching. Double match values in 
particular would fail to match the string values since `1.0` would become 
`'1.0'` which does not match `'1'`.
   
   I investigated an alternative of just having the SQL planner not eat `CAST` 
operators like it currently does, since a query like `... WHERE stringColumn = 
1.0` ends up as `... WHERE CAST(stringColumn as DOUBLE) = 1.0` before we eat 
the cast, which makes the native layer a lot more explicit, however this change 
basically does the same thing and is a lot less disruptive.
   
   It may still be worth investigating not eating casts during SQL planning, 
but I'll save that for follow-up work.
   
   #### Release note
   Modified behavior of using `EqualityFilter` and `TypedInFilter` to match 
numeric typed values (particularly DOUBLE) against string columns to 
effectively cast the strings to use numerical comparison, for more consistent 
Druid behavior. 
   
   This PR has:
   
   - [x] been self-reviewed.
   - [x] a release note entry in the PR description.
   - [x] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [x] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [x] been tested in a test Druid cluster.
   


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