-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Improvement] jdbc support dialect.name to choose dialect. #7294
[Improvement] jdbc support dialect.name to choose dialect. #7294
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @hailin0
docs/en/connector-v2/source/Jdbc.md
Outdated
@@ -60,6 +60,7 @@ supports query SQL and can achieve projection effect. | |||
| table_list | Array | No | - | The list of tables to be read, you can use this configuration instead of `table_path` | | |||
| where_condition | String | No | - | Common row filter conditions for all tables/queries, must start with `where`. for example `where id > 100` | | |||
| split.size | Int | No | 8096 | How many rows in one split, captured tables are split into multiple splits when read of table. | | |||
| split.hash-function | String | No | - | Which hash function use to split. <br/> default is `MD5`, oracle is `ORA_HASH`, Postgres is `HASHTEXT`.<br/> if the default function is not work, you can use this parameter to customize the hash function. | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| split.hash-function | String | No | - | Which hash function use to split. <br/> default is `MD5`, oracle is `ORA_HASH`, Postgres is `HASHTEXT`.<br/> if the default function is not work, you can use this parameter to customize the hash function. | | | |
| split.hash-function | String | No | - | Which hash function use to split. <br/> Default is `MD5`, Oracle is `ORA_HASH`, PostgreSQL is `HASHTEXT`.<br/> If the default function is not work, you can use this parameter to customize the hash function. | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Why not separate the dialect from the driver? cc @Hisoka-X
|
Now the dialect is parse from jdbc url, mysql and starrocks both use mysql driver |
I prefer adding the |
We often use a certain client to access a variety of different database servers, which have many differences. Dialects can cover more differences. e.g: |
I get it. Make sense to me. |
updated, has add a parameter |
docs/en/connector-v2/source/Jdbc.md
Outdated
@@ -60,6 +60,7 @@ supports query SQL and can achieve projection effect. | |||
| table_list | Array | No | - | The list of tables to be read, you can use this configuration instead of `table_path` | | |||
| where_condition | String | No | - | Common row filter conditions for all tables/queries, must start with `where`. for example `where id > 100` | | |||
| split.size | Int | No | 8096 | How many rows in one split, captured tables are split into multiple splits when read of table. | | |||
| split.hash-function | String | No | - | Which hash function use to split. <br/> Default is `MD5`, Oracle is `ORA_HASH`, PostgreSQL is `HASHTEXT`.<br/> If the default function is not work, you can use this parameter to customize the hash function. | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking back, is it necessary to add this parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will remove this parameter
e689924
to
214d5f9
Compare
} | ||
|
||
@Override | ||
public String hashModForField(String functionName, String fieldName, int mod) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public String hashModForField(String functionName, String fieldName, int mod) { | |
public String hashModForField(String nativeType, String fieldName, int mod) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -62,7 +63,9 @@ public static JdbcDialect load(String url, String compatibleMode, String fieldId | |||
} | |||
|
|||
final List<JdbcDialectFactory> matchingFactories = | |||
foundFactories.stream().filter(f -> f.acceptsURL(url)).collect(Collectors.toList()); | |||
foundFactories.stream() | |||
.filter(f -> f.acceptsURL(url) && f.getDialectName().equals(dialectName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore case?
|
||
@Override | ||
public String getDialectName() { | ||
return "starrocks"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return "starrocks"; | |
return DatabaseIdentifier.STARROCKS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
public static Map<TablePath, JdbcSourceTable> getTables( | ||
JdbcConnectionConfig jdbcConnectionConfig, List<JdbcSourceTableConfig> tablesConfig) | ||
JdbcConnectionConfig jdbcConnectionConfig, | ||
List<JdbcSourceTableConfig> tablesConfig, | ||
JdbcSourceConfig sourceConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JdbcSourceConfig sourceConfig
change to
String dialectName
since we only use this parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update
Option<String> DIALECT_NAME = | ||
Options.key("dialect.name") | ||
.stringType() | ||
.defaultValue("default") | ||
.withDescription( | ||
"The dialect name, when use same jdbc drive, use this parameter to choose the special implement."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I use this config will not work right?
Jdbc {
driver = com.mysql.cj.jdbc.Driver
url = "jdbc:mysql://mysql:9030"
user = root
password = ""
query = "select * from `test`.`e2e_table_source`"
partition_column = "STRING_COL"
dialect.name = "mysql"
}
It's weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, if we support dialect.name = "mysql" then this parameter is required to mysql connector, it will impact the current user.
and i think this feature is the special requirement, use same jdbc driver, and the default dialect can not support some feature, it can use this parameter to choose the corresponding dialect implement.
In this case, only those user need this feature need add this parameter
d4713ea
to
d5f3ac7
Compare
6b62ed5
to
a71f906
Compare
@@ -39,6 +41,9 @@ public JdbcDialect create() { | |||
|
|||
@Override | |||
public JdbcDialect create(@Nonnull String compatibleMode, String fieldIde) { | |||
if (DatabaseIdentifier.STARROCKS.equalsIgnoreCase(compatibleMode)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost forgot! We have compatibleMode
to do such thing.
a71f906
to
25d1b0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @liunaijie
Purpose of this pull request
close #7293
Does this PR introduce any user-facing change?
How was this patch tested?
add new test
Check list
New License Guide
release-note
.