rdblue commented on a change in pull request #23915: SPARK-24252: Add v2 catalog plugin system. URL: https://github.com/apache/spark/pull/23915#discussion_r261454690
########## File path: sql/catalyst/src/main/java/org/apache/spark/sql/catalog/v2/Catalogs.java ########## @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.catalog.v2; + +import org.apache.spark.SparkException; +import org.apache.spark.sql.internal.SQLConf; +import org.apache.spark.util.Utils; + +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static scala.collection.JavaConverters.mapAsJavaMapConverter; + +public class Catalogs { + private Catalogs() { + } + + /** + * Load and configure a catalog by name. + * <p> + * This loads, instantiates, and initializes the catalog plugin for each call; it does not cache + * or reuse instances. + * + * @param name a String catalog name + * @param conf a SQLConf + * @return an initialized CatalogPlugin + * @throws SparkException If the plugin class cannot be found or instantiated + */ + public static CatalogPlugin load(String name, SQLConf conf) throws SparkException { Review comment: I'm reluctant to use `Utils.loadExtensions` instead of this: * The error messages aren't as clear because they don't identify the catalog name (e.g. "Plugin class for catalog 'foo' does not implement CatalogPlugin: com.example.MyCatalog") * It doesn't catch as many cases, like `IllegalAccessException` * It is awkward to call because it s a Scala API and requires a Seq I think for the error messages, we should keep this as is. Catching generic errors from `loadExtensions` and adding metadata would end up being just as much code with errors that are less helpful because there are more options ("did not have a no-arg constructor or a constructor that accepts SparkConf ..." I can update this to use SparkConf if it would be better that way. What do you think? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
