[fix](nereids)decimal and datetime literal comparison should compare datatype too (#36064)

pick from master #36055
This commit is contained in:
starocean999
2024-06-08 22:01:37 +08:00
committed by GitHub
parent 9e972cb0b9
commit 936bf65622
7 changed files with 77 additions and 17 deletions

View File

@ -29,6 +29,7 @@ import org.apache.doris.nereids.util.StandardDateFormat;
import com.google.common.base.Preconditions;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* date time v2 literal for nereids
@ -271,4 +272,19 @@ public class DateTimeV2Literal extends DateTimeLiteral {
dateTime.getMinute(), dateTime.getSecond(),
(dateTime.getNano() / 1000) / value * value);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
DateTimeV2Literal literal = (DateTimeV2Literal) o;
return Objects.equals(dataType, literal.dataType);
}
}

View File

@ -95,4 +95,19 @@ public class DecimalLiteral extends FractionalLiteral {
precision, scale, realPrecision, realScale));
}
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
DecimalLiteral literal = (DecimalLiteral) o;
return Objects.equals(dataType, literal.dataType);
}
}

View File

@ -106,4 +106,19 @@ public class DecimalV3Literal extends FractionalLiteral {
precision, scale, realPrecision, realScale));
}
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
DecimalV3Literal literal = (DecimalV3Literal) o;
return Objects.equals(dataType, literal.dataType);
}
}