From 5130a6c006eb41ed8df7f415cf0183f01fe68a75 Mon Sep 17 00:00:00 2001 From: zy-kkk Date: Sat, 7 Oct 2023 06:25:52 -0500 Subject: [PATCH] [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. --- docs/en/docs/lakehouse/multi-catalog/jdbc.md | 4 +++- docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md | 4 +++- .../apache/doris/datasource/jdbc/JdbcExternalCatalog.java | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/en/docs/lakehouse/multi-catalog/jdbc.md b/docs/en/docs/lakehouse/multi-catalog/jdbc.md index 812f456318..d629484606 100644 --- a/docs/en/docs/lakehouse/multi-catalog/jdbc.md +++ b/docs/en/docs/lakehouse/multi-catalog/jdbc.md @@ -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`: diff --git a/docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md b/docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md index 493f02e525..ec3a37ab42 100644 --- a/docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md +++ b/docs/zh-CN/docs/lakehouse/multi-catalog/jdbc.md @@ -80,7 +80,9 @@ PROPERTIES ("key"="value", ...) 2. 在 Doris 2.0.3 及之后的版本,对所有的数据库都有效,在查询时,会将所有的库名和表名转换为真实的名称,再去查询,如果是从老版本升级到 2.0.3 ,需要 `Refresh ` 才能生效。 - 但是,如果数据库或者表名只有大小写不同,例如 `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 在处理内部和外部表配置时的一致性和可预测性。 ### 指定同步数据库 diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalog.java index 0dd2cc2260..df1d442b9d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/JdbcExternalCatalog.java @@ -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"); }