ARRAY_WITH_CONSTANT
Descriptionβ
Generates an array containing n repeated elements
Syntaxβ
ARRAY_WITH_CONSTANT(<n>, <element>)
Parametersβ
Parameter | Description |
---|---|
<n> | Number of digits |
<element> | Specifying Elements |
Return Valueβ
Returns an array containing n repeated elements. array_repeat has the same function as array_with_constant and is used to be compatible with the hive syntax format.
Exampleβ
SELECT ARRAY_WITH_CONSTANT(2, "hello"),ARRAY_WITH_CONSTANT(3, 12345);
+---------------------------------+-------------------------------+
| array_with_constant(2, 'hello') | array_with_constant(3, 12345) |
+---------------------------------+-------------------------------+
| ["hello", "hello"] | [12345, 12345, 12345] |
+---------------------------------+-------------------------------+