Kopīgot, izmantojot


raise_error

Throws an exception with the provided error message.

Syntax

from pyspark.sql import functions as sf

sf.raise_error(errMsg)

Parameters

Parameter Type Description
errMsg pyspark.sql.Column or str A Python string literal or column containing the error message.

Returns

pyspark.sql.Column: throws an error with specified message.

Examples

Example 1: Raise a custom error message

from pyspark.sql import functions as sf
spark.range(1).select(sf.raise_error("My error message")).show()
java.lang.RuntimeException: My error message