contains function (Databricks SQL)

Returns true if expr contains subExpr.

Syntax

contains(expr, subExpr)

Arguments

  • expr: A STRING or BINARY within which to search.

  • subExpr: The STRING or BINARY to search for.

Returns

A BOOLEAN. If expr or subExpr are NULL, the result is NULL. If subExpr is the empty string or empty binary the result is true.

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

Examples

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

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

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

> SELECT contains('SparkSQL', 'ark');
  true

> SELECT contains('SparkSQL', 'SQL');
  true

> SELECT contains('SparkSQL', 'Spork');
  false

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

> SELECT contains(x'120033', x'00');
  true