Skip to content

Commit c5a8eea

Browse files
committed
add type checker
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent baa5ee4 commit c5a8eea

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ private PPLOperandTypes() {}
6161
public static final UDFOperandMetadata DATE_OR_TIMESTAMP_OR_STRING =
6262
UDFOperandMetadata.wrap(
6363
(CompositeOperandTypeChecker) OperandTypes.DATE_OR_TIMESTAMP.or(OperandTypes.STRING));
64+
public static final UDFOperandMetadata STRING_DATE_OR_TIMESTAMP =
65+
UDFOperandMetadata.wrap(
66+
(CompositeOperandTypeChecker)
67+
OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.DATE)
68+
.or(OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.TIMESTAMP)));
6469
}

core/src/main/java/org/opensearch/sql/expression/function/udf/condition/EarliestFunction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package org.opensearch.sql.expression.function.udf.condition;
77

8+
import static org.opensearch.sql.calcite.utils.PPLOperandTypes.STRING_DATE_OR_TIMESTAMP;
89
import static org.opensearch.sql.calcite.utils.UserDefinedFunctionUtils.prependFunctionProperties;
910
import static org.opensearch.sql.utils.DateTimeUtils.getRelativeZonedDateTime;
1011

@@ -26,6 +27,7 @@
2627
import org.opensearch.sql.data.model.ExprValue;
2728
import org.opensearch.sql.expression.function.FunctionProperties;
2829
import org.opensearch.sql.expression.function.ImplementorUDF;
30+
import org.opensearch.sql.expression.function.UDFOperandMetadata;
2931

3032
public class EarliestFunction extends ImplementorUDF {
3133
public EarliestFunction() {
@@ -37,6 +39,11 @@ public SqlReturnTypeInference getReturnTypeInference() {
3739
return ReturnTypes.BOOLEAN;
3840
}
3941

42+
@Override
43+
public UDFOperandMetadata getOperandMetadata() {
44+
return STRING_DATE_OR_TIMESTAMP;
45+
}
46+
4047
public static class EarliestImplementor implements NotNullImplementor {
4148
@Override
4249
public Expression implement(

core/src/main/java/org/opensearch/sql/expression/function/udf/condition/LatestFunction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package org.opensearch.sql.expression.function.udf.condition;
77

8+
import static org.opensearch.sql.calcite.utils.PPLOperandTypes.STRING_DATE_OR_TIMESTAMP;
89
import static org.opensearch.sql.calcite.utils.UserDefinedFunctionUtils.prependFunctionProperties;
910
import static org.opensearch.sql.utils.DateTimeUtils.getRelativeZonedDateTime;
1011

@@ -26,6 +27,7 @@
2627
import org.opensearch.sql.data.model.ExprValue;
2728
import org.opensearch.sql.expression.function.FunctionProperties;
2829
import org.opensearch.sql.expression.function.ImplementorUDF;
30+
import org.opensearch.sql.expression.function.UDFOperandMetadata;
2931

3032
public class LatestFunction extends ImplementorUDF {
3133
public LatestFunction() {
@@ -37,6 +39,11 @@ public SqlReturnTypeInference getReturnTypeInference() {
3739
return ReturnTypes.BOOLEAN;
3840
}
3941

42+
@Override
43+
public UDFOperandMetadata getOperandMetadata() {
44+
return STRING_DATE_OR_TIMESTAMP;
45+
}
46+
4047
public static class LatestImplementor implements NotNullImplementor {
4148
@Override
4249
public Expression implement(

integ-test/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ integTest {
448448

449449
dependsOn ':opensearch-sql-plugin:bundlePlugin'
450450
if(getOSFamilyType() != "windows") {
451-
dependsOn startPrometheus
452-
finalizedBy stopPrometheus
451+
//dependsOn startPrometheus
452+
//finalizedBy stopPrometheus
453453
}
454454

455455
// enable calcite codegen in IT

0 commit comments

Comments
 (0)