position

Description

Searches for the first occurrence of the second argument (needle) in the first argument (haystack).

If successful, returns the needle’s position (0-based). Returns -1 if the needle is not found.

Return type

int64

Domain

This is a scalar function (calculates a single output value for a single input row.)

Categories

Usage

position(haystack, needle, [ start ])

Argument

Type

Optional

Repeatable

Restrictions

haystack

string

no

no

none

needle

string

no

no

none

start

int64

yes

no

none

Examples

make_col p:position('fuzzy wuzzy', 'uzzy', 5)

Looks for the first occurrence of the needle ‘uzzy’ starting at index 5 (0-based) in the haystack ‘fuzzy wuzzy’. Returns 7.