HIVE-28875 Numbers should be compared with equals(), not with ==
Comparison with == and != checks memory adresses equals() check values
equals() is used to check the object content, == does a comparision on the object reference. Using equals() is the right programming paradigm.
I did a small test for confirming the same for Double datatype - There is a difference -
Double do1 = 9.0;
Double do2 = 9.00;
System.out.println(do1 == do2); // Returns false
System.out.println(do1.equals(do2)); // Returns true
I agree with @aturoczy comment. Instead of creating small PRs for handling each of these minor details its better to handle it in a single PR. Its always better to group similar ones and post aggregated PRs on them.
@SourabhBadhya @aturoczy I didn't mean to overwhelm the repo with PRs. But still I prefer to have several atomic PRs because it's easier to complete each PR. As for equals(): it has some specifics for Strings and numbers. If both strings are interned (which I didn't check), it's ok to compare their values using ==
@dk2k Please rebase your PR for the tests to pass.
@SourabhBadhya I can merge master branch. Is it what you need?
@dk2k Yes you can do that as well.
@SourabhBadhya I merged
@dk2k There is a qtest which is failing - windowing_udaf.q due to this change. Please evaluate whether modifying the corresponding q.out file is OK here. https://ci.hive.apache.org/blue/organizations/jenkins/hive-precommit/detail/PR-5743/6/tests
@SourabhBadhya please restart the checks
@dk2k Please merge with master branch due to recent Calcite upgrade.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
@SourabhBadhya please check
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Feel free to reach out on the [email protected] list if the patch is in need of reviews.
@SourabhBadhya tests are green. Is it good to merge?
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Feel free to reach out on the [email protected] list if the patch is in need of reviews.