metric

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//UniqueFields is metadata needed to form unique count metric
	UniqueFields = "uniquefields"
)

Variables

View Source
var (
	//TypesBasicMetric metric in basic metric category
	TypesBasicMetric = []Type{NullCount, Count, UniqueCount, Sum, InvalidCount}

	//TypesDataQuality is metric types in data quality category
	TypesDataQuality = []Type{NullnessPct, DuplicationPct, TrendInconsistencyPct, RowCount, InvalidPct}

	//TypeAll is all of metric types
	TypeAll = append(TypesDataQuality, TypesBasicMetric...)
)

Functions

This section is empty.

Types

type Category

type Category string

Category is business perspective of metric

const (
	//Basic is category for metric belong to basic metric
	Basic Category = "basic"

	//Quality is category for metric belong to data quality metric
	Quality = "quality"
)

func GetCategory

func GetCategory(metricType Type) Category

GetCategory to get Category of a metric Type

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

Finder to find metric with specific criteria

func NewFinder

func NewFinder(metrics []*Metric) *Finder

NewFinder create Finder need list of metrics

func (*Finder) Find

func (f *Finder) Find() []*Metric

Find find all metrics matches criteria return empty slices when no metric found

func (*Finder) FindOne

func (f *Finder) FindOne() *Metric

FindOne find one metric matches criteria Return first found metric Might return nil when not found

func (*Finder) WithCategory

func (f *Finder) WithCategory(cat Category) *Finder

func (*Finder) WithCondition

func (f *Finder) WithCondition(condition string) *Finder

func (*Finder) WithFieldID

func (f *Finder) WithFieldID(fieldID string) *Finder

func (*Finder) WithID

func (f *Finder) WithID(ID string) *Finder

func (*Finder) WithOwner

func (f *Finder) WithOwner(owner Owner) *Finder

func (*Finder) WithPartition

func (f *Finder) WithPartition(partition string) *Finder

func (*Finder) WithType

func (f *Finder) WithType(Type Type) *Finder

type Group

type Group []*Metric

func (Group) ByGroupValue

func (g Group) ByGroupValue() []Group

func (Group) ByPartition

func (g Group) ByPartition() []Group

func (Group) ByPartitionAsMap

func (g Group) ByPartitionAsMap() map[string][]*Metric

type Metric

type Metric struct {
	ID       string
	FieldID  string
	Type     Type
	Category Category
	Owner    Owner

	//Partition will be deprecated, please do not use this
	Partition string

	Metadata map[string]interface{}

	GroupValue string
	Value      float64
	Condition  string
	Timestamp  time.Time
}

Metric information about statistical measurement of a table resource

func New

func New(fieldID string,
	_type Type,
	category Category,
	value float64,
	timestamp time.Time) *Metric

New create Metric

type Owner

type Owner string

Owner type the metric

const (
	//Table table as owner of metric
	Table Owner = "table"
	//Field field or column as owner of metric
	Field Owner = "field"
)

type Spec

type Spec struct {
	Name    Type
	FieldID string
	TableID string

	//Condition is rule of invalidity, contains sql query and also an unique ID
	Condition string

	Owner Owner

	Metadata map[string]interface{}

	//Optional is the metric optional
	Optional bool
}

Spec is specification of metric that generated by profiler or auditor

type SpecFinder

type SpecFinder []*Spec

SpecFinder for search specific metric specs from list of metric spec

func (SpecFinder) GetMetricSpecsByFieldID

func (msf SpecFinder) GetMetricSpecsByFieldID(fieldID string) ([]*Spec, error)

GetMetricSpecsByFieldID to get metrics based on field Partition

type Type

type Type string

Type is type of metric

const (
	//NullnessPct is nullnes percentage
	NullnessPct Type = "nullness_pct"
	//DuplicationPct is duplication percentage
	DuplicationPct Type = "duplication_pct"
	//TrendInconsistencyPct is trend inconsistency percentage
	TrendInconsistencyPct Type = "trend_inconsistency_pct"
	//RowCount is row count and is not a percentage
	RowCount Type = "row_count"
	//InvalidPct is invalid percentage
	InvalidPct Type = "invalid_pct"
)
const (
	//NullCount is null count metric
	NullCount Type = "nullcount"
	//Count is count metric
	Count Type = "count"

	//UniqueCount is unique count metric
	UniqueCount Type = "uniquecount"
	//Sum is sum metric
	Sum Type = "sum"
	//InvalidCount is invalid count metric
	InvalidCount Type = "invalidcount"
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL