You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2021/03/08 18:29:19 UTC

[GitHub] [calcite] MalteBellmann commented on a change in pull request #2118: [CALCITE-2317] Support JDBC DatabaseMetaData.getFunctions

MalteBellmann commented on a change in pull request #2118:
URL: https://github.com/apache/calcite/pull/2118#discussion_r589651624



##########
File path: core/src/main/java/org/apache/calcite/jdbc/CalciteMetaImpl.java
##########
@@ -502,6 +507,70 @@ CalciteConnectionImpl getConnection() {
         "TABLE_TYPE");
   }
 
+  @Override public MetaResultSet getFunctions(ConnectionHandle ch,
+      String catalog,
+      Pat schemaPattern,
+      Pat functionNamePattern) {
+    final Predicate1<MetaSchema> schemaMatcher = namedMatcher(schemaPattern);
+    return createResultSet(schemas(catalog)
+            .where(schemaMatcher)
+            .selectMany(schema -> functions(schema, catalog, matcher(functionNamePattern)))
+            .orderBy(x ->
+                (Comparable) FlatLists.of(
+                    x.functionCat, x.functionSchem, x.functionName, x.specificName
+                )),
+        MetaFunction.class,
+        "FUNCTION_CAT",
+        "FUNCTION_SCHEM",
+        "FUNCTION_NAME",
+        "REMARKS",
+        "FUNCTION_TYPE",
+        "SPECIFIC_NAME");
+  }
+
+  Enumerable<MetaFunction> functions(final MetaSchema schema_, final String catalog) {
+    final CalciteMetaSchema schema = (CalciteMetaSchema) schema_;
+    Enumerable<MetaFunction> opTableFunctions = Linq4j.emptyEnumerable();
+    if (schema.getName().equals("metadata")) {

Review comment:
       The idea was: It is hardcoded in https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/jdbc/CalciteSchema.java#L525-L527 and I didn't see a better way.
   
   But I just realized, I can use `MetadataSchema.INSTANCE` for the check. I will update the PR accordingly




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org