diff options
author | robot-piglet <[email protected]> | 2025-07-07 15:25:40 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-07-07 15:49:57 +0300 |
commit | 0e4dd8bb5d401ba0cd8bf5751dcf9fd2e054eaef (patch) | |
tree | a5e8089fdd03bdf1e00fa8611e3035cb32d699a7 | |
parent | 7b5e0194f5ddeab1c864112b1716b70b969ac7b2 (diff) |
Intermediate changes
commit_hash:5a3888997f606a4dec72243c6f80a42a8e44021b
-rw-r--r-- | yql/essentials/docs/en/syntax/flatten.md | 14 | ||||
-rw-r--r-- | yql/essentials/docs/ru/syntax/flatten.md | 11 |
2 files changed, 16 insertions, 9 deletions
diff --git a/yql/essentials/docs/en/syntax/flatten.md b/yql/essentials/docs/en/syntax/flatten.md index f6978fa41d0..0dd81ceed4c 100644 --- a/yql/essentials/docs/en/syntax/flatten.md +++ b/yql/essentials/docs/en/syntax/flatten.md @@ -125,21 +125,25 @@ SELECT * FROM ( ## FLATTEN COLUMNS {#flatten-columns} -Converts a table where all columns must be structures to a table with columns corresponding to each element of each structure from the source columns. -The names of the source column structures are not used and not returned in the result. Be sure that the structure element names aren't repeated in the source columns. + +Transforms each column of type `Struct` into individual columns, one for each field within the struct. The names of the new columns are the names of the fields from the original struct columns. Columns that are not structs remain unchanged. + +- Only one level of the struct is flattened. +- The original struct columns are not included in the result; their names are not used anywhere. +- All column names in the resulting table (including names from struct fields in the original columns and names of non-struct columns) must be unique; name conflicts result in an error. #### Example ```yql -SELECT x, y, z +SELECT x, y, z, not_struct FROM ( SELECT AsStruct( 1 AS x, "foo" AS y), AsStruct( - false AS z) + false AS z), + 1 as not_struct, ) FLATTEN COLUMNS; ``` - diff --git a/yql/essentials/docs/ru/syntax/flatten.md b/yql/essentials/docs/ru/syntax/flatten.md index 0c9be54980a..a33e83ed220 100644 --- a/yql/essentials/docs/ru/syntax/flatten.md +++ b/yql/essentials/docs/ru/syntax/flatten.md @@ -119,20 +119,23 @@ SELECT * FROM ( ## FLATTEN COLUMNS {#flatten-columns} -Преобразует таблицу, в которой все столбцы должны являться структурами, в таблицу со столбцами, соответствующими каждому элементу каждой структуры из исходных столбцов. +Преобразует каждый столбец типа `Struct` в набор отдельных столбцов, по одному на каждое поле структуры. Названия новых столбцов являются названиями полей исходных столбцов-структур. Столбцы, не являющиеся структурами, остаются без изменений. -Имена исходных столбцов-структур не используются и не возвращаются в результате. Имена элементов структур не должны повторяться в исходных столбцах. +- Раскрывается только один уровень структуры. +- Исходные столбцы-структуры не возвращаются в результате, их имена никак не используются. +- Все имена столбцов в итоговой таблице (включая имена элементов структур в исходных столбцах и имена столбцов, не являющихся структурами) должны быть уникальными, конфликты имен приводят к ошибке. #### Пример ```yql -SELECT x, y, z +SELECT x, y, z, not_struct FROM ( SELECT AsStruct( 1 AS x, "foo" AS y), AsStruct( - false AS z) + false AS z), + 1 as not_struct, ) FLATTEN COLUMNS; ``` |