[improvement](jdbc catalog)Adjustment to JDBC External Table Configuration Based on Internal Table Settings (#25059)

This pull request addresses the behavior of the `lower_case_table_names` parameter for jdbc catalog's based on the configuration of the internal table's corresponding parameter.

Changes:
- For internal tables, if `lower_case_table_names` is set to 1 or 2, thejdbc catalog's parameter is forcefully set to `true`.
- For internal tables, if `lower_case_table_names` is set to 0, the jdbc catalog's parameter can be either `true` or `false` with a default value of `false`.

These adjustments ensure consistency and predictability when working with both internal and external table configurations in Doris.
This commit is contained in:
zy-kkk
2023-10-07 06:25:52 -05:00
committed by GitHub
parent 9d0f4c0094
commit 5130a6c006
3 changed files with 13 additions and 2 deletions

View File

@ -74,7 +74,7 @@ When `lower_case_table_names` is set to `true`, Doris is able to query non-lower
1. In versions before Doris 2.0.3, it is only valid for Oracle database. When querying, all library names and table names will be converted to uppercase before querying Oracle, for example:
Oracle has the TEST table in the TEST space. When Doris creates the Catalog, set `lower_case_table_names` to `true`, then Doris can query the TEST table through `select * from oracle_catalog.test.test`, and Doris will automatically format test.test into TEST.TEST is sent to Oracle. It should be noted that this is the default behavior, which also means that lowercase table names in Oracle cannot be queried.
Oracle has the TEST table in the TEST space. When Doris creates the Catalog, set `lower_case_table_names` to `true`, then Doris can query the TEST table through `select * from oracle_catalog.test.test`, and Doris will automatically format test.test into TEST.TEST is sent to Oracle. It should be noted that this is the default behavior, which also means that lowercase table names in Oracle cannot be queried.
For other databases, you still need to specify the real library name and table name when querying.
@ -82,6 +82,8 @@ Oracle has the TEST table in the TEST space. When Doris creates the Catalog, set
However, if the database or table names differ only in case, such as `Doris` and `doris`, Doris cannot query them due to ambiguity.
3. When the FE parameter's `lower_case_table_names` is set to `1` or `2`, the JDBC Catalog's `lower_case_table_names` parameter must be set to `true`. If the FE parameter's `lower_case_table_names` is set to `0`, the JDBC Catalog parameter can be `true` or `false` and defaults to `false`. This ensures consistency and predictability in how Doris handles internal and external table configurations.
### Specify synchronization database:
`only_specified_database`:

View File

@ -80,7 +80,9 @@ PROPERTIES ("key"="value", ...)
2. 在 Doris 2.0.3 及之后的版本,对所有的数据库都有效,在查询时,会将所有的库名和表名转换为真实的名称,再去查询,如果是从老版本升级到 2.0.3 ,需要 `Refresh <catalog_name>` 才能生效。
但是,如果数据库或者表名只有大小写不同,例如 `Doris``doris`,则 Doris 由于歧义而无法查询它们。
但是,如果数据库或者表名只有大小写不同,例如 `Doris``doris`,则 Doris 由于歧义而无法查询它们。
3. 当 FE 参数的 `lower_case_table_names` 设置为 `1``2` 时,JDBC Catalog 的 `lower_case_table_names` 参数必须设置为 `true`。如果 FE 参数的 `lower_case_table_names` 设置为 `0`,则 JDBC Catalog 的参数可以为 `true``false`,默认为 `false`。这确保了 Doris 在处理内部和外部表配置时的一致性和可预测性。
### 指定同步数据库

View File

@ -19,6 +19,7 @@ package org.apache.doris.datasource.jdbc;
import org.apache.doris.catalog.JdbcResource;
import org.apache.doris.catalog.external.JdbcExternalDatabase;
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.datasource.CatalogProperty;
import org.apache.doris.datasource.ExternalCatalog;
@ -125,6 +126,12 @@ public class JdbcExternalCatalog extends ExternalCatalog {
}
public String getLowerCaseTableNames() {
// Forced to true if Config.lower_case_table_names has a value of 1 or 2
if (Config.lower_case_table_names == 1 || Config.lower_case_table_names == 2) {
return "true";
}
// Otherwise, it defaults to false
return catalogProperty.getOrDefault(JdbcResource.LOWER_CASE_TABLE_NAMES, "false");
}