contains
function
Applies to: Databricks SQL Databricks Runtime 10.4 LTS and above
Returns true
if expr
contains 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
.
Applies to: Databricks SQL Databricks Runtime 11.3 LTS and above
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