Skip to content

Commit b2d92a3

Browse files
committed
Add javadoc for function registries in PPLFuncImpTable
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 34132e9 commit b2d92a3

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,19 @@ default List<RelDataType> getParams() {
9191
INSTANCE = new PPLFuncImpTable(builder);
9292
}
9393

94+
/**
95+
* The registry for built-in functions. Functions defined by the PPL specification, whose
96+
* implementations are independent of any specific data storage, should be registered here
97+
* internally.
98+
*/
9499
private final ImmutableMap<BuiltinFunctionName, PairList<CalciteFuncSignature, FunctionImp>>
95100
functionRegistry;
101+
102+
/**
103+
* The external function registry. Functions whose implementations depend on a specific data
104+
* engine should be registered here. This reduces coupling between the core module and particular
105+
* storage backends.
106+
*/
96107
private final Map<BuiltinFunctionName, PairList<CalciteFuncSignature, FunctionImp>>
97108
externalFunctionRegistry;
98109

@@ -113,7 +124,11 @@ private PPLFuncImpTable(Builder builder) {
113124
public void registerExternalFunction(BuiltinFunctionName functionName, FunctionImp functionImp) {
114125
CalciteFuncSignature signature =
115126
new CalciteFuncSignature(functionName.getName(), functionImp.getParams());
116-
externalFunctionRegistry.put(functionName, PairList.of(signature, functionImp));
127+
if (externalFunctionRegistry.containsKey(functionName)) {
128+
externalFunctionRegistry.get(functionName).add(signature, functionImp);
129+
} else {
130+
externalFunctionRegistry.put(functionName, PairList.of(signature, functionImp));
131+
}
117132
}
118133

119134
public @Nullable RexNode resolveSafe(

0 commit comments

Comments
 (0)