zzwqqq commented on code in PR #4794:
URL: https://github.com/apache/calcite/pull/4794#discussion_r2807472936
##########
core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java:
##########
@@ -171,14 +172,57 @@ private Collection<org.apache.calcite.schema.Function>
getFunctionsFrom(
SqlValidatorUtil.getSchema(rootSchema,
Iterables.concat(schemaNames, Util.skipLast(names)),
nameMatcher);
if (schema != null) {
- final String name = Util.last(names);
- boolean caseSensitive = nameMatcher.isCaseSensitive();
- functions2.addAll(schema.getFunctions(name, caseSensitive));
+ final String functionName = Util.last(names);
+ if (nameMatcher.isCaseSensitive()) {
+ addFunctions(functions2, schema, names, functionName, true);
+ } else {
+ boolean hasMatchedFunctionName = false;
+ for (String candidateFunctionName : schema.getFunctionNames()) {
+ if (nameMatcher.matches(functionName, candidateFunctionName)) {
+ hasMatchedFunctionName = true;
+ // candidateFunctionName already has canonical case from schema.
+ // Use case-sensitive lookup to bind each function to that exact
name.
+ addFunctions(functions2, schema, names, candidateFunctionName,
true);
+ }
+ }
+ if (!hasMatchedFunctionName) {
+ // Fallback for schemas where getFunctionNames() is incomplete but
+ // getFunctions(name, false) can still resolve functions.
+ addFunctions(functions2, schema, names, functionName, false);
+ }
+ }
}
}
return functions2;
}
+ private static SqlIdentifier resolvedFunctionIdentifier(CalciteSchema schema,
Review Comment:
I have rename `resolvedFunctionIdentifier` to `createResolvedIdentifier`.
Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]