raise_error
Throws an exception with the provided error message.
Syntax
Python
from pyspark.sql import functions as sf
sf.raise_error(errMsg)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| 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
Python
from pyspark.sql import functions as sf
spark.range(1).select(sf.raise_error("My error message")).show()
Output
java.lang.RuntimeException: My error message