Chispa is a PySpark test helper library that provides fast and descriptive methods for comparing Spark DataFrames. It's designed to make writing high-quality PySpark unit tests easier by offering clear error messages when assertions fail. The library is currently at version 0.12.0 and is actively maintained with regular releases.
pip install chispaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `chispa.dataframe_comparer.assert_df_equality` to compare two PySpark DataFrames. It initializes a SparkSession, creates two DataFrames (one identical, one with a subtle difference), and then uses `assert_df_equality` to check their equivalence, showcasing both a passing and a failing scenario with Chispa's descriptive error messages.
Upgrade chispa to 0.12.0 or a later version: `pip install --upgrade chispa`
Remove any direct imports of `chispa.bcolors`. If custom console coloring is needed, use a dedicated library or Python's `colorama`.
Review the specific comparison requirements. Use `ignore_nullable=True`, `ignore_metadata=True`, `ignore_column_order=True`, or `ignore_row_order=True` as appropriate for your test case. For floating-point comparisons, consider `assert_approx_df_equality` or the `precision` argument.
Upgrade chispa to version 0.11.1 or newer to ensure correct behavior when combining `ignore_columns` and `ignore_row_order`.