ClickHouse JDBC URL support (#13884)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
This commit is contained in:
parent
f3690c1be6
commit
fd9949dcd8
|
|
@ -892,6 +892,24 @@ public enum JdbcConnectionUrlParser {
|
|||
|
||||
return builder;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* <a
|
||||
* href="https://clickhouse.com/docs/integrations/language-clients/java/jdbc#configuration">Driver
|
||||
* configuration doc</a> mentions that besides <code>clickhouse</code> <code>ch</code> could also
|
||||
* be used but ClickHouse Connection implementation always returns full prefix <code>
|
||||
* jdbc:clickhouse:</code>
|
||||
*/
|
||||
CLICKHOUSE("clickhouse") {
|
||||
@Override
|
||||
DbInfo.Builder doParse(String jdbcUrl, DbInfo.Builder builder) {
|
||||
String clickhouseUrl = jdbcUrl.substring("clickhouse:".length());
|
||||
int typeEndIndex = clickhouseUrl.indexOf("://");
|
||||
if (typeEndIndex > 0) {
|
||||
builder.subtype(clickhouseUrl.substring(0, typeEndIndex));
|
||||
}
|
||||
return GENERIC_URL_LIKE.doParse(clickhouseUrl, builder);
|
||||
}
|
||||
};
|
||||
|
||||
private static final Logger logger = Logger.getLogger(JdbcConnectionUrlParser.class.getName());
|
||||
|
|
@ -1079,6 +1097,8 @@ public enum JdbcConnectionUrlParser {
|
|||
return DbSystemValues.MSSQL;
|
||||
case "sap": // SAP Hana
|
||||
return DbSystemValues.HANADB;
|
||||
case "clickhouse": // ClickHouse
|
||||
return DbSystemValues.CLICKHOUSE;
|
||||
default:
|
||||
return DbSystemValues.OTHER_SQL; // Unknown DBMS
|
||||
}
|
||||
|
|
@ -1098,6 +1118,7 @@ public enum JdbcConnectionUrlParser {
|
|||
static final String DERBY = "derby";
|
||||
static final String MARIADB = "mariadb";
|
||||
static final String H2 = "h2";
|
||||
static final String CLICKHOUSE = "clickhouse";
|
||||
|
||||
private DbSystemValues() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,6 +207,35 @@ class JdbcConnectionUrlParserTest {
|
|||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{index}: {0}")
|
||||
@ArgumentsSource(ClickHouseProvider.class)
|
||||
void testClickHouseParsing(ParseTestArgument argument) {
|
||||
testVerifySystemSubtypeParsingOfUrl(argument);
|
||||
}
|
||||
|
||||
static final class ClickHouseProvider implements ArgumentsProvider {
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
|
||||
return args(
|
||||
// https://clickhouse.com/docs/integrations/language-clients/java/jdbc#configuration
|
||||
arg("jdbc:clickhouse:http://localhost:8123/mydb")
|
||||
.setShortUrl("clickhouse:http://localhost:8123")
|
||||
.setSystem("clickhouse")
|
||||
.setSubtype("http")
|
||||
.setHost("localhost")
|
||||
.setPort(8123)
|
||||
.setDb("mydb")
|
||||
.build(),
|
||||
arg("jdbc:clickhouse:https://localhost:8443?ssl=true")
|
||||
.setShortUrl("clickhouse:https://localhost:8443")
|
||||
.setSystem("clickhouse")
|
||||
.setSubtype("https")
|
||||
.setHost("localhost")
|
||||
.setPort(8443)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "{index}: {0}")
|
||||
@ArgumentsSource(PostgresProvider.class)
|
||||
void testPostgresParsing(ParseTestArgument argument) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue