snowflake.snowpark.functions.charindex¶
- snowflake.snowpark.functions.charindex(target_expr: ColumnOrName, source_expr: ColumnOrName, position: Column | int | None = None) Column [source]¶
Searches for
target_expr
insource_expr
and, if successful, returns the position (1-based) of thetarget_expr
insource_expr
.- Parameters:
target_expr – A string or binary expression representing the value to look for.
source_expr – A string or binary expression representing the value to search.
position – A number indication the position (1-based) from where to start the search. Defaults to None.
- Examples::
>>> df = session.create_dataframe(["banana"], schema=['a']) >>> df.select(charindex(lit("an"), df.a, 1).as_("result")).show() ------------ |"RESULT" | ------------ |2 | ------------
>>> df.select(charindex(lit("an"), df.a, 3).as_("result")).show() ------------ |"RESULT" | ------------ |4 | ------------