How to customize the data docs output for a custom expectation

How can I output a custom message or altair graph instead of the default output in data docs?

1 Like

Here is a guide for customizing the interface of Data Docs:

It explains the basic architecture of the templates and how to replace the default code with your own.

1 Like

Thanks for your answer! It seems super straightforward to add a single custom expectation, but I couldn’t find an easy way of injecting custom visualizations.

So far, I’ve been able to update a couple files in the source ( expectation_string , validation_results_table_content_block ) to generate some custom displays for my own expectations, but ideally we’d have plugins for each new expectation & viz. I suppose I could create a whole custom renderer, but that seems like overkill for my use case.

Is creating a whole new renderer the right/only way forward here?

if so, any advice on a straightforward way to integrate custom expectations into that new renderer? The example at the bottom of the page you linked didn’t seem to have a whole lot in the way of iterating over expectation results

Hi Ryan - thanks for reaching out. You are correct - currently, if you would like to use plugins in that way for custom expectations in Data Docs, you would have to implement a custom ExpectationStringRenderer, as well as a custom ValidationResultsTableContentBlockRenderer and ExpectationSuiteBulletListContentBlockRenderer that inherits the custom ExpectationStringRenderer. You would then specify the custom ValidationResultsTableContentBlockRenderer and ExpectationSuiteBulletListContentBlockRenderer in your great_expectations.yml (also referenced in the docs link above):

    class_name: SiteBuilder
      class_name: TupleFilesystemStoreBackend
      base_directory: uncommitted/data_docs/local_site/
      class_name: DefaultSiteIndexBuilder
          module_name: great_expectations.render.renderer
          class_name: ExpectationSuitePageRenderer
            class_name: ExpectationSuiteColumnSectionRenderer
              module_name: custom_data_docs.renderers.custom_bullet_list_renderer
              class_name: CustomExpectationSuiteBulletListContentBlockRenderer
          module_name: great_expectations.render.renderer
          class_name: ValidationResultsPageRenderer
            class_name: ValidationResultsColumnSectionRenderer
              module_name: custom_data_docs.renderers.custom_table_renderer
              class_name: CustomValidationResultsTableContentBlockRenderer

We realize this is not ideal and are currently in the middle of a big refactor that will make implementing custom expectations (and their Data Docs renderers) much simpler. In the new architecture, expectations are refactored into their own classes, which also encapsulates any rendering logic. This will be released soon in GE 0.13.


Similar to bhcastleton’s original question, is it possible/what would be the best way to add a custom field in the data docs results screen? For example, we wish to add an id field so that we can easily match up troublesome records using their database id.

Like imagine similar to the custom comments/notes feature, but on a record-by-record basis.


Just discovered that one can get full data_docs results including the problematic id fields by tweaking the result_format checkpoint setting:

These then get saved as json files within the folder:

Apologies for digging up an old thread!