TRIM (Lakehouse v1)
Retorna a string sem ocorrências iniciais ou finais da string de remoção especificada. Se a string de remoção for omitida, os espaços são removidos.
A função do Analyze remove automaticamente os espaços iniciais e finais.
Sintaxe do Analyze
Seção intitulada “Sintaxe do Analyze”func.trim(str)Exemplos do Analyze
Seção intitulada “Exemplos do Analyze”func.trim(' plaidcloud ')┌────────────────────────────────┐│ func.trim(' plaidcloud ') │├────────────────────────────────┤│ 'plaidcloud' │└────────────────────────────────┘Sintaxe SQL
Seção intitulada “Sintaxe SQL”TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM ] str)Exemplos de SQL
Seção intitulada “Exemplos de SQL”Observação: TODOS os exemplos desta seção retornam a string ‘databend’.
O exemplo a seguir remove a string ‘xxx’ do início e do final da string ‘xxxdatabendxxx’:
SELECT TRIM(BOTH 'xxx' FROM 'xxxdatabendxxx');O exemplo a seguir remove a string ‘xxx’ do início da string ‘xxxdatabend’:
SELECT TRIM(LEADING 'xxx' FROM 'xxxdatabend' );O exemplo a seguir remove a string ‘xxx’ do final da string ‘databendxxx’:
SELECT TRIM(TRAILING 'xxx' FROM 'databendxxx' );Se nenhuma string de remoção for especificada, a função remove todos os espaços iniciais e finais. Os exemplos a seguir removem os espaços iniciais e/ou finais:
SELECT TRIM(' databend ');SELECT TRIM(' databend');SELECT TRIM('databend ');