|
79 | 79 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.HOUR_OF_DAY; |
80 | 80 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.IF; |
81 | 81 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.IFNULL; |
| 82 | +import static org.opensearch.sql.expression.function.BuiltinFunctionName.ILIKE; |
82 | 83 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.INTERNAL_GROK; |
83 | 84 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.INTERNAL_ITEM; |
84 | 85 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.INTERNAL_PARSE; |
|
150 | 151 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.MULTIPLYFUNCTION; |
151 | 152 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.MULTI_MATCH; |
152 | 153 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.MVAPPEND; |
| 154 | +import static org.opensearch.sql.expression.function.BuiltinFunctionName.MVDEDUP; |
153 | 155 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.MVINDEX; |
154 | 156 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.MVJOIN; |
155 | 157 | import static org.opensearch.sql.expression.function.BuiltinFunctionName.NOT; |
@@ -326,6 +328,18 @@ default RexNode resolve(RexBuilder builder, RexNode... args) { |
326 | 328 | } |
327 | 329 | } |
328 | 330 |
|
| 331 | + public interface FunctionImp3 extends FunctionImp { |
| 332 | + RexNode resolve(RexBuilder builder, RexNode arg1, RexNode arg2, RexNode arg3); |
| 333 | + |
| 334 | + @Override |
| 335 | + default RexNode resolve(RexBuilder builder, RexNode... args) { |
| 336 | + if (args.length != 3) { |
| 337 | + throw new IllegalArgumentException("This function requires exactly 3 arguments"); |
| 338 | + } |
| 339 | + return resolve(builder, args[0], args[1], args[2]); |
| 340 | + } |
| 341 | + } |
| 342 | + |
329 | 343 | /** The singleton instance. */ |
330 | 344 | public static final PPLFuncImpTable INSTANCE; |
331 | 345 |
|
@@ -989,6 +1003,7 @@ void populate() { |
989 | 1003 |
|
990 | 1004 | registerOperator(ARRAY, PPLBuiltinOperators.ARRAY); |
991 | 1005 | registerOperator(MVAPPEND, PPLBuiltinOperators.MVAPPEND); |
| 1006 | + registerOperator(MVDEDUP, SqlLibraryOperators.ARRAY_DISTINCT); |
992 | 1007 | registerOperator(MAP_APPEND, PPLBuiltinOperators.MAP_APPEND); |
993 | 1008 | registerOperator(MAP_CONCAT, SqlLibraryOperators.MAP_CONCAT); |
994 | 1009 | registerOperator(MAP_REMOVE, PPLBuiltinOperators.MAP_REMOVE); |
@@ -1214,17 +1229,22 @@ void populate() { |
1214 | 1229 | arg))), |
1215 | 1230 | PPLTypeChecker.family(SqlTypeFamily.ANY)); |
1216 | 1231 | register( |
1217 | | - LIKE, |
| 1232 | + ILIKE, |
1218 | 1233 | (FunctionImp2) |
1219 | 1234 | (builder, arg1, arg2) -> |
1220 | 1235 | builder.makeCall( |
1221 | | - SqlLibraryOperators.ILIKE, |
1222 | | - arg1, |
1223 | | - arg2, |
1224 | | - // TODO: Figure out escaping solution. '\\' is used for JSON input but is not |
1225 | | - // necessary for SQL function input |
1226 | | - builder.makeLiteral("\\")), |
| 1236 | + SqlLibraryOperators.ILIKE, arg1, arg2, builder.makeLiteral("\\")), |
1227 | 1237 | PPLTypeChecker.family(SqlTypeFamily.STRING, SqlTypeFamily.STRING)); |
| 1238 | + register( |
| 1239 | + LIKE, |
| 1240 | + (FunctionImp3) |
| 1241 | + (builder, arg1, arg2, arg3) -> |
| 1242 | + ((RexLiteral) arg3).getValueAs(Boolean.class) |
| 1243 | + ? builder.makeCall( |
| 1244 | + SqlStdOperatorTable.LIKE, arg1, arg2, builder.makeLiteral("\\")) |
| 1245 | + : builder.makeCall( |
| 1246 | + SqlLibraryOperators.ILIKE, arg1, arg2, builder.makeLiteral("\\")), |
| 1247 | + PPLTypeChecker.family(SqlTypeFamily.STRING, SqlTypeFamily.STRING, SqlTypeFamily.BOOLEAN)); |
1228 | 1248 | } |
1229 | 1249 | } |
1230 | 1250 |
|
|
0 commit comments