druid icon indicating copy to clipboard operation
druid copied to clipboard

Fix queries filtering for the same condition with both an IN and EQUALS to not return empty results

Open kgyrtkirk opened this issue 1 year ago • 1 comments

  • temp fix until CALCITE-6435 gets fixed (released&upgraded to)
  • added a custom rule (FixIncorrectInExpansionTypes) to fix-up types of the affected literals
  • added a testcase which will alert on upgrade

Release note

Queries filtering for the same string value with both an IN expression and an = filter may have been incorrectly returned an empty resultset.

This PR has:

  • [x] been self-reviewed.
  • [x] a release note entry in the PR description.
  • [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.

kgyrtkirk avatar Jun 13 '24 16:06 kgyrtkirk

current approach is to run the ReduceExpressionRule early to get rid of the problematic issue

but that does not seem to be what is happening. Could you please clarify what the bug is and how we're fixing it?

thank you for noticing this! that would have been the easiest to fix it - however it had some adverse effects; so I've decided to write a custom rule instead. (updated the desc)

kgyrtkirk avatar Jun 29 '24 05:06 kgyrtkirk

thank you @sreemanamala for taking a look; I expect this sqlToRelWorkaroundProgram to be removed when we upgrade to 1.38.0 - I don't think we will need to add more such rules...or at least hope :D but it can be re-organized as needed if we have to add anything beyond this

kgyrtkirk avatar Jul 08 '24 07:07 kgyrtkirk