CONTAINS_SEQUENCE()

All functions > ARRAY > CONTAINS_SEQUENCE()

Returns TRUE if the array contains the specified sequence as a contiguous subsequence.

Signatures

Returns: TRUE if sequence appears contiguously in array, FALSE otherwise

CONTAINS_SEQUENCE(array: ARRAY<T>, sequence: ARRAY<T>) → BOOLEAN
sql
ParameterTypeRequiredDescription
arrayARRAY<T>YesThe array to search within
sequenceARRAY<T>YesThe contiguous sequence to find

Notes

  • Checks for contiguous subsequence match
  • Elements must appear in order without gaps
  • Returns FALSE if sequence is not found
  • Empty sequence argument yields NULL (not TRUE)
  • Uses element equality comparison

See also

Examples

FeatureQL
SELECT
    -- Contiguous numeric subsequence
    f1 := CONTAINS_SEQUENCE(ARRAY(1, 2, 3, 4), ARRAY(2, 3)),
    -- Contiguous string subsequence
    f2 := CONTAINS_SEQUENCE(ARRAY('a', 'b', 'c'), ARRAY('b', 'c')),
    -- Wrong order is not a match
    f3 := CONTAINS_SEQUENCE(ARRAY(1, 2, 3), ARRAY(3, 2)),
    -- Empty sequence argument
    f4 := CONTAINS_SEQUENCE(ARRAY(1, 2, 3), ARRAY()::BIGINT[])
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEANf4 BOOLEAN
truetruefalsenull

Last update at: 2026/06/20 10:08:10