@@ -182,19 +182,21 @@ public interface BuiltinFunctionTransformer {
182182 // Relative time functions
183183 .put (
184184 RELATIVE_TIMESTAMP ,
185- BuiltinFunctionTransformer :: buildRelativeTimestampExpression )
185+ args -> buildRelativeTimestamp ( args . get ( 0 )) )
186186 .put (
187187 EARLIEST ,
188- args ->
189- LessThanOrEqual$ .MODULE$ .apply (
190- buildRelativeTimestampExpression (List .of (args .get (0 ))),
191- args .get (1 )))
188+ args -> {
189+ Expression relativeTimestamp = buildRelativeTimestamp (args .get (0 ));
190+ Expression timestamp = args .get (1 );
191+ return LessThanOrEqual$ .MODULE$ .apply (relativeTimestamp , timestamp );
192+ })
192193 .put (
193194 LATEST ,
194- args ->
195- GreaterThanOrEqual$ .MODULE$ .apply (
196- buildRelativeTimestampExpression (List .of (args .get (0 ))),
197- args .get (1 )))
195+ args -> {
196+ Expression relativeTimestamp = buildRelativeTimestamp (args .get (0 ));
197+ Expression timestamp = args .get (1 );
198+ return GreaterThanOrEqual$ .MODULE$ .apply (relativeTimestamp , timestamp );
199+ })
198200 .build ();
199201
200202 static Expression builtinFunction (org .opensearch .sql .ast .expression .Function function , List <Expression > args ) {
@@ -237,9 +239,9 @@ static Expression[] createIntervalArgs(IntervalUnit unit, Expression value) {
237239 return args ;
238240 }
239241
240- private static Expression buildRelativeTimestampExpression ( List < Expression > args ) {
242+ private static Expression buildRelativeTimestamp ( Expression relativeStringExpression ) {
241243 return SerializableUdf .visit (
242244 RELATIVE_TIMESTAMP .getName ().getFunctionName (),
243- List .of (args . get ( 0 ) , CurrentTimestamp$ .MODULE$ .apply (), CurrentTimeZone$ .MODULE$ .apply ()));
245+ List .of (relativeStringExpression , CurrentTimestamp$ .MODULE$ .apply (), CurrentTimeZone$ .MODULE$ .apply ()));
244246 }
245247}
0 commit comments