github-actions[bot] commented on code in PR #65709:
URL: https://github.com/apache/doris/pull/65709#discussion_r3600374736
##########
fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/client/JdbcClickHouseConnectorClient.java:
##########
@@ -145,25 +146,31 @@ protected Set<String> getFilterInternalDatabases() {
private boolean isNewClickHouseDriver(Connection conn) throws SQLException
{
if (isNewDriver == null) {
- String driverVersion = conn.getMetaData().getDriverVersion();
- isNewDriver = driverVersion != null &&
!driverVersion.startsWith("0.3")
- && !driverVersion.startsWith("0.4");
- if (!isNewDriver) {
- // Old driver uses schema mode (not catalog), matching old
JdbcClickHouseClient
- databaseTermIsCatalog = false;
- } else {
- // New driver checks the JDBC URL for databaseterm parameter
- databaseTermIsCatalog =
"catalog".equalsIgnoreCase(getDatabaseTermFromUrl());
- }
+ DatabaseMetaData meta = conn.getMetaData();
+ String driverVersion = meta.getDriverVersion();
+ isNewDriver = isNewClickHouseDriverVersion(driverVersion);
+ databaseTermIsCatalog = isDatabaseTermCatalog(
+ driverVersion, meta.supportsCatalogsInDataManipulation());
}
return isNewDriver;
}
- private String getDatabaseTermFromUrl() {
- if (jdbcUrl != null &&
jdbcUrl.toLowerCase().contains("databaseterm=schema")) {
- return "schema";
+ static boolean isNewClickHouseDriverVersion(String driverVersion) {
+ if (driverVersion == null) {
+ throw new DorisConnectorException("ClickHouse driver version
cannot be null");
}
- return "catalog";
+ try {
+ String[] versionParts = driverVersion.split("\\.");
+ int majorVersion = Integer.parseInt(versionParts[0]);
Review Comment:
[P1] Preserve versionless custom ClickHouse drivers
Doris accepts a custom `driver_url`/`driver_class` without requiring
manifest version metadata, and ClickHouse 0.7.x returns `""` from
`getDriverVersion()` when a repackaged jar drops `Implementation-Version`. Such
a jar still loads, connects, and serves catalog metadata; the base connector
treated the empty value as a newer driver and selected its configured database
term. This parser now throws before `supportsCatalogsInDataManipulation()` can
choose the namespace mode, so an existing or replayed catalog loses
database/table discovery after upgrade; with `test_connection=false`, a new
catalog can likewise be created and then fail on first metadata access. Please
preserve the 0.3/0.4 override but fall back to the metadata capability for
absent/unparseable versions, and cover the empty-version case.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]