Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix][Jdbc Connector]: Fix JdbcCatalogOptions BASE builder will be changed by call required() #6788

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,57 +21,61 @@
import org.apache.seatunnel.api.configuration.Options;
import org.apache.seatunnel.api.configuration.util.OptionRule;

public interface JdbcCatalogOptions {
Option<String> BASE_URL =
public class JdbcCatalogOptions {
public static final Option<String> BASE_URL =
Options.key("base-url")
.stringType()
.noDefaultValue()
.withDescription(
"URL has to be with database, like \"jdbc:mysql://localhost:5432/db\" or"
+ "\"jdbc:mysql://localhost:5432/db?useSSL=true\".");

Option<String> USERNAME =
public static final Option<String> USERNAME =
Options.key("username")
.stringType()
.noDefaultValue()
.withDescription(
"Name of the database to use when connecting to the database server.");

Option<String> PASSWORD =
public static final Option<String> PASSWORD =
Options.key("password")
.stringType()
.noDefaultValue()
.withDescription("Password to use when connecting to the database server.");

Option<String> SCHEMA =
public static final Option<String> SCHEMA =
Options.key("schema")
.stringType()
.noDefaultValue()
.withDescription(
"for databases that support the schema parameter, give it priority.");

Option<String> COMPATIBLE_MODE =
public static final Option<String> COMPATIBLE_MODE =
Options.key("compatibleMode")
.stringType()
.noDefaultValue()
.withDescription(
"The compatible mode of database, required when the database supports multiple compatible modes. "
+ "For example, when using OceanBase database, you need to set it to 'mysql' or 'oracle'.");

OptionRule.Builder BASE_RULE =
OptionRule.builder().required(BASE_URL).required(USERNAME, PASSWORD).optional(SCHEMA);

Option<String> TABLE_PREFIX =
public static final Option<String> TABLE_PREFIX =
Options.key("tablePrefix")
.stringType()
.noDefaultValue()
.withDescription(
"The table prefix name added when the table is automatically created");

Option<String> TABLE_SUFFIX =
public static final Option<String> TABLE_SUFFIX =
Options.key("tableSuffix")
.stringType()
.noDefaultValue()
.withDescription(
"The table suffix name added when the table is automatically created");

public static OptionRule.Builder base() {
return OptionRule.builder()
.required(BASE_URL)
.required(USERNAME, PASSWORD)
.optional(SCHEMA);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public Catalog createCatalog(String catalogName, ReadonlyConfig options) {

@Override
public OptionRule optionRule() {
return JdbcCatalogOptions.BASE_RULE.build();
return JdbcCatalogOptions.base().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public Catalog createCatalog(String catalogName, ReadonlyConfig options) {

@Override
public OptionRule optionRule() {
return JdbcCatalogOptions.BASE_RULE.build();
return JdbcCatalogOptions.base().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ public Catalog createCatalog(String catalogName, ReadonlyConfig options) {

@Override
public OptionRule optionRule() {
return JdbcCatalogOptions.BASE_RULE.required(JdbcCatalogOptions.COMPATIBLE_MODE).build();
return JdbcCatalogOptions.base().required(JdbcCatalogOptions.COMPATIBLE_MODE).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public Catalog createCatalog(String catalogName, ReadonlyConfig options) {

@Override
public OptionRule optionRule() {
return JdbcCatalogOptions.BASE_RULE.build();
return JdbcCatalogOptions.base().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public Catalog createCatalog(String catalogName, ReadonlyConfig options) {

@Override
public OptionRule optionRule() {
return JdbcCatalogOptions.BASE_RULE.build();
return JdbcCatalogOptions.base().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public Catalog createCatalog(String catalogName, ReadonlyConfig options) {

@Override
public OptionRule optionRule() {
return JdbcCatalogOptions.BASE_RULE.build();
return JdbcCatalogOptions.base().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public Catalog createCatalog(String catalogName, ReadonlyConfig options) {

@Override
public OptionRule optionRule() {
return JdbcCatalogOptions.BASE_RULE.build();
return JdbcCatalogOptions.base().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public Catalog createCatalog(String catalogName, ReadonlyConfig options) {

@Override
public OptionRule optionRule() {
return JdbcCatalogOptions.BASE_RULE.build();
return JdbcCatalogOptions.base().build();
}
}