From the course: Data Quality Testing with Great Expectations
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Creating custom Expectations - Great Expectations Tutorial
From the course: Data Quality Testing with Great Expectations
Creating custom Expectations
So far, we've only used the built-in expectations that ship with GX, but sometimes we need domain-specific rules that go beyond those defaults. Let's take a look at how we can create custom expectations in GX. In the New York City taxi data, for example, we have both pickup and drop-off timestamps. A simple and common check would be to assert that the pickup happens before the drop-off. That makes intuitive sense, but it's a multi-column rule on those two columns, and there isn't a built-in expectation that handles it cleanly. For this case, Gx has an expectation type called unexpected rows expectation. This lets us define a custom SQL query that returns rows which violate specific assertions. If the query returns any rows, the expectation fails. OK, let's try this out and create a custom expectation that fails when the pickup time is after the drop-off time. First of all, we can write the SQL query just as a string in Python. See that batch in the curly brackets? That's a wild card…
Contents
-
-
-
-
-
(Locked)
Triggering actions with checkpoints2m 55s
-
(Locked)
Understanding data test failures2m 32s
-
Root cause analysis of test failures3m 34s
-
(Locked)
Approaches to debugging and fixing data quality issues2m 42s
-
(Locked)
Creating fuzzy expectations2m 12s
-
(Locked)
Updating and deleting Expectations in an Expectation Suite2m 29s
-
(Locked)
Creating custom Expectations3m 24s
-
(Locked)
Monitoring ongoing data quality2m 24s
-
(Locked)
-
-