feat(models/assertion): Add SQL Assertions (#8969)

This commit is contained in:
Andrew Sikowitz 2023-10-08 13:26:48 -04:00 committed by GitHub
parent b191abbc5b
commit 93958302d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 83 additions and 1 deletions

View File

@ -32,6 +32,11 @@ record AssertionInfo includes CustomProperties, ExternalReference {
*/
VOLUME
/**
* A raw SQL-statement based assertion
*/
SQL
/**
* A schema or structural assertion.
*
@ -56,7 +61,12 @@ record AssertionInfo includes CustomProperties, ExternalReference {
volumeAssertion: optional VolumeAssertionInfo
/**
* An schema Assertion definition. This field is populated when the type is DATASET_SCHEMA
* A SQL Assertion definition. This field is populated when the type is SQL.
*/
sqlAssertion: optional SqlAssertionInfo
/**
* An schema Assertion definition. This field is populated when the type is DATA_SCHEMA
*/
schemaAssertion: optional SchemaAssertionInfo
@ -67,4 +77,9 @@ record AssertionInfo includes CustomProperties, ExternalReference {
* the platform where it was ingested from.
*/
source: optional AssertionSource
/**
* An optional human-readable description of the assertion
*/
description: optional string
}

View File

@ -0,0 +1,67 @@
namespace com.linkedin.assertion
import com.linkedin.common.Urn
import com.linkedin.dataset.DatasetFilter
/**
* Attributes defining a SQL Assertion
*/
record SqlAssertionInfo {
/**
* The type of the SQL assertion being monitored.
*/
@Searchable = {}
type: enum SqlAssertionType {
/**
* A SQL Metric Assertion, e.g. one based on a numeric value returned by an arbitrary SQL query.
*/
METRIC
/**
* A SQL assertion that is evaluated against the CHANGE in a metric assertion
* over time.
*/
METRIC_CHANGE
}
/**
* The entity targeted by this SQL check.
*/
@Searchable = {
"fieldType": "URN"
}
@Relationship = {
"name": "Asserts",
"entityTypes": [ "dataset" ]
}
entity: Urn
/**
* The SQL statement to be executed when evaluating the assertion (or computing the metric).
* This should be a valid and complete statement, executable by itself.
*
* Usually this should be a SELECT query statement.
*/
statement: string
/**
* The type of the value used to evaluate the assertion: a fixed absolute value or a relative percentage.
* This value is required if the type is METRIC_CHANGE.
*/
changeType: optional AssertionValueChangeType
/**
* The operator you'd like to apply to the result of the SQL query.
*
* Note that at this time, only numeric operators are valid inputs:
* GREATER_THAN, GREATER_THAN_OR_EQUAL_TO, EQUAL_TO, LESS_THAN, LESS_THAN_OR_EQUAL_TO,
* BETWEEN.
*/
operator: AssertionStdOperator
/**
* The parameters you'd like to provide as input to the operator.
*
* Note that only numeric parameter types are valid inputs: NUMBER.
*/
parameters: AssertionStdParameters
}