struct()
SinceVersion 2.0.0
struct()
description
Syntax
STRUCT<T1, T2, T3, ...> struct(T1, T2, T3, ...)
construct an struct with variadic elements and return it, Tn could be column or literal
notice
Only supported in vectorized engine
example
1. mysql> select struct(1, 'a', "abc");
2. +-----------------------+
3. | struct(1, 'a', 'abc') |
4. +-----------------------+
5. | {1, 'a', 'abc'} |
6. +-----------------------+
7. 1 row in set (0.03 sec)
9. mysql> select struct(null, 1, null);
10. +-----------------------+
11. | struct(NULL, 1, NULL) |
12. +-----------------------+
13. | {NULL, 1, NULL} |
14. +-----------------------+
15. 1 row in set (0.02 sec)
17. mysql> select struct(cast('2023-03-16' as datetime));
18. +----------------------------------------+
19. | struct(CAST('2023-03-16' AS DATETIME)) |
20. +----------------------------------------+
21. | {2023-03-16 00:00:00} |
22. +----------------------------------------+
23. 1 row in set (0.01 sec)
25. mysql> select struct(k1, k2, null) from test_tb;
26. +--------------------------+
27. | struct(`k1`, `k2`, NULL) |
28. +--------------------------+
29. | {1, 'a', NULL} |
30. +--------------------------+
31. 1 row in set (0.04 sec)
keywords
STRUCT,CONSTRUCTOR
