Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.math.BigInteger;
import java.nio.IntBuffer;
import java.util.Objects;

/**
* This code was based on code from Microsoft's PolyBase.
Expand Down Expand Up @@ -683,7 +684,7 @@ public void subtractDestructive(SignedInt128 right) {
*/
public static void multiply(SignedInt128 left, SignedInt128 right,
SignedInt128 result) {
if (result == left || result == right) {
if (Objects.equals(result, left) || Objects.equals(result, right)) {
throw new IllegalArgumentException(
"result object cannot be left or right operand");
}
Expand Down Expand Up @@ -768,7 +769,7 @@ public int divideDestructive(int right) {
*/
public static void divide(SignedInt128 left, SignedInt128 right,
SignedInt128 quotient, SignedInt128 remainder) {
if (quotient == left || quotient == right) {
if (Objects.equals(quotient, left) || Objects.equals(quotient, right)) {
throw new IllegalArgumentException(
"result object cannot be left or right operand");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Stack;

import org.apache.hadoop.hive.ql.exec.CommonJoinOperator;
Expand Down Expand Up @@ -114,7 +115,7 @@ private void combineLimits(LimitOperator childLimit) throws SemanticException {
LimitOperator parentLimit = (LimitOperator) childLimit.getParentOperators().get(0);
LimitDesc parentConf = parentLimit.getConf();
LimitDesc childConf = childLimit.getConf();
if (parentConf.getOffset() == childConf.getOffset()) {
if (Objects.equals(parentConf.getOffset(), childConf.getOffset())) {
int min = Math.min(parentConf.getLimit(), childConf.getLimit());
LOG.debug("Combining two limits child={}, parent={}, newLimit={}", childLimit, parentLimit, min);
parentConf.setLimit(min);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ public boolean isDistanceGreaterPrimitive(Double d1, Double d2, int amt) {
@Override
public boolean isEqualPrimitive(Double d1, Double d2) {
if (d1 != null && d2 != null) {
return d1 == d2;
return d1.equals(d2);
}

return d1 == null && d2 == null; // True if both are null
Expand Down
Loading