Skip to main content
Version: 0.14.13

How to add comments to Expectations and display them in Data Docs

This guide will help you add descriptive comments (or notes, here used interchangeably) to ExpectationsA verifiable assertion about data. and display those comments in Data DocsHuman readable documentation generated from Great Expectations metadata detailing Expectations, Validation Results, etc.. In these comments you can add some clarification or motivation to the Expectation definition to help you communicate more clearly with your team about specific Expectations. Markdown is supported in these comments.

Prerequisites: This how-to guide assumes you have:

Steps

1. First, edit your Expectation Suite

great_expectations suite edit <your_suite_name>

2. Next, add comments to specific Expectations

For each Expectation you wish to add notes to, add a dictionary to the meta field with the key notes and your comment as the value. Here is an example.

validator.expect_table_row_count_to_be_between(
max_value=1000000, min_value=1,
meta={"notes": "Example notes about this expectation."}
)

Leads to the following representation in the Data DocsHuman readable documentation generated from Great Expectations metadata detailing Expectations, Validation Results, etc. (For Expectation SuiteA collection of verifiable assertions about data. pages, click on the speech bubble to view the comment).

Expectation with simple comment, no formatting

3. Add styling to your comments (optional)

To add styling to your comments, you can add a format tag. Here are a few examples.

A single line of markdown is rendered in red, with any Markdown formatting applied.

validator.expect_column_values_to_not_be_null(
column="column_name",
meta={
"notes": {
"format": "markdown",
"content": "Example notes about this expectation. **Markdown** `Supported`."
}
}
)

Expectation with a single line of markdown comment is rendered in red with markdown formatting

Multiple lines can be rendered by using a list for content; these lines are rendered in black text with any Markdown formatting applied.

validator.expect_column_values_to_not_be_null(
column="column_name",
meta={
"notes": {
"format": "markdown",
"content": [
"Example notes about this expectation. **Markdown** `Supported`.",
"Second example note **with** *Markdown*",
]
}
}
)

Multiple lines of markdown rendered with formatting

You can also change the format to string and single or multiple lines will be formatted similar to the above, but the Markdown formatting will not be applied.

validator.expect_column_values_to_not_be_null(
column="column_name",
meta={
"notes": {
"format": "string",
"content": [
"Example notes about this expectation. **Markdown** `Not Supported`.",
"Second example note **without** *Markdown*",
]
}
}
)

Multiple lines of string rendered without formatting

4. Review your comments in the Expectation Suite overview of your Data Docs

You can open your Data Docs by using the .open_data_docs() method of your Data Context, which should be present in the last cell of the Jupyter Notebook you did your editing in.