188188
189189public class EsqlFunctionRegistry {
190190
191- private static final Map <Class <? extends Function >, List <DataType >> DATA_TYPES_FOR_STRING_LITERAL_CONVERSIONS = new LinkedHashMap <>();
192-
193191 private static final Map <DataType , Integer > DATA_TYPE_CASTING_PRIORITY ;
194192
195193 static {
@@ -225,6 +223,7 @@ public class EsqlFunctionRegistry {
225223 private final Map <String , FunctionDefinition > defs = new LinkedHashMap <>();
226224 private final Map <String , String > aliases = new HashMap <>();
227225 private final Map <Class <? extends Function >, String > names = new HashMap <>();
226+ private final Map <Class <? extends Function >, List <DataType >> dataTypesForStringLiteralConversions = new LinkedHashMap <>();
228227
229228 private SnapshotFunctionRegistry snapshotRegistry = null ;
230229
@@ -320,7 +319,6 @@ private static FunctionDefinition[][] functions() {
320319 def (Greatest .class , Greatest ::new , "greatest" ),
321320 def (Hypot .class , Hypot ::new , "hypot" ),
322321 def (Log .class , Log ::new , "log" ),
323- def (Log10 .class , Log10 ::new , "log10" ),
324322 def (Least .class , Least ::new , "least" ),
325323 def (Pi .class , Pi ::new , "pi" ),
326324 def (Pow .class , Pow ::new , "pow" ),
@@ -445,7 +443,8 @@ private static FunctionDefinition[][] snapshotFunctions() {
445443 // This is an experimental function and can be removed without notice.
446444 def (Delay .class , Delay ::new , "delay" ),
447445 def (Rate .class , Rate ::withUnresolvedTimestamp , "rate" ),
448- def (Term .class , bi (Term ::new ), "term" ) } };
446+ def (Term .class , bi (Term ::new ), "term" ),
447+ def (Log10 .class , Log10 ::new , "log10" ) } };
449448 }
450449
451450 public EsqlFunctionRegistry snapshotRegistry () {
@@ -711,20 +710,8 @@ private static Constructor<?> constructorFor(Class<? extends Function> clazz) {
711710 return constructors [0 ];
712711 }
713712
714- private void buildDataTypesForStringLiteralConversion (FunctionDefinition []... groupFunctions ) {
715- for (FunctionDefinition [] group : groupFunctions ) {
716- for (FunctionDefinition def : group ) {
717- FunctionDescription signature = description (def );
718- DATA_TYPES_FOR_STRING_LITERAL_CONVERSIONS .put (
719- def .clazz (),
720- signature .args ().stream ().map (EsqlFunctionRegistry .ArgSignature ::targetDataType ).collect (Collectors .toList ())
721- );
722- }
723- }
724- }
725-
726713 public List <DataType > getDataTypeForStringLiteralConversion (Class <? extends Function > clazz ) {
727- return DATA_TYPES_FOR_STRING_LITERAL_CONVERSIONS .get (clazz );
714+ return dataTypesForStringLiteralConversions .get (clazz );
728715 }
729716
730717 private static class SnapshotFunctionRegistry extends EsqlFunctionRegistry {
@@ -733,6 +720,7 @@ private static class SnapshotFunctionRegistry extends EsqlFunctionRegistry {
733720 throw new IllegalStateException ("build snapshot function registry for non-snapshot build" );
734721 }
735722 register (snapshotFunctions ());
723+ buildDataTypesForStringLiteralConversion (snapshotFunctions ());
736724 }
737725
738726 }
@@ -793,6 +781,18 @@ void register(FunctionDefinition... functions) {
793781 );
794782 }
795783
784+ protected void buildDataTypesForStringLiteralConversion (FunctionDefinition []... groupFunctions ) {
785+ for (FunctionDefinition [] group : groupFunctions ) {
786+ for (FunctionDefinition def : group ) {
787+ FunctionDescription signature = description (def );
788+ dataTypesForStringLiteralConversions .put (
789+ def .clazz (),
790+ signature .args ().stream ().map (EsqlFunctionRegistry .ArgSignature ::targetDataType ).collect (Collectors .toList ())
791+ );
792+ }
793+ }
794+ }
795+
796796 protected FunctionDefinition cloneDefinition (String name , FunctionDefinition definition ) {
797797 return new FunctionDefinition (name , emptyList (), definition .clazz (), definition .builder ());
798798 }
0 commit comments