DanielLeens commented on code in PR #11165:
URL: https://github.com/apache/seatunnel/pull/11165#discussion_r3473887118
##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/config/JdbcCommonOptions.java:
##########
@@ -162,38 +165,42 @@ public class JdbcCommonOptions {
public static final Option<String> REGION =
Options.key("region").stringType().noDefaultValue().withDescription("region");
- /** @deprecated Use {@link #baseCatalogRule()} instead to avoid shared
mutable state. */
- @Deprecated public static final OptionRule.Builder BASE_CATALOG_RULE =
baseCatalogRule();
-
/**
- * Returns a fresh {@link OptionRule.Builder} with the base validation
rules shared by all JDBC
- * catalog factories (MySQL, PostgreSQL, Oracle, etc.).
+ * Returns a fresh {@link OptionRule.Builder} with the base validation
rules shared by standard
+ * JDBC catalog factories (MySQL, PostgreSQL, etc.) that use generic
{@code host:port/database}
+ * URL format and require username/password authentication.
*
- * <p>These rules are evaluated at <b>submission time</b> via {@code
- * ConfigValidator.validate(factory.optionRule())} in the {@code
FactoryUtil} entry path. They
- * enforce that the JDBC URL contains a database name, and that
username/password are provided.
+ * <p>Catalog factories with non-standard URL formats (SqlServer, Oracle,
SapHana) should use
+ * {@link #baseCatalogRule(ConditionExtension)} with their own URL
validator.
*
- * <p>Individual catalog factories may append additional rules (e.g.
OceanBase requires {@code
- * compatible_mode}) before calling {@code .build()}.
+ * <p>Catalog factories that do not require authentication (e.g. DuckDB)
should define their own
+ * {@code optionRule()} directly.
*/
public static OptionRule.Builder baseCatalogRule() {
+ return baseCatalogRule(new UrlContainsDatabaseValidator());
+ }
+
+ /**
+ * Returns a fresh {@link OptionRule.Builder} with a custom URL validator.
Use this for
+ * databases whose JDBC URL does not follow the standard {@code
host:port/database} format (e.g.
+ * SqlServer, Oracle, SapHana).
+ */
+ public static OptionRule.Builder
baseCatalogRule(ConditionExtension<String> urlValidator) {
return OptionRule.builder()
- .required(URL, Conditions.extension(URL, new
UrlContainsDatabaseValidator()))
+ .required(URL, Conditions.extension(URL, urlValidator))
.required(USERNAME, PASSWORD)
.optional(SCHEMA, DECIMAL_TYPE_NARROWING,
HANDLE_BLOB_AS_STRING);
Review Comment:
Examples do exist. Common ones are trust-auth / integrated-auth setups where
the catalog path still needs a username, but the password is not passed in the
SeaTunnel config at all. The SeaTunnel-side reason this matters is that the
current runtime path already allows `pwd == null`:
`JdbcCatalogUtils.extractCatalogConfig(...)` only forwards `password` when
present, and `AbstractJdbcCatalog.getConnectionProperties()` only adds the
`password` property when it is non-null.
So the compatibility gap here is not hypothetical. On the current head,
submission-time validation is still stricter than the real JDBC catalog runtime
contract for `password`.
--
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]