Skip to content

Commit 190597a

Browse files
committed
Correct type checkers for mvappend; fix regexp lookup; correct isempty and isblank (1738/2018)
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 9e844d6 commit 190597a

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

core/src/main/java/org/opensearch/sql/expression/function/CollectionUDF/MVAppendFunctionImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public SqlReturnTypeInference getReturnTypeInference() {
5151

5252
@Override
5353
public UDFOperandMetadata getOperandMetadata() {
54-
return UDFOperandMetadata.wrap(OperandTypes.ARRAY);
54+
return UDFOperandMetadata.wrap(OperandTypes.VARIADIC);
5555
}
5656

5757
private static RelDataType determineElementType(

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.calcite.sql.SqlKind;
3131
import org.apache.calcite.sql.SqlNode;
3232
import org.apache.calcite.sql.SqlOperator;
33+
import org.apache.calcite.sql.fun.SqlLibraryOperators;
3334
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
3435
import org.apache.calcite.sql.type.OperandTypes;
3536
import org.apache.calcite.sql.type.ReturnTypes;
@@ -504,6 +505,11 @@ public SqlNode rewriteCall(SqlValidator validator, SqlCall call) {
504505
return call;
505506
}
506507
};
508+
// SPARK dialect is not included in lookup table to resolve overrides issues (e.g. reverse
509+
// function won't work if spark is included because there are multiple overrides of reverse, and
510+
// it will choose none of them in the end.) Therefore, SPARK functions used are explicitly
511+
// declared here for lookup.
512+
public static final SqlFunction REGEXP = SqlLibraryOperators.REGEXP;
507513

508514
/**
509515
* Returns the PPL specific operator table, creating it if necessary.

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ void populate() {
832832
registerOperator(COALESCE, PPLBuiltinOperators.ENHANCED_COALESCE);
833833

834834
// Register library operator
835-
registerOperator(REGEXP, SqlLibraryOperators.REGEXP);
835+
registerOperator(REGEXP, PPLBuiltinOperators.REGEXP);
836836
registerOperator(REGEXP_MATCH, SqlLibraryOperators.REGEXP_CONTAINS);
837837
registerOperator(CONCAT, SqlLibraryOperators.CONCAT_FUNCTION);
838838
registerOperator(CONCAT_WS, SqlLibraryOperators.CONCAT_WS);
@@ -1001,7 +1001,7 @@ void populate() {
10011001
return builder.makeCall(
10021002
SqlStdOperatorTable.CASE, isEmptyDelimiter, splitChars, normalSplit);
10031003
},
1004-
PPLTypeChecker.family(SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER));
1004+
OperandTypes.family(SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER));
10051005

10061006
// Register MVINDEX to use Calcite's ITEM/ARRAY_SLICE with index normalization
10071007
register(
@@ -1192,7 +1192,7 @@ void populate() {
11921192
builder.makeCall(
11931193
SqlStdOperatorTable.OR,
11941194
builder.makeCall(SqlStdOperatorTable.IS_NULL, arg),
1195-
builder.makeCall(SqlStdOperatorTable.IS_EMPTY, arg)),
1195+
builder.makeCall(SqlStdOperatorTable.EQUALS, arg, builder.makeLiteral(""))),
11961196
OperandTypes.family(SqlTypeFamily.ANY));
11971197
register(
11981198
IS_BLANK,
@@ -1202,12 +1202,13 @@ void populate() {
12021202
SqlStdOperatorTable.OR,
12031203
builder.makeCall(SqlStdOperatorTable.IS_NULL, arg),
12041204
builder.makeCall(
1205-
SqlStdOperatorTable.IS_EMPTY,
1205+
SqlStdOperatorTable.EQUALS,
12061206
builder.makeCall(
12071207
SqlStdOperatorTable.TRIM,
12081208
builder.makeFlag(Flag.BOTH),
12091209
builder.makeLiteral(" "),
1210-
arg))),
1210+
arg),
1211+
builder.makeLiteral(""))),
12111212
OperandTypes.family(SqlTypeFamily.ANY));
12121213
register(
12131214
ILIKE,

0 commit comments

Comments
 (0)