hive icon indicating copy to clipboard operation
hive copied to clipboard

HIVE-28875 Numbers should be compared with equals(), not with ==

Open dk2k opened this issue 11 months ago • 11 comments

Comparison with == and != checks memory adresses equals() check values

dk2k avatar Apr 02 '25 19:04 dk2k

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 avatar Apr 12 '25 05:04 SourabhBadhya

@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 avatar Apr 20 '25 09:04 dk2k

@dk2k Please rebase your PR for the tests to pass.

SourabhBadhya avatar Apr 21 '25 13:04 SourabhBadhya

@SourabhBadhya I can merge master branch. Is it what you need?

dk2k avatar Apr 21 '25 17:04 dk2k

@dk2k Yes you can do that as well.

SourabhBadhya avatar Apr 22 '25 00:04 SourabhBadhya

@SourabhBadhya I merged

dk2k avatar Apr 23 '25 09:04 dk2k

@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 avatar Apr 28 '25 05:04 SourabhBadhya

@SourabhBadhya please restart the checks

dk2k avatar Apr 30 '25 19:04 dk2k

@dk2k Please merge with master branch due to recent Calcite upgrade.

SourabhBadhya avatar May 03 '25 06:05 SourabhBadhya

@SourabhBadhya please check

dk2k avatar May 17 '25 08:05 dk2k

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.

github-actions[bot] avatar Jul 18 '25 00:07 github-actions[bot]

@SourabhBadhya tests are green. Is it good to merge?

dk2k avatar Jul 18 '25 07:07 dk2k

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.

github-actions[bot] avatar Sep 18 '25 00:09 github-actions[bot]