startswith function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 10.3 and above

Returns true if expr begins with startExpr.

Syntax

startswith(expr, startExpr)

Arguments

  • expr: A STRING expression.

  • startExpr: A STRING expression that 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.

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 10.5 and above

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