SPLIT (Lakehouse v1)
Divide uma string usando um delimitador especificado e retorna as partes resultantes como um array.
Veja também: SPLIT_PART
Sintaxe do Analyze
Seção intitulada “Sintaxe do Analyze”func.split('<input_string>', '<delimiter>')Exemplos do Analyze
Seção intitulada “Exemplos do Analyze”func.split('PlaidCloud Lakehouse', ' ')┌─────────────────────────────────────────┐│ func.split('PlaidCloud Lakehouse', ' ') │├─────────────────────────────────────────┤│ ['PlaidCloud Lakehouse'] │└─────────────────────────────────────────┘Sintaxe SQL
Seção intitulada “Sintaxe SQL”SPLIT('<input_string>', '<delimiter>')Tipo de retorno
Seção intitulada “Tipo de retorno”Array de strings. SPLIT retorna NULL quando a string de entrada ou o delimitador é NULL.
Exemplos de SQL
Seção intitulada “Exemplos de SQL”-- Use a space as the delimiter-- SPLIT returns an array with two parts.SELECT SPLIT('PlaidCloud Lakehouse', ' ');
split('PlaidCloud Lakehouse', ' ')|----------------------------------+['PlaidCloud','Lakehouse'] |
-- Use an empty string as the delimiter or a delimiter that does not exist in the input string-- SPLIT returns an array containing the entire input string as a single part.SELECT SPLIT('PlaidCloud Lakehouse', '');
split('databend cloud', '')|----------------------------------+['PlaidCloud Lakehouse'] |
SELECT SPLIT('PlaidCloud Lakehouse', ',');
split('databend cloud', ',')|----------------------------------+['PlaidCloud Lakehouse'] |
-- Use ' ' (tab) as the delimiter-- SPLIT returns an array with timestamp, log level, and message.
SELECT SPLIT('2023-10-19 15:30:45 INFO Log message goes here', ' ');
split('2023-10-19 15:30:45\tinfo\tlog message goes here', '\t')|---------------------------------------------------------------+['2023-10-19 15:30:45','INFO','Log message goes here'] |