Code review comment: This case will cast to LARGEINT now.

Code before review:
private Type getCmpType() throws AnalysisException {
PrimitiveType t1 = getChild(0).getType().getResultType().getPrimitiveType();
PrimitiveType t2 = getChild(1).getType().getResultType().getPrimitiveType();
for (Expr e : getChildren()) {
if (e.getType().getPrimitiveType() == PrimitiveType.HLL) {
throw new AnalysisException("Hll type dose not support operand: " + toSql());
}
if (e.getType().getPrimitiveType() == PrimitiveType.BITMAP) {
throw new AnalysisException("Bitmap type dose not support operand: " + toSql());
}
}
if (canCompareDate(getChild(0).getType().getPrimitiveType(), getChild(1).getType().getPrimitiveType())) {
if (!(getChild(0).getType().isDateV2() || getChild(0).getType().isDatetimeV2()
|| getChild(1).getType().isDateV2() || getChild(1).getType().isDatetimeV2())) {
return Type.DATETIME;
} else {
Preconditions.checkArgument(getChild(0).getType() instanceof ScalarType
&& getChild(1).getType() instanceof ScalarType);
return dateV2ComparisonResultType((ScalarType) getChild(0).getType(),
(ScalarType) getChild(1).getType());
}
}
if (t1 == PrimitiveType.VARCHAR && t2 == PrimitiveType.VARCHAR) {
return Type.VARCHAR;
}
if (t1 == PrimitiveType.STRING && t2 == PrimitiveType.STRING
|| t1 == PrimitiveType.STRING && t2 == PrimitiveType.VARCHAR
|| t1 == PrimitiveType.VARCHAR && t2 == PrimitiveType.STRING) {
return Type.STRING;
}
if (t1 == PrimitiveType.BIGINT && t2 == PrimitiveType.BIGINT) {
return Type.getAssignmentCompatibleType(getChild(0).getType(), getChild(1).getType(), false);
}
if (t1.isDecimalV3Type() || t2.isDecimalV3Type()) {
return Type.getAssignmentCompatibleType(getChild(0).getType(), getChild(1).getType(), false);
}
if ((t1 == PrimitiveType.BIGINT || t1 == PrimitiveType.DECIMALV2)
&& (t2 == PrimitiveType.BIGINT || t2 == PrimitiveType.DECIMALV2)) {
return Type.DECIMALV2;
}
if ((t1 == PrimitiveType.BIGINT || t1 == PrimitiveType.LARGEINT)
&& (t2 == PrimitiveType.BIGINT || t2 == PrimitiveType.LARGEINT)) {
return Type.LARGEINT;
}
if (t1 == PrimitiveType.BIGINT && (t2 == PrimitiveType.VARCHAR || t2 == PrimitiveType.STRING)) {
Expr rightChild = getChild(1);
Long parsedLong = Type.tryParseToLong(rightChild);
if (parsedLong != null) {
return Type.BIGINT;
}
}
if ((t1 == PrimitiveType.VARCHAR || t1 == PrimitiveType.STRING) && t2 == PrimitiveType.BIGINT) {
Expr leftChild = getChild(0);
Long parsedLong = Type.tryParseToLong(leftChild);
if (parsedLong != null) {
return Type.BIGINT;
}
}
return Type.VARCHAR;
}

Line under review: return Type.VARCHAR;

Code after addressing the review:
private Type getCmpType() throws AnalysisException {
PrimitiveType t1 = getChild(0).getType().getResultType().getPrimitiveType();
PrimitiveType t2 = getChild(1).getType().getResultType().getPrimitiveType();
for (Expr e : getChildren()) {
if (e.getType().getPrimitiveType() == PrimitiveType.HLL) {
throw new AnalysisException("Hll type dose not support operand: " + toSql());
}
if (e.getType().getPrimitiveType() == PrimitiveType.BITMAP) {
throw new AnalysisException("Bitmap type dose not support operand: " + toSql());
}
}
if (canCompareDate(getChild(0).getType().getPrimitiveType(), getChild(1).getType().getPrimitiveType())) {
if (!(getChild(0).getType().isDateV2() || getChild(0).getType().isDatetimeV2()
|| getChild(1).getType().isDateV2() || getChild(1).getType().isDatetimeV2())) {
return Type.DATETIME;
} else {
Preconditions.checkArgument(getChild(0).getType() instanceof ScalarType
&& getChild(1).getType() instanceof ScalarType);
return dateV2ComparisonResultType((ScalarType) getChild(0).getType(),
(ScalarType) getChild(1).getType());
}
}
if (t1 == PrimitiveType.VARCHAR && t2 == PrimitiveType.VARCHAR) {
return Type.VARCHAR;
}
if (t1 == PrimitiveType.STRING && t2 == PrimitiveType.STRING
|| t1 == PrimitiveType.STRING && t2 == PrimitiveType.VARCHAR
|| t1 == PrimitiveType.VARCHAR && t2 == PrimitiveType.STRING) {
return Type.STRING;
}
if (t1 == PrimitiveType.BIGINT && t2 == PrimitiveType.BIGINT) {
return Type.getAssignmentCompatibleType(getChild(0).getType(), getChild(1).getType(), false);
}
if (t1.isDecimalV3Type() || t2.isDecimalV3Type()) {
return Type.getAssignmentCompatibleType(getChild(0).getType(), getChild(1).getType(), false);
}
if ((t1 == PrimitiveType.BIGINT || t1 == PrimitiveType.DECIMALV2)
&& (t2 == PrimitiveType.BIGINT || t2 == PrimitiveType.DECIMALV2)) {
return Type.DECIMALV2;
}
if ((t1 == PrimitiveType.BIGINT || t1 == PrimitiveType.LARGEINT)
&& (t2 == PrimitiveType.BIGINT || t2 == PrimitiveType.LARGEINT)) {
return Type.LARGEINT;
}
if (t1.isStringType() || t2.isStringType()) {
if ((t1 == PrimitiveType.BIGINT || t1 == PrimitiveType.LARGEINT) && Type.canParseTo(getChild(1), t1)) {
return Type.fromPrimitiveType(t1);
}
if ((t2 == PrimitiveType.BIGINT || t2 == PrimitiveType.LARGEINT) && Type.canParseTo(getChild(0), t2)) {
return Type.fromPrimitiveType(t2);
}
}
return Type.DOUBLE;
}