Skip to content

Commit fd6251e

Browse files
committed
Address comments
- use OperandTypes.CHARACTER consistenly - use OperandTypes.VARIADIC for append function - add safeguard for atan rewrite Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 8d561a0 commit fd6251e

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

core/src/main/java/org/opensearch/sql/calcite/utils/PPLOperandTypes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ private PPLOperandTypes() {}
7575

7676
public static final UDFOperandMetadata NUMERIC_STRING_OR_STRING_STRING =
7777
UDFOperandMetadata.wrap(
78-
(OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.STRING))
79-
.or(OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.STRING)));
78+
(OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.CHARACTER))
79+
.or(OperandTypes.family(SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER)));
8080

8181
public static final UDFOperandMetadata NUMERIC_NUMERIC_OPTIONAL_NUMERIC_SYMBOL =
8282
UDFOperandMetadata.wrap(

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

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

4848
@Override
4949
public UDFOperandMetadata getOperandMetadata() {
50-
return UDFOperandMetadata.wrap(OperandTypes.SAME_VARIADIC);
50+
return UDFOperandMetadata.wrap(OperandTypes.VARIADIC);
5151
}
5252

5353
public static class AppendImplementor implements NotNullImplementor {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,13 @@ public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
501501
SqlFunctionCategory.NUMERIC) {
502502
@Override
503503
public SqlNode rewriteCall(SqlValidator validator, SqlCall call) {
504-
SqlOperator op =
505-
call.getOperandList().size() == 2
506-
? SqlStdOperatorTable.ATAN2
507-
: SqlStdOperatorTable.ATAN;
508-
((SqlBasicCall) call).setOperator(op);
504+
if (call instanceof SqlBasicCall) {
505+
SqlOperator op =
506+
call.getOperandList().size() == 2
507+
? SqlStdOperatorTable.ATAN2
508+
: SqlStdOperatorTable.ATAN;
509+
((SqlBasicCall) call).setOperator(op);
510+
}
509511
return call;
510512
}
511513
};

0 commit comments

Comments
 (0)