startswith function (Databricks SQL)

Returns true if expr begins with startExpr.

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.

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