DEV Community

Michael
Michael

Posted on • Originally published at gbase8.cn

GBase 8a unnest Function: The Reverse of group_concat

GBase 8a provides group_concat to aggregate multiple rows into a single comma‑separated string. Its counterpart, unnest, does the opposite — it splits a delimited string into multiple rows. This is particularly useful for data normalisation and log parsing in a gbase database.

Test Environment

Version: 9.5.3.28.14.patch1

gbase> select * from tt;
+---------+
| v       |
+---------+
| 1,2,3,4 |
| a,b,c   |
+---------+
2 rows in set
Enter fullscreen mode Exit fullscreen mode

How unnest Works

unnest takes a single argument, which must be a comma‑separated string. If your data uses a different delimiter, use replace to convert it to commas first.

-- Splitting rows from a table
gbase> select unnest(v) f1 from tt;
+------+
| f1   |
+------+
| 1    |
| 2    |
| 3    |
| 4    |
| a    |
| b    |
| c    |
+------+
7 rows in set

-- Splitting a literal string
gbase> select unnest('1,2,3,4,5,6,7,8');
+---------------------------+
| unnest('1,2,3,4,5,6,7,8') |
+---------------------------+
| 1                         |
| 2                         |
| 3                         |
| 4                         |
| 5                         |
| 6                         |
| 7                         |
| 8                         |
+---------------------------+
8 rows in set
Enter fullscreen mode Exit fullscreen mode

With unnest, GBASE's GBase 8a makes it easy to pivot between denormalised strings and normalised rows, complementing group_concat for a complete data transformation toolkit.

Top comments (0)