MrPowers / chispa

PySpark test helper methods with beautiful error messages
https://mrpowers.github.io/chispa/
MIT License
595 stars 65 forks source link

Give user control to customize output formatting #75

Open MrPowers opened 1 year ago

MrPowers commented 1 year ago

As noted in this pull request (https://github.com/MrPowers/chispa/pull/68), we want to give the user the ability to control the formatting of the output.

The formatting should be easy to configure for a given test and also easy to set globally for the entire test suite.

Here are the main concepts we want to model:

The formatting should let the user configure color, underline, and bold.

These settings should be globally applicable to all the interfaces in the project including schema comparisons, DataFrame comparisons, StructField comparisons, and column comparisons.

Something like this could work:

{
  "mismatched_rows": ["red", "bold"],
  "matched_rows": "blue",
  "mismatched_cells": ["white", "underline"],
  "print_dif": True,
  "print_mismatched_cols": True
}

The user should be able to set this globally and then override for a given test (they should be able to partially override).

The user should also be able to ignore this entirely and just rely on the built-in defaults.

Hopefully we can make the outputs look good on both Mac and Windows machines.

MrPowers commented 7 months ago

Let's start with this:

{
  "mismatched_rows": ["red", "bold"],
  "matched_rows": "blue",
  "mismatched_cells": ["white", "underline"],
  "matched_cells": ["blue", "bold"]
}

We will need to document the supported colors and font styles.

asears commented 6 months ago

Hi there,

Is there any way to turn formats off or adjust for Databricks? In Databricks we see ANSI character codes in the output instead of nicely colored results.