Skip to content

Commit b8d6437

Browse files
mergify[bot]jaogoy
andauthored
[BugFix] change max string length to 1M when unknown (backport #67873) (backport #68132) (#68136)
Signed-off-by: jaogoy <jaogoy@gmail.com> Co-authored-by: Planck Li <jaogoy@gmail.com>
1 parent 9ddac42 commit b8d6437

8 files changed

Lines changed: 43 additions & 1 deletion

File tree

docs/en/cover_pages/bi_tools.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ displayed_sidebar: docs
66

77
import DocCardList from '@theme/DocCardList';
88

9+
> Tip: If a BI tool relies on the string max length in query metadata and that length is smaller than actual values (causing empty returns), set the global variable `max_unknown_string_meta_length` (1~1,048,576, default 64) to a higher value so string columns return that length in metadata.
10+
911
<DocCardList />

docs/en/sql-reference/System_variable.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,13 @@ Default value: `true`.
484484
* **Description**: Whether to cache pointers and partition names for Iceberg tables. From v3.2.1 to v3.2.3, this parameter is set to `true` by default, regardless of what metastore service is used. In v3.2.4 and later, if the Iceberg cluster uses AWS Glue as metastore, this parameter still defaults to `true`. However, if the Iceberg cluster uses other metastore service such as Hive metastore, this parameter defaults to `false`.
485485
* **Introduced in**: v3.2.1
486486

487+
### max_unknown_string_meta_length (global)
488+
489+
* **Description**: Fallback length for string columns in query result metadata when the max length is unknown. Clients that rely on the metadata may return empty values or truncation if the reported length is smaller than actual values. Valid range is `1` to `1048576`.
490+
* **Default**: 64
491+
* **Data Type**: int
492+
* **Introduced in**: v3.5.13
493+
487494
### enable_metadata_profile
488495

489496
* **Description**: Whether to enabled Profile for Iceberg Catalog metadata.

docs/ja/cover_pages/bi_tools.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ displayed_sidebar: docs
66

77
import DocCardList from '@theme/DocCardList';
88

9+
> ヒント:BI ツールが結果セットのメタデータに含まれる文字列最大長に依存し、その値が実際より小さいために空値や切り詰めが発生する場合は、グローバル変数 `max_unknown_string_meta_length`(範囲 1〜1,048,576、デフォルト 64)を大きく設定すると、文字列列のメタデータ長がその値にフォールバックします。
10+
911
<DocCardList />

docs/ja/sql-reference/System_variable.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,13 @@ MySQL クライアント互換性のために使用されます。実際の用
474474
* **説明**: Iceberg テーブルのポインタとパーティション名をキャッシュするかどうか。v3.2.1 から v3.2.3 では、メタストアサービスに関係なく、このパラメータはデフォルトで `true` に設定されています。v3.2.4 以降では、Iceberg クラスタがメタストアとして AWS Glue を使用している場合、このパラメータはデフォルトで `true` に設定されています。ただし、Iceberg クラスタが Hive メタストアなどの他のメタストアサービスを使用している場合、このパラメータはデフォルトで `false` に設定されています。
475475
* **導入バージョン**: v3.2.1
476476

477+
### max_unknown_string_meta_length (global)
478+
479+
* **説明**: 文字列列の最大長が不明な場合にメタデータで使用するフォールバック長。メタデータの長さが実際より小さいと、一部の BI ツールで空値や切り詰めが発生する可能性があります。`0` 以下は `64` にフォールバックします。有効範囲は `1``1048576`
480+
* **デフォルト**: 64
481+
* **データ型**: Int
482+
* **導入バージョン**: v3.5.13
483+
477484
### enable_metadata_profile
478485

479486
* **説明**: Iceberg Catalog のメタデータ収集クエリに対して Profile を有効にするかどうか。

docs/zh/cover_pages/bi_tools.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ displayed_sidebar: docs
66

77
import DocCardList from '@theme/DocCardList';
88

9+
> 提示:如果 BI 工具依赖返回结果集元数据中的字符串最大长度,而该长度小于真实值导致返回空值,可将全局变量 `max_unknown_string_meta_length`(范围 1~1048576,默认 64)调大,使字符串列在元数据中返回该长度。
10+
911
<DocCardList />

docs/zh/sql-reference/System_variable.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,13 @@ ALTER USER 'jack' SET PROPERTIES ('session.query_timeout' = '600');
480480
* 描述:是否缓存 Iceberg 表指针和分区名相关的数据。在 3.2.1 到 3.2.3 版本,该参数默认值统一为 `true`。自 3.2.4 版本起,如果 Iceberg 集群的元数据服务为 AWS Glue,该参数默认值仍为 `true`,如果 Iceberg 集群的元数据服务为 Hive Metastore(简称 HMS)或其他,则该参数默认值变更为 `false`
481481
* 引入版本:v3.2.1
482482

483+
### max_unknown_string_meta_length (global)
484+
485+
* 描述:当字符串列的最大长度未知时用于元数据的回退长度。如果客户端依赖该元数据且报告的长度小于真实值,部分 BI 工具可能返回空值或截断。小于等于 0 时回退为 `64`;有效范围为 `1` ~ `1048576`
486+
* 默认值:64
487+
* 数据类型:Int
488+
* 引入版本:v3.5.13
489+
483490
### enable_metadata_profile
484491

485492
* 描述:是否为 Iceberg Catalog 的元数据收集查询开启 Profile。

fe/fe-core/src/main/java/com/starrocks/catalog/Type.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
import com.google.common.collect.ImmutableMap;
4040
import com.google.common.collect.ImmutableSortedMap;
4141
import com.google.common.collect.Lists;
42+
import com.starrocks.catalog.PrimitiveType;
4243
import com.starrocks.catalog.combinator.AggStateDesc;
4344
import com.starrocks.common.Pair;
4445
import com.starrocks.mysql.MysqlColType;
4546
import com.starrocks.proto.PScalarType;
4647
import com.starrocks.proto.PTypeDesc;
48+
import com.starrocks.qe.GlobalVariable;
4749
import com.starrocks.sql.analyzer.SemanticException;
4850
import com.starrocks.thrift.TColumnType;
4951
import com.starrocks.thrift.TPrimitiveType;
@@ -1667,7 +1669,8 @@ public int getMysqlResultSetFieldLength() {
16671669
ScalarType charType = ((ScalarType) this);
16681670
int charLength = charType.getLength();
16691671
if (charLength == -1) {
1670-
charLength = 64;
1672+
charLength = (this.getPrimitiveType() == PrimitiveType.CHAR) ? 255
1673+
: GlobalVariable.getMaxUnknownStringMetaLength();
16711674
}
16721675
// utf8 charset
16731676
return charLength * 3;

fe/fe-core/src/main/java/com/starrocks/qe/GlobalVariable.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public final class GlobalVariable {
7777
public static final String ACTIVATE_ALL_ROLES_ON_LOGIN = "activate_all_roles_on_login";
7878
public static final String ACTIVATE_ALL_ROLES_ON_LOGIN_V2 = "activate_all_roles_on_login_v2";
7979
public static final String ENABLE_TDE = "enable_tde";
80+
public static final String MAX_UNKNOWN_STRING_META_LENGTH = "max_unknown_string_meta_length";
81+
8082

8183
@VariableMgr.VarAttr(name = VERSION_COMMENT, flag = VariableMgr.READ_ONLY)
8284
public static String versionComment = Version.STARROCKS_VERSION + "-" + Version.STARROCKS_COMMIT_HASH;
@@ -178,6 +180,9 @@ public final class GlobalVariable {
178180
@VariableMgr.VarAttr(name = ENABLE_TDE, flag = VariableMgr.GLOBAL | VariableMgr.READ_ONLY)
179181
public static boolean enableTde = KeyMgr.isEncrypted();
180182

183+
@VariableMgr.VarAttr(name = MAX_UNKNOWN_STRING_META_LENGTH, flag = VariableMgr.GLOBAL)
184+
private static int maxUnknownStringMetaLength = 64;
185+
181186
public static boolean isEnableQueryQueueSelect() {
182187
return enableQueryQueueSelect;
183188
}
@@ -312,6 +317,13 @@ public static void setActivateAllRolesOnLogin(boolean activateAllRolesOnLogin) {
312317
GlobalVariable.activateAllRolesOnLogin = activateAllRolesOnLogin;
313318
}
314319

320+
public static int getMaxUnknownStringMetaLength() {
321+
if (maxUnknownStringMetaLength <= 0) {
322+
return 64;
323+
}
324+
return maxUnknownStringMetaLength;
325+
}
326+
315327
// Don't allow create instance.
316328
private GlobalVariable() {
317329

0 commit comments

Comments
 (0)