mchades commented on code in PR #13942:
URL: https://github.com/apache/gravitino/pull/13942#discussion_r4312228984
##########
server/src/main/java/org/apache/gravitino/server/web/rest/CatalogOperations.java:
##########
@@ -168,7 +168,8 @@ public Response createCatalog(
request.getType(),
request.getProvider(),
request.getComment(),
- request.getProperties(),
+ JdbcDriverProperties.withDefaultDriver(
+ request.getProvider(), request.getProperties()),
Review Comment:
[P2] Preserve the driver from the provider configuration
Please derive the default after merging the provider configuration.
`CatalogManager.mergeConf()` gives request properties precedence, so injecting
a driver here overwrites `jdbc-driver` in `<provider>.conf` even when the
caller omits it. For example, a configured `com.oceanbase.jdbc.Driver` becomes
`com.mysql.cj.jdbc.Driver`, breaking previously valid create/test requests
using `jdbc:oceanbase:`. The test-connection endpoint has the same regression.
##########
server/src/main/java/org/apache/gravitino/server/web/rest/JdbcDriverProperties.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.gravitino.server.web.rest;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+/** Adds the known JDBC driver class to catalog properties when the caller
omits it. */
+public final class JdbcDriverProperties {
+
+ private static final String JDBC_DRIVER = "jdbc-driver";
+ private static final Map<String, String> PROVIDER_DRIVERS =
+ ImmutableMap.<String, String>builder()
+ .put("jdbc-clickhouse", "com.clickhouse.jdbc.ClickHouseDriver")
+ .put("jdbc-doris", "com.mysql.cj.jdbc.Driver")
+ .put("jdbc-hologres", "org.postgresql.Driver")
+ .put("jdbc-mysql", "com.mysql.cj.jdbc.Driver")
+ .put("jdbc-oceanbase", "com.mysql.cj.jdbc.Driver")
Review Comment:
[P2] Select the driver for the native OceanBase URL scheme
`jdbc-oceanbase` also supports `jdbc:oceanbase://...`, but this always
chooses the MySQL driver. MySQL Connector/J 8.0.33 returns `false` from
`acceptsURL()` for that scheme, so these requests still fail without an
explicit driver even when the OceanBase driver is installed. Please select
`com.oceanbase.jdbc.Driver` for the native scheme and cover this documented URL
in the tests.
--
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]