snowflake.snowpark.functions.substr

snowflake.snowpark.functions.substr(str: Union[Column, str], pos: Union[Column, int], len: Union[Column, int]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L2580-L2604)

Returns the portion of the string or binary value str, starting from the character/byte specified by pos, with limited length. The length should be greater than or equal to zero. If the length is a negative number, the function returns an empty string.

Note

For pos, 1 is the first character of the string in Snowflake database.

substr() is an alias of substring().

Example::
>>> df = session.create_dataframe(
...     ["abc", "def"],
...     schema=["S"],
... ).select(substring(col("S"), 1, 1))
>>> df.collect()
[Row(SUBSTRING("S", 1, 1)='a'), Row(SUBSTRING("S", 1, 1)='d')]
Copy
语言: 中文