You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "clintropolis (via GitHub)" <gi...@apache.org> on 2024/06/13 04:36:57 UTC

[PR] fix equality and typed in filter behavior for numeric match values on string columns (druid)

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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] modify equality and typed in filter behavior for numeric match values on string columns (druid)

Posted by "clintropolis (via GitHub)" <gi...@apache.org>.
clintropolis merged PR #16593:
URL: https://github.com/apache/druid/pull/16593


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org