Validates that the values in a numeric column fall within a specified range.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Examples:
>>> from pyspark.sql import SparkSession
>>> from pyspark.sql.types import StructType, StructField, IntegerType
>>> spark = SparkSession.builder.getOrCreate()
>>> schema = StructType([
... StructField("id", IntegerType(), True),
... StructField("score", IntegerType(), True)
... ])
>>> data = [(1, 10), (2, 15), (3, 25), (4, 5)]
>>> df = spark.createDataFrame(data, schema)
>>> try:
... range_test(df, "score", 0, 20)
... except ValueError as e:
... print(e)
False
Logs:
-
INFO: Invalid values found in column
columns:value -
INFO: Data Quality Check: Successfully processed range test.