startswith function

Returns true if expr begins with startExpr.

Since: Databricks Runtime 10.3

Syntax

startswith(expr, startExpr)

Arguments

  • expr: A STRING expression.
  • startExpr: A STRING expression which is compared to the start of str.

Returns

A BOOLEAN.

If expr or startExpr is NULL, the result is NULL.

If startExpr is the empty string or empty binary the result is true.

Since: Databricks Runtime 10.5

The function operates in BINARY mode if both arguments are BINARY.

Examples

> SELECT startswith('SparkSQL', 'Spark');
 true

> SELECT startswith('SparkSQL', 'spark');
 false

> SELECT startswith('SparkSQL', NULL);
 NULL

> SELECT startswith(NULL, 'Spark');
 NULL

> SELECT startswith('SparkSQL', '');
 true

> SELECT startswith(x'110033', x'11');
 true