Skip to content

Commit 3d32da0

Browse files
committed
Rule out ip from built-in comparator via its type checker
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 4ea73dc commit 3d32da0

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

core/src/main/java/org/opensearch/sql/expression/function/CoercionUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,11 @@ public class CoercionUtils {
8686
}
8787

8888
private static @Nullable RexNode cast(RexBuilder builder, ExprType targetType, RexNode arg) {
89-
// Implement the logic to check if fromType can be cast to toType
90-
// This could involve checking if the types are compatible, or if a cast is possible
91-
// For example, you might check if fromType is a subtype of toType, or if a conversion exists
9289
ExprType argType = OpenSearchTypeFactory.convertRelDataTypeToExprType(arg.getType());
9390
if (!argType.shouldCast(targetType)) {
9491
return arg;
9592
}
9693

97-
// If the arg is string
9894
if (WideningTypeRule.distance(argType, targetType) != WideningTypeRule.IMPOSSIBLE_WIDENING) {
9995
return builder.makeCast(OpenSearchTypeFactory.convertExprTypeToRelDataType(targetType), arg);
10096
}

core/src/main/java/org/opensearch/sql/expression/function/PPLTypeChecker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ public boolean checkOperandTypes(List<RelDataType> types) {
262262
// with strings in isComparable
263263
RelDataType type_l = types.get(i);
264264
RelDataType type_r = types.get(i + 1);
265+
// Rule out IP types from built-in comparable functions
266+
if (type_l instanceof ExprIPType || type_r instanceof ExprIPType) {
267+
return false;
268+
}
265269
if (!isComparable(type_l, type_r)) {
266270
return false;
267271
}

0 commit comments

Comments
 (0)