Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/sql-reference/System_variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,7 @@ Used to specify the SQL mode to accommodate certain SQL dialects. Valid values i
* `SORT_NULLS_LAST`: places NULL values at the end after sorting.
* `ERROR_IF_OVERFLOW`: returns an error instead of NULL in the case of arithmetic overflow. Currently, only the DECIMAL data type supports this option.
* `GROUP_CONCAT_LEGACY`: uses the `group_concat` syntax of v2.5 and earlier. This option is supported from v3.0.9 and v3.1.6.
* `STRUCT_CAST_BY_NAME`: enables name-based field matching when casting between STRUCT types, rather than the default position-based matching. When this mode is enabled, fields in the source struct are matched to fields in the target struct by field name (case-insensitively), regardless of the order in which they are declared. Fields present in the source but absent in the target are ignored; fields present in the target but absent in the source are filled with NULL. This mode affects both the FE type resolution (common supertype computation for UNION ALL and castability checks) and the BE cast evaluation (runtime field reordering in CastStructExpr). This is particularly useful when performing UNION ALL on STRUCT columns whose fields are defined in different orders across branches.

You can set only one SQL mode, for example:

Expand Down
1 change: 1 addition & 0 deletions docs/ja/sql-reference/System_variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ JDBC 接続プール C3P0 との互換性のために使用されます。実際
* `SORT_NULLS_LAST`: ソート後に NULL 値を最後に配置します。
* `ERROR_IF_OVERFLOW`: 算術オーバーフローが発生した場合に NULL の代わりにエラーを返します。現在、このオプションは DECIMAL データ型にのみ対応しています。
* `GROUP_CONCAT_LEGACY`: v2.5 およびそれ以前の `group_concat` 構文を使用します。このオプションは v3.0.9 および v3.1.6 からサポートされています。
* `STRUCT_CAST_BY_NAME`: STRUCT 型間のキャストにおいて、デフォルトの位置ベースのマッチングではなく、名前ベースのフィールドマッチングを有効にします。このモードが有効になっている場合、ソース構造体のフィールドは、宣言順序に関係なく、フィールド名(大文字小文字を区別しない)に基づいてターゲット構造体のフィールドと照合されます。ソース側には存在するがターゲット側には存在しないフィールドは無視され、ターゲット側には存在するがソース側には存在しないフィールドは NULL で埋められます。このモードは、FE型の解決(UNION ALL における共通のスーパータイプの計算やキャスト可能性のチェック)と、BEキャストの評価(CastStructExpr における実行時のフィールドの順序変更)の両方に影響します。これは、分岐間でフィールドの定義順序が異なるSTRUCT列に対して UNION ALL を実行する場合に特に有用です。

1 つの SQL モードのみを設定できます。例:

Expand Down
1 change: 1 addition & 0 deletions docs/zh/sql-reference/System_variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,7 @@ ALTER USER 'jack' SET PROPERTIES ('session.query_timeout' = '600');
* `SORT_NULLS_LAST`:排序后,将 NULL 值放到最后。
* `ERROR_IF_OVERFLOW`:运算溢出时,报错而不是返回 NULL,目前仅 DECIMAL 支持这一行为。
* `GROUP_CONCAT_LEGACY`:使用 2.5 及以前的 `group_concat` 的语法。该选项从 3.0.9,3.1.6 开始支持。
* `STRUCT_CAST_BY_NAME`:在 STRUCT 类型之间进行类型转换时,启用基于名称的字段匹配,而非默认的基于位置的匹配。启用此模式后,源 Struct 中的字段将根据字段名称(不区分大小写)与目标 Struct 中的字段进行匹配,无论它们的声明顺序如何。源 Struct 中存在而目标 Struct 中缺失的字段将被忽略;目标 Struct 中存在而源 Struct 中缺失的字段将被填充为 NULL。此模式同时影响 FE 类型解析(UNION ALL 的通用超类型计算和可转换性检查)以及 BE 转换评估(CastStructExpr 中的运行时字段重新排序)。当对 STRUCT 列执行 UNION ALL 操作时,若各分支中字段的定义顺序不同,此模式尤为有用。

不同模式之间可以独立设置,您可以单独开启某一个模式,例如:

Expand Down
Loading