array_with_constant

SinceVersion 1.2.0

array_with_constant array_repeat

description

Syntax

  1. ARRAY<T> array_with_constant(n, T)
  2. ARRAY<T> array_repeat(T, n)

返回一个数组, 包含n个重复的T常量。array_repeat与array_with_constant功能相同,用来兼容hive语法格式。

notice

仅支持向量化引擎中使用

example

  1. mysql> set enable_vectorized_engine=true;
  2. mysql> select array_with_constant(2, "hello"), array_repeat("hello", 2);
  3. +---------------------------------+--------------------------+
  4. | array_with_constant(2, 'hello') | array_repeat('hello', 2) |
  5. +---------------------------------+--------------------------+
  6. | ['hello', 'hello'] | ['hello', 'hello'] |
  7. +---------------------------------+--------------------------+
  8. 1 row in set (0.04 sec)
  9. mysql> select array_with_constant(3, 12345), array_repeat(12345, 3);
  10. +-------------------------------+------------------------+
  11. | array_with_constant(3, 12345) | array_repeat(12345, 3) |
  12. +-------------------------------+------------------------+
  13. | [12345, 12345, 12345] | [12345, 12345, 12345] |
  14. +-------------------------------+------------------------+
  15. 1 row in set (0.01 sec)
  16. mysql> select array_with_constant(3, null), array_repeat(null, 3);
  17. +------------------------------+-----------------------+
  18. | array_with_constant(3, NULL) | array_repeat(NULL, 3) |
  19. +------------------------------+-----------------------+
  20. | [NULL, NULL, NULL] | [NULL, NULL, NULL] |
  21. +------------------------------+-----------------------+
  22. 1 row in set (0.01 sec)
  23. mysql> select array_with_constant(null, 3), array_repeat(3, null);
  24. +------------------------------+-----------------------+
  25. | array_with_constant(NULL, 3) | array_repeat(3, NULL) |
  26. +------------------------------+-----------------------+
  27. | [] | [] |
  28. +------------------------------+-----------------------+
  29. 1 row in set (0.01 sec)

keywords

ARRAY,WITH_CONSTANT,ARRAY_WITH_CONSTANT,ARRAY_REPEAT