Skip to content

Commit

Permalink
feat(models/assertion): Add SQL Assertions (#8969)
Browse files Browse the repository at this point in the history
  • Loading branch information
asikowitz authored Oct 8, 2023
1 parent b191abb commit 9395830
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ record AssertionInfo includes CustomProperties, ExternalReference {
*/
VOLUME

/**
* A raw SQL-statement based assertion
*/
SQL

/**
* A schema or structural assertion.
*
Expand All @@ -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

Expand All @@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 9395830

Please sign in to comment.