snowflake.snowpark.functions.charindex¶
- snowflake.snowpark.functions.charindex(target_expr: Union[Column, str], source_expr: Union[Column, str], position: Optional[Union[Column, int]] = None) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L3273-L3314)¶
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 | ------------