You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But when I'm adapting it with pandera.pyspark I have an error.
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandera.
(optional) I have confirmed this bug exists on the main branch of pandera.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
fromtypingimportUnionimportpandera.pysparkaspafrompandera.typing.pyspark_sqlimportDataFramefrompyspark.sqlimportRow, SparkSessionfrompyspark.sql.typesimportIntegerTypespark=SparkSession.builder.master("local").appName("test").getOrCreate()
classOnlyZeroesSchema(pa.DataFrameModel):
a: IntegerType=pa.Field(eq=0)
classOnlyOnesSchema(pa.DataFrameModel):
a: IntegerType=pa.Field(eq=1)
@pa.check_typesdefreturn_zeros_or_ones(
df: Union[DataFrame[OnlyZeroesSchema], DataFrame[OnlyOnesSchema]]
) ->Union[DataFrame[OnlyZeroesSchema], DataFrame[OnlyOnesSchema]]:
returndfdefcreate_df(spark: SparkSession, val: int):
rows= [Row(a=val), Row(a=val)]
df=spark.createDataFrame(rows)
returndfdf_0=create_df(spark, 0)
# fails but it should passreturn_zeros_or_ones(df_0)
df_1=create_df(spark, 1)
# fails but it should passreturn_zeros_or_ones(df_1)
The error is
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "/Users/BENOIT/aifforecastsupply_ml_drift_demand_pyspark/.venv/lib/python3.9/site-packages/pandera/decorators.py", line 853, in _wrapper
validated_pos, validated_kwd = validate_inputs(
File "/Users/BENOIT/aifforecastsupply_ml_drift_demand_pyspark/.venv/lib/python3.9/site-packages/pandera/decorators.py", line 811, in validate_inputs
validated_pos = validate_args(sig.bind_partial(*args).arguments, args)
File "/Users/BENOIT/aifforecastsupply_ml_drift_demand_pyspark/.venv/lib/python3.9/site-packages/pandera/decorators.py", line 757, in validate_args
return list(
File "/Users/BENOIT/aifforecastsupply_ml_drift_demand_pyspark/.venv/lib/python3.9/site-packages/pandera/decorators.py", line 758, in <genexpr>
_check_arg(arg_name, arg_value)
File "/Users/BENOIT/aifforecastsupply_ml_drift_demand_pyspark/.venv/lib/python3.9/site-packages/pandera/decorators.py", line 711, in _check_arg
raise errors.SchemaErrors(
pandera.errors.SchemaErrors: <exception str() failed>
Describe the bug
I started from this documentation example : https://pandera.readthedocs.io/en/stable/dataframe_models.html#validate-against-multiple-schemas which works in my env.
But when I'm adapting it with pandera.pyspark I have an error.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
The error is
Expected behavior
The expected behaviour should be same as in the doc : https://pandera.readthedocs.io/en/stable/dataframe_models.html#validate-against-multiple-schemas
The error should not happen
Desktop (please complete the following information):
pyspark
(pandera[pyspark]==0.20.4)The text was updated successfully, but these errors were encountered: