PageSourceSearch

https://docs.greatexpectations.io/assets/js/4cf8feea.84376a6d.js

js greatexpectations.io collected 2026-10-02 02:26:26 UTC 10,177 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[991],{28453(e,r,t){t.d(r,{R:()=>o,x:()=>c});var i=t(96540);const n={},s=i.createContext(n);function o(e){const r=i.useContext(s);return i.useMemo(function(){return"function"==typeof e?e(r):{...r,...e}},[r,e])}function c(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(n):e.components||n:o(e.components),i.createElement(s.Provider,{value:r},e.children)}},89919(e,r,t){t.r(r),t.d(r,{assets:()=>a,contentTitle:()=>c,default:()=>h,frontMatter:()=>o,metadata:()=>i,toc:()=>d});const i=JSON.parse('{"id":"reference/learn/conceptual_guides/metricproviders","title":"MetricProviders","description":"Learn how MetricProviders are an integral component of the Expectation software development kit (SDK).","source":"@site/versioned_docs/version-0.18/reference/learn/conceptual_guides/metricproviders.md","sourceDirName":"reference/learn/conceptual_guides","slug":"/reference/learn/conceptual_guides/metricproviders","permalink":"/docs/0.18/reference/learn/conceptual_guides/metricproviders","draft":false,"unlisted":false,"tags":[],"version":"0.18","frontMatter":{"sidebar_label":"MetricProviders","title":"MetricProviders","id":"metricproviders","description":"Learn how MetricProviders are an integral component of the Expectation software development kit (SDK)."},"sidebar":"learn","previous":{"title":"Expectation classes","permalink":"/docs/0.18/reference/learn/conceptual_guides/expectation_classes"},"next":{"title":"Usage statistics","permalink":"/docs/0.18/reference/learn/usage_statistics"}}');var n=t(74848),s=t(28453);const o={sidebar_label:"MetricProviders",title:"MetricProviders",id:"metricproviders",description:"Learn how MetricProviders are an integral component of the Expectation software development kit (SDK)."},c=void 0,a={},d=[{value:"Assumed knowledge",id:"assumed-knowledge",level:2},{value:"Class hierarchy",id:"class-hierarchy",level:2},{value:"Define Metrics with a MetricProvider",id:"define-metrics-with-a-metricprovider",level:2}];function l(e){const r={a:"a",admonition:"admonition",code:"code",h2:"h2",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(r.p,{children:["MetricProviders generate and register Metrics to support Expectations, and they are an important part of the Expectation software development kit (SDK). Typically, MetricProviders are used to resolve complex requirements and are not implemented widely. If you're considering using MetricProviders, you're encouraged to join the ",(0,n.jsx)(r.a,{href:"https://greatexpectations.io/slack",children:"Great Expectations Slack community"})," and discuss your requirements in the ",(0,n.jsx)(r.a,{href:"https://greatexpectationstalk.slack.com/archives/CUTCNHN82",children:"#gx-community-support"})," channel."]}),"\n",(0,n.jsx)(r.p,{children:"You'll encounter references to MetricProviders in many of the topics in the Great Expectations (GX) documentation. An in-depth knowledge of MetricProvider functionality is helpful, but not required to successfully complete the tasks documented in these topics. However, some knowledge of MetricProvider functionality is useful if you're developing Custom Expectations, or you're maintaining or extending MetricProvider classes."}),"\n",(0,n.jsx)(r.p,{children:"MetricProviders let you declare all the Metrics that are needed to support an Expectation in concise, Don't Repeat Yourself (DRY) syntax. MetricProviders support the following use cases:"}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:"Conceptually grouping code for Metrics calculation across multiple backends."}),"\n",(0,n.jsx)(r.li,{children:"Incremental development. You can develop Metrics for each Execution Engine, one at a time."}),"\n",(0,n.jsx)(r.li,{children:"Sharing Metrics across Expectations."}),"\n",(0,n.jsx)(r.li,{children:"Generating Metrics that can be inferred from specific types of Expectation automatically."}),"\n"]}),"\n",(0,n.jsx)(r.h2,{id:"assumed-knowledge",children:"Assumed knowledge"}),"\n",(0,n.jsx)(r.p,{children:"To get the most out of the information provided here, you should have an understanding of:"}),"\n",(0,n.jsxs)(r.ul,{children:["\n",(0,n.jsx)(r.li,{children:"Expectations"}),"\n",(0,n.jsx)(r.li,{children:"Metrics"}),"\n",(0,n.jsx)(r.li,{children:"The Metric registry"}),"\n",(0,n.jsx)(r.li,{children:"ExecutionEngines"}),"\n"]}),"\n",(0,n.jsx)(r.h2,{id:"class-hierarchy",children:"Class hierarchy"}),"\n",(0,n.jsx)(r.p,{children:"Although the class hierarchy for MetricProviders and Expectations is different, they use the same naming conventions. The following is the MetricProviders class hierarchy:"}),"\n",(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-text",metastring:'title="MetricProvider class hierarchy"',children:"MetricProvider\n    QueryMetricProvider\n    TableMetricProvider\n        ColumnAggregateExpectation\n    MapMetricProvider\n        ColumnMapMetricProvider\n            RegexColumnMapMetricProvider\n            SetColumnMapMetricProvide\n        ColumnPairMapMetricProvider\n        MulticolumnMapExpectation\n        MulticolumnMapMetricProvider\n"})}),"\n",(0,n.jsx)(r.p,{children:"If you\u2019re not sure which MetricProvider you should use with an Expectation, you can usually infer the correct MetricProvider class name from the Expectation class name. For example:"}),"\n",(0,n.jsxs)(r.table,{children:[(0,n.jsx)(r.thead,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.th,{children:"Expectation class"}),(0,n.jsx)(r.th,{children:"MetricProvider class"})]})}),(0,n.jsxs)(r.tbody,{children:[(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"Expectation"}),(0,n.jsx)(r.td,{children:"MetricProvider"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"BatchExpectation"}),(0,n.jsx)(r.td,{children:"TableMetricProvider"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"ColumnAggregateExpectation"}),(0,n.jsx)(r.td,{children:"ColumnAggregateMetricProvider"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"ColumnMapExpectation"}),(0,n.jsx)(r.td,{children:"ColumnMapMetricProvider"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"RegexBasedColumnMapExpectation"}),(0,n.jsx)(r.td,{children:"RegexColumnMapMetricProvider (built in)"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"SetBasedColumnMapExpectation"}),(0,n.jsx)(r.td,{children:"SetColumnMapMetricProvider (built in)"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"ColumnPairMapExpectation"}),(0,n.jsx)(r.td,{children:"ColumnPairMapMetricProvider"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"MulticolumnMapExpectation"}),(0,n.jsx)(r.td,{children:"MulticolumnMapMetricProvider"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"QueryExpectation"}),(0,n.jsx)(r.td,{children:"QueryMetricProvider"})]})]})]}),"\n",(0,n.jsx)(r.p,{children:"Sometimes, the MetricProvider class is created directly from the Expectation class, so you don\u2019t need to specify a MetricProvider or methods when declaring a new Expectation. For example, the RegexBasedColumnMapExpectation automatically implements the RegexColumnMapMetricProvider, and the SetBasedColumnMapExpectation automatically implements the SetColumnMapMetricProvider."}),"\n",(0,n.jsx)(r.h2,{id:"define-metrics-with-a-metricprovider",children:"Define Metrics with a MetricProvider"}),"\n",(0,n.jsxs)(r.p,{children:["The API for MetricProvider classes is unusual. MetricProvider classes are never intended to be instantiated, and they don\u2019t have inputs or outputs in the normal sense of method arguments and return values. Instead, the inputs for MetricProvider classes are methods for calculating the Metric on different backend applications. Each method must be decorated with an appropriate decorator. On ",(0,n.jsx)(r.code,{children:"new"}),", the MetricProvider class registers the decorated methods as part of the Metrics registry so that they can be invoked to calculate Metrics. The registered methods are the only output from MetricProviders."]}),"\n",(0,n.jsx)(r.admonition,{title:"Note",type:"note",children:(0,n.jsxs)(r.p,{children:["Decorators invoked on ",(0,n.jsx)(r.code,{children:"new"})," can make maintainability challenging. GX intends to address this shortcoming in future releases."]})}),"\n",(0,n.jsx)(r.p,{children:"A typical MetricProvider class has three methods that correspond to the three primary ExecutionEngines used by GX (pandas, SQL, and SparkDF). Each of the three methods are marked with an appropriate decorator."}),"\n",(0,n.jsxs)(r.p,{children:["Each MetricProvider class supports different decorators. Every MetricProvider class can use ",(0,n.jsx)(r.code,{children:"@metric_value"})," and ",(0,n.jsx)(r.code,{children:"@metric_partial"}),". For the MetricProvider, QueryMetricProvider, and TableMetricProvider classes, these are the only supported Metric decorators."]}),"\n",(0,n.jsx)(r.p,{children:"The following table lists the MetricProvider subclasses and their associated Metrics."}),"\n",(0,n.jsxs)(r.table,{children:[(0,n.jsx)(r.thead,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.th,{children:"Subclass"}),(0,n.jsx)(r.th,{children:"Supported Metrics"})]})}),(0,n.jsxs)(r.tbody,{children:[(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"ColumnAggregateMetricProvider"}),(0,n.jsx)(r.td,{children:"@column_aggregate_value, @column_aggregate_partial"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"ColumnMapMetricProvider"}),(0,n.jsx)(r.td,{children:"@column_condition_partial, @column_function_partial"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"ColumnPairMapMetricProvider"}),(0,n.jsx)(r.td,{children:"@column_pair_condition_partial"})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"MulticolumnMapMetricProvider"}),(0,n.jsx)(r.td,{children:"@multicolumn_condition_partial, @multicolumn_function_partial"})]})]})]})]})}function h(e={}){const{wrapper:r}={...(0,s.R)(),...e.components};return r?(0,n.jsx)(r,{...e,children:(0,n.jsx)(l,{...e})}):l(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.