# position¶

## Description¶

Searches for the first occurrence of the second argument (needle) in the first argument (haystack) and, if successful, returns the needle’s position (0-based). Returns -1 if the needle is not found.

int64

## Domain¶

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

## Usage¶

position( haystack, needle [ , start ] )


Argument

Type

Required

Multiple

haystack

string

Required

Only one

needle

string

Required

Only one

start

int64

Optional

Only one

## 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.