[Improvement] jdbc support dialect.name to choose dialect.#7294
Conversation
| | 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.
| | 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. | | |
|
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 |
| | 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.
Looking back, is it necessary to add this parameter?
There was a problem hiding this comment.
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.
| public String hashModForField(String functionName, String fieldName, int mod) { | |
| public String hashModForField(String nativeType, String fieldName, int mod) { |
| 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)) |
|
|
||
| @Override | ||
| public String getDialectName() { | ||
| return "starrocks"; |
There was a problem hiding this comment.
| return "starrocks"; | |
| return DatabaseIdentifier.STARROCKS; |
| 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.
JdbcSourceConfig sourceConfig
change to
String dialectName
since we only use this parameter.
| 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.
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.
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
|
|
||
| @Override | ||
| public JdbcDialect create(@Nonnull String compatibleMode, String fieldIde) { | ||
| if (DatabaseIdentifier.STARROCKS.equalsIgnoreCase(compatibleMode)) { |
There was a problem hiding this comment.
Almost forgot! We have compatibleMode to do such thing.
a71f906 to
25d1b0f
Compare
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.