vitess icon indicating copy to clipboard operation
vitess copied to clipboard

evalengine: support mismatched numerical types

Open vmg opened this issue 2 years ago • 4 comments

Description

Found this while working on some internal stuff. The evalengine does not properly handle mismatched numeric types because we were not properly normalizing. E.g. an UINT8(0) would fail to compare equally to an UINT64(0), even though an INT8(0) would actually compare equally to a UINT64(0). This PR fixes this issue by upcasting all comparison types before performing a numeric comparison.

It probably requires a backport.

cc @systay @deepthi

Related Issue(s)

Checklist

  • [x] "Backport me!" label has been added if this change should be backported
  • [x] Tests were added or are not required
  • [x] Documentation was added or is not required

Deployment Notes

vmg avatar Aug 11 '22 14:08 vmg

Review Checklist

Hello reviewers! :wave: Please follow this checklist when reviewing this Pull Request.

General

  • [x] Ensure that the Pull Request has a descriptive title.
  • [ ] If this is a change that users need to know about, please apply the release notes (needs details) label so that merging is blocked unless the summary release notes document is included.
  • [ ] If a new flag is being introduced, review whether it is really needed. The flag names should be clear and intuitive (as far as possible), and the flag's help should be descriptive.
  • [ ] If a workflow is added or modified, each items in Jobs should be named in order to mark it as required. If the workflow should be required, the GitHub Admin should be notified.

Bug fixes

  • [x] There should be at least one unit or end-to-end test.
  • [x] The Pull Request description should either include a link to an issue that describes the bug OR an actual description of the bug and how to reproduce, along with a description of the fix.

Non-trivial changes

  • [x] There should be some code comments as to why things are implemented the way they are.

New/Existing features

  • [ ] Should be documented, either by modifying the existing documentation or creating new documentation.
  • [ ] New features should have a link to a feature request issue or an RFC that documents the use cases, corner cases and test cases.

Backward compatibility

  • [ ] Protobuf changes should be wire-compatible.
  • [ ] Changes to _vt tables and RPCs need to be backward compatible.
  • [ ] vtctl command output order should be stable and awk-able.

vitess-bot[bot] avatar Aug 11 '22 14:08 vitess-bot[bot]

We've just noticed @harshit-gangal's https://github.com/vitessio/vitess/pull/10793, which found this bug already and added a check to the evalengine to error out when the bug was triggered.

This PR follows up on that by removing the check and instead always performing the right comparison. The tests that were previously testing the error have been updated and are now green. :sparkles:

vmg avatar Aug 11 '22 15:08 vmg

@harshit-gangal: the end2end test no longer errors, but it doesn't appear to be giving the right results either:

=== RUN   TestFilterOnLeftOuterJoin
    mysql.go:188: Query (select team.id
        				from team_fact
        				  join team on team.id = team_fact.team
        				  left outer join team_member on team_member.team = team.id
        				where (
        				  team_fact.fact = 'A'
        				  and team_member.user is null
        				  and team_fact.team >= 22
        				)) results mismatched.
        Vitess Results:
        [INT32(22)]
        [INT32(33)]
        MySQL Results:
        
--- FAIL: TestFilterOnLeftOuterJoin (0.05s)

Did I not write the test properly?

vmg avatar Aug 11 '22 17:08 vmg

Did I not write the test properly?

There was a bug in the test that I fixed up, so it should be green now.

dbussink avatar Aug 11 '22 20:08 dbussink

I was unable to backport this Pull Request to the following branches: release-14.0, release-13.0.

vitess-bot[bot] avatar Aug 12 '22 04:08 vitess-bot[bot]