och5351 commented on code in PR #183:
URL:
https://github.com/apache/flink-connector-jdbc/pull/183#discussion_r2702793132
##########
flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/core/database/catalog/AbstractJdbcCatalog.java:
##########
@@ -579,14 +574,69 @@ protected String getSchemaTableName(ObjectPath tablePath)
{
throw new UnsupportedOperationException();
}
+ private Function<String, String> calculateUrlFunction(String url) {
+ final String[] parts;
+ final int questionMarkIndex = url.indexOf('?');
+ if (questionMarkIndex == -1) {
+ parts = url.split("/+", 3);
+ return dbName -> parts.length == 3 ? url.trim() : url.trim() + "/"
+ dbName;
+ } else {
+ String withoutParams = url.substring(0, questionMarkIndex);
+ String prefix = withoutParams.substring(0,
withoutParams.lastIndexOf('/') + 1);
+ return dbName ->
+ dbName == null ? url : prefix + dbName + "?" +
url.substring(questionMarkIndex);
+ }
+ }
+
/**
* URL has to be without database, like "jdbc:dialect://localhost:1234/" or
* "jdbc:dialect://localhost:1234" rather than
"jdbc:dialect://localhost:1234/db".
*/
- protected static void validateJdbcUrl(String url) {
- String[] parts = url.trim().split("\\/+");
-
- checkArgument(parts.length == 2);
+ protected static String validateJdbcUrl(String url, String
defaultDatabase) {
+
+ final String noDatabaseError = "No default database specified. Please
set a database name.";
Review Comment:
like this!
--
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]