1919import org .apache .calcite .linq4j .tree .Expression ;
2020import org .apache .calcite .rex .RexCall ;
2121import org .apache .calcite .sql .SqlOperator ;
22- import org .apache .calcite .sql .type .ReturnTypes ;
23- import org .apache .calcite .sql .type .SqlTypeTransforms ;
2422import org .apache .calcite .sql .type .CompositeOperandTypeChecker ;
2523import org .apache .calcite .sql .type .OperandTypes ;
24+ import org .apache .calcite .sql .type .ReturnTypes ;
2625import org .apache .calcite .sql .type .SqlTypeFamily ;
26+ import org .apache .calcite .sql .type .SqlTypeTransforms ;
2727import org .apache .calcite .sql .util .ReflectiveSqlOperatorTable ;
2828import org .apache .calcite .util .BuiltInMethod ;
2929import org .opensearch .sql .calcite .utils .PPLReturnTypes ;
3030import org .opensearch .sql .data .type .ExprCoreType ;
3131import org .opensearch .sql .expression .datetime .DateTimeFunctions ;
32- import org .opensearch .sql .expression .function .udf .CryptographicFunction ;
32+ import org .opensearch .sql .expression .function .udf .Sha2Function ;
3333import org .opensearch .sql .expression .function .udf .datetime .AddSubDateFunction ;
3434import org .opensearch .sql .expression .function .udf .datetime .CurrentFunction ;
3535import org .opensearch .sql .expression .function .udf .datetime .DateAddSubFunction ;
5555import org .opensearch .sql .expression .function .udf .math .DivideFunction ;
5656import org .opensearch .sql .expression .function .udf .math .EulerFunction ;
5757import org .opensearch .sql .expression .function .udf .math .ModFunction ;
58- import org .opensearch .sql .calcite .utils .UserDefinedFunctionUtils ;
59- import org .opensearch .sql .expression .datetime .DateTimeFunctions ;
6058
6159/** Defines functions and operators that are implemented only by PPL */
6260public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
@@ -68,7 +66,7 @@ public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
6866 public static final SqlOperator MOD = new ModFunction ().toUDF ("MOD" );
6967 public static final SqlOperator CRC32 = new CRC32Function ().toUDF ("CRC32" );
7068 public static final SqlOperator DIVIDE = new DivideFunction ().toUDF ("DIVIDE" );
71- public static final SqlOperator SHA2 = CryptographicFunction .sha2 ().toUDF ("SHA2" );
69+ public static final SqlOperator SHA2 = Sha2Function .sha2 ().toUDF ("SHA2" );
7270
7371 // Datetime function
7472 public static final SqlOperator TIMESTAMP = new TimestampFunction ().toUDF ("TIMESTAMP" );
@@ -223,7 +221,11 @@ public class PPLBuiltinOperators extends ReflectiveSqlOperatorTable {
223221 DateTimeFunctions .class ,
224222 "exprTimeDiff" ,
225223 PPLReturnTypes .TIME_FORCE_NULLABLE ,
226- NullPolicy .ANY )
224+ NullPolicy .ANY ,
225+ UDFOperandMetadata .wrap (
226+ (CompositeOperandTypeChecker )
227+ OperandTypes .family (SqlTypeFamily .TIME , SqlTypeFamily .TIME )
228+ .or (OperandTypes .STRING_STRING )))
227229 .toUDF ("TIME_DIFF" );
228230 public static final SqlOperator TIMESTAMPADD = new TimestampAddFunction ().toUDF ("TIMESTAMPADD" );
229231 public static final SqlOperator TO_DAYS =
0 commit comments