btrim function

Returns str with leading and trailing characters removed.

Since: Databricks Runtime 10.0

Syntax

btrim( str [, trimStr ] )

Arguments

  • str: A STRING expression to be trimmed.

  • trimStr: An optional STRING expression with characters to be trimmed. The default is a space character.

Returns

A STRING.

The function removes any leading and trailing characters within trimStr from str.

Examples

> SELECT 'X' || btrim('    SparkSQL   ') || 'X';
 XSparkSQLX

> SELECT btrim('abcaabaSparkSQLabcaaba', 'abc');
 SparkSQL