SPRKPY1023
pyspark.sql.functions.log1p
Message: pyspark.sql.functions.log1p has a workaround, see documentation for more info
Category: Warning
Description
This issue appears when the SMA detects a use of the pyspark.sql.functions.log1p function, which has a workaround.
Scenario
Input
Below is an example of a use of the pyspark.sql.functions.log1p
function that generates this EWI. In this example, the log1p
function is used to calculate the natural logarithm of the value column.
df = spark.createDataFrame([(0,), (1,), (10,), (100,)], ["value"])
df_with_log1p = df.withColumn("log1p_value", log1p(df["value"]))
Output
The SMA adds the EWI SPRKPY1023
to the output code to let you know that this function is not directly supported by Snowpark, but it has a workaround.
df = spark.createDataFrame([(0,), (1,), (10,), (100,)], ["value"])
#EWI: SPRKPY1023 => pyspark.sql.functions.log1p has a workaround, see documentation for more info
df_with_log1p = df.withColumn("log1p_value", log1p(df["value"]))
Recommended fix
As a workaround, you can use the call_function function by passing the string ln
as the first argument and by adding 1
to the second argument.
df = spark.createDataFrame([(0,), (1,), (10,), (100,)], ["value"])
df_with_log1p = df.withColumn("log1p_value", call_function("ln", lit(1) + df["value"]))
Additional recommendations
For more support, you can email us at sma-support@snowflake.com or post an issue in the SMA.
Last updated