Code review comment: The cast to function will only return IntLiteral or LargeIntLiteral. So the only possibility of data overflow is when Largeint is converted to Int. Obviously, the checkValueValid function has already been called when Largeint cast to int, so there is no need to check again here.

Code before review:
public Expr apply(Expr expr, Analyzer analyzer, ClauseType clauseType) throws AnalysisException {
if (!(expr instanceof InPredicate)) {
return expr;
}
InPredicate inPredicate = (InPredicate) expr;
if (inPredicate.contains(Subquery.class) || !inPredicate.isLiteralChildren() || inPredicate.isNotIn()
|| !(inPredicate.getChild(0).unwrapExpr(false) instanceof SlotRef)) {
return expr;
}
SlotRef slotRef = inPredicate.getChild(0).getSrcSlotRef();
Type columnType = slotRef.getColumn().getType();
if (!columnType.isFixedPointType()) {
return expr;
}
InPredicate newInPredicate = inPredicate.clone();
boolean isCast = false;
List<Expr> invalidChildren = Lists.newArrayList();
for (int i = 1; i < newInPredicate.getChildren().size(); ++i) {
LiteralExpr childExpr = (LiteralExpr) newInPredicate.getChild(i);
if (childExpr.getType().getPrimitiveType().equals(columnType.getPrimitiveType())) {
continue;
}
if (childExpr.getType().getPrimitiveType().isCharFamily() || childExpr.getType().isFloatingPointType()) {
try {
childExpr = (LiteralExpr) childExpr.castTo(Type.DECIMALV2);
} catch (Exception e) {
newInPredicate.setChild(i, childExpr);
invalidChildren.add(childExpr);
continue;
}
}
if (childExpr.getType().isNumericType()) {
try {
LiteralExpr newExpr = (LiteralExpr) childExpr.castTo(columnType);
newExpr.checkValueValid();
if (childExpr.compareLiteral(newExpr) == 0) {
newInPredicate.setChild(i, newExpr);
isCast = true;
} else {
throw new AnalysisException("Converting the type will result in a loss of accuracy.");
}
} catch (Exception e) {
newInPredicate.setChild(i, childExpr);
invalidChildren.add(childExpr);
}
} else {
return expr;
}
}
if (invalidChildren.size() == newInPredicate.getChildren().size() - 1) {
return new BoolLiteral(false);
}
if (newInPredicate.getChild(0).getType().getPrimitiveType() != columnType.getPrimitiveType()) {
newInPredicate.castChild(columnType, 0);
isCast = true;
}
newInPredicate.getChildren().removeAll(invalidChildren);
return !isCast && invalidChildren.isEmpty() ? expr : newInPredicate;
}

Line under review: newExpr.checkValueValid();

Code after addressing the review:
public Expr apply(Expr expr, Analyzer analyzer, ClauseType clauseType) throws AnalysisException {
if (!(expr instanceof InPredicate)) {
return expr;
}
InPredicate inPredicate = (InPredicate) expr;
SlotRef slotRef;
if (inPredicate.contains(Subquery.class) || !inPredicate.isLiteralChildren() || inPredicate.isNotIn()
|| !(inPredicate.getChild(0).unwrapExpr(false) instanceof SlotRef)
|| (slotRef = inPredicate.getChild(0).getSrcSlotRef()) == null || slotRef.getColumn() == null) {
return expr;
}
Type columnType = slotRef.getColumn().getType();
if (!columnType.isFixedPointType()) {
return expr;
}
Expr newColumnExpr = expr.getChild(0).getType().getPrimitiveType() == columnType.getPrimitiveType()
? expr.getChild(0) : expr.getChild(0).castTo(columnType);
List<Expr> newInList = Lists.newArrayList();
boolean isCast = false;
for (int i = 1; i < inPredicate.getChildren().size(); ++i) {
LiteralExpr childExpr = (LiteralExpr) inPredicate.getChild(i);
if (!(childExpr.getType().isNumericType() || childExpr.getType().getPrimitiveType().isCharFamily())) {
return expr;
}
if (childExpr.getType().getPrimitiveType().equals(columnType.getPrimitiveType())) {
newInList.add(childExpr);
continue;
}
if (childExpr.getType().getPrimitiveType().isCharFamily() || childExpr.getType().isFloatingPointType()) {
try {
childExpr = (LiteralExpr) childExpr.castTo(Type.DECIMALV2);
} catch (AnalysisException e) {
continue;
}
}
try {
LiteralExpr newExpr = (LiteralExpr) childExpr.castTo(columnType);
if (childExpr.compareLiteral(newExpr) == 0) {
isCast = true;
newInList.add(newExpr);
}
} catch (AnalysisException ignored) {
}
}
if (newInList.isEmpty()) {
return new BoolLiteral(false);
}
return newInList.size() + 1 < expr.getChildren().size() || isCast
? new InPredicate(newColumnExpr, newInList, false) : expr;
}