Skip to content

Commit 0e4dd8b

Browse files
committed
Intermediate changes
commit_hash:5a3888997f606a4dec72243c6f80a42a8e44021b
1 parent 7b5e019 commit 0e4dd8b

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

yql/essentials/docs/en/syntax/flatten.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,25 @@ SELECT * FROM (
125125

126126
## FLATTEN COLUMNS {#flatten-columns}
127127

128-
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.
129128

130-
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.
129+
130+
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.
131+
132+
- Only one level of the struct is flattened.
133+
- The original struct columns are not included in the result; their names are not used anywhere.
134+
- 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.
131135

132136
#### Example
133137

134138
```yql
135-
SELECT x, y, z
139+
SELECT x, y, z, not_struct
136140
FROM (
137141
SELECT
138142
AsStruct(
139143
1 AS x,
140144
"foo" AS y),
141145
AsStruct(
142-
false AS z)
146+
false AS z),
147+
1 as not_struct,
143148
) FLATTEN COLUMNS;
144149
```
145-

yql/essentials/docs/ru/syntax/flatten.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,23 @@ SELECT * FROM (
119119

120120
## FLATTEN COLUMNS {#flatten-columns}
121121

122-
Преобразует таблицу, в которой все столбцы должны являться структурами, в таблицу со столбцами, соответствующими каждому элементу каждой структуры из исходных столбцов.
122+
Преобразует каждый столбец типа `Struct` в набор отдельных столбцов, по одному на каждое поле структуры. Названия новых столбцов являются названиями полей исходных столбцов-структур. Столбцы, не являющиеся структурами, остаются без изменений.
123123

124-
Имена исходных столбцов-структур не используются и не возвращаются в результате. Имена элементов структур не должны повторяться в исходных столбцах.
124+
- Раскрывается только один уровень структуры.
125+
- Исходные столбцы-структуры не возвращаются в результате, их имена никак не используются.
126+
- Все имена столбцов в итоговой таблице (включая имена элементов структур в исходных столбцах и имена столбцов, не являющихся структурами) должны быть уникальными, конфликты имен приводят к ошибке.
125127

126128
#### Пример
127129

128130
```yql
129-
SELECT x, y, z
131+
SELECT x, y, z, not_struct
130132
FROM (
131133
SELECT
132134
AsStruct(
133135
1 AS x,
134136
"foo" AS y),
135137
AsStruct(
136-
false AS z)
138+
false AS z),
139+
1 as not_struct,
137140
) FLATTEN COLUMNS;
138141
```

0 commit comments

Comments
 (0)