snowflake.snowpark.functions.compress¶
- snowflake.snowpark.functions.compress(input_val: Union[snowflake.snowpark.column.Column, str], method: Union[snowflake.snowpark.column.Column, str]) Column[source]¶
Compresses the input string using the specified compression method.
- Parameters:
input_val (ColumnOrName) – The input string to be compressed.
method (ColumnOrName) – The compression method (e.g., “SNAPPY”).
- Returns:
The compressed binary data.
- Return type:
- Example::
>>> df = session.create_dataframe([['Snowflake'], ['Hello World']], schema=["input"]) >>> df.select(compress(df["input"], lit("SNAPPY")).alias("compressed")).collect() [Row(COMPRESSED=bytearray(b'\t Snowflake')), Row(COMPRESSED=bytearray(b'\x0b(Hello World'))]