acryl-datahub-cloud 0.3.10rc4__py3-none-any.whl → 0.3.16.1rc0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of acryl-datahub-cloud might be problematic. Click here for more details.
- acryl_datahub_cloud/_codegen_config.json +1 -1
- acryl_datahub_cloud/acryl_cs_issues/acryl_customer.py +1 -1
- acryl_datahub_cloud/acryl_cs_issues/models.py +5 -3
- acryl_datahub_cloud/action_request/action_request_owner_source.py +37 -8
- acryl_datahub_cloud/datahub_forms_notifications/__init__.py +0 -0
- acryl_datahub_cloud/datahub_forms_notifications/forms_notifications_source.py +569 -0
- acryl_datahub_cloud/datahub_forms_notifications/get_feature_flag.gql +7 -0
- acryl_datahub_cloud/datahub_forms_notifications/get_search_results_total.gql +14 -0
- acryl_datahub_cloud/datahub_forms_notifications/query.py +17 -0
- acryl_datahub_cloud/datahub_forms_notifications/scroll_forms_for_notification.gql +29 -0
- acryl_datahub_cloud/datahub_forms_notifications/send_form_notification_request.gql +5 -0
- acryl_datahub_cloud/datahub_reporting/datahub_dataset.py +39 -19
- acryl_datahub_cloud/datahub_reporting/datahub_form_reporting.py +60 -25
- acryl_datahub_cloud/datahub_reporting/extract_graph.py +9 -3
- acryl_datahub_cloud/datahub_reporting/extract_sql.py +248 -52
- acryl_datahub_cloud/datahub_reporting/forms.py +1 -1
- acryl_datahub_cloud/datahub_reporting/forms_config.py +3 -2
- acryl_datahub_cloud/datahub_restore/source.py +3 -2
- acryl_datahub_cloud/datahub_usage_reporting/excluded.py +94 -0
- acryl_datahub_cloud/datahub_usage_reporting/query_builder.py +48 -8
- acryl_datahub_cloud/datahub_usage_reporting/usage_feature_reporter.py +532 -109
- acryl_datahub_cloud/elasticsearch/graph_service.py +76 -14
- acryl_datahub_cloud/graphql_utils.py +64 -0
- acryl_datahub_cloud/lineage_features/source.py +555 -49
- acryl_datahub_cloud/metadata/_urns/urn_defs.py +2390 -1938
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/actionworkflow/__init__.py +53 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/anomaly/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/application/__init__.py +19 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/assertion/__init__.py +6 -2
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/common/__init__.py +6 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/conversation/__init__.py +29 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/event/notification/settings/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/execution/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/file/__init__.py +19 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/form/__init__.py +8 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/identity/__init__.py +8 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/knowledge/__init__.py +33 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/logical/__init__.py +15 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/metadata/key/__init__.py +14 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/metadata/search/features/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/module/__init__.py +31 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/monitor/__init__.py +6 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/notification/__init__.py +19 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/platform/event/v1/__init__.py +4 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/role/__init__.py +2 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/settings/asset/__init__.py +19 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/settings/global/__init__.py +28 -0
- acryl_datahub_cloud/metadata/com/linkedin/pegasus2avro/template/__init__.py +31 -0
- acryl_datahub_cloud/metadata/schema.avsc +27843 -23200
- acryl_datahub_cloud/metadata/schema_classes.py +29901 -24310
- acryl_datahub_cloud/metadata/schemas/ActionRequestInfo.avsc +235 -2
- acryl_datahub_cloud/metadata/schemas/ActionWorkflowInfo.avsc +683 -0
- acryl_datahub_cloud/metadata/schemas/ActionWorkflowKey.avsc +21 -0
- acryl_datahub_cloud/metadata/schemas/Actors.avsc +38 -1
- acryl_datahub_cloud/metadata/schemas/ApplicationKey.avsc +31 -0
- acryl_datahub_cloud/metadata/schemas/ApplicationProperties.avsc +75 -0
- acryl_datahub_cloud/metadata/schemas/Applications.avsc +38 -0
- acryl_datahub_cloud/metadata/schemas/AssertionAnalyticsRunEvent.avsc +375 -212
- acryl_datahub_cloud/metadata/schemas/AssertionInfo.avsc +147 -20
- acryl_datahub_cloud/metadata/schemas/AssertionKey.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/AssertionRunEvent.avsc +191 -21
- acryl_datahub_cloud/metadata/schemas/{AssertionSummary.avsc → AssertionRunSummary.avsc} +15 -2
- acryl_datahub_cloud/metadata/schemas/AssertionsSummary.avsc +54 -0
- acryl_datahub_cloud/metadata/schemas/AssetSettings.avsc +63 -0
- acryl_datahub_cloud/metadata/schemas/BusinessAttributeInfo.avsc +7 -3
- acryl_datahub_cloud/metadata/schemas/ChartInfo.avsc +20 -6
- acryl_datahub_cloud/metadata/schemas/ChartKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/ConstraintInfo.avsc +12 -1
- acryl_datahub_cloud/metadata/schemas/ContainerKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/ContainerProperties.avsc +16 -5
- acryl_datahub_cloud/metadata/schemas/CorpGroupEditableInfo.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/CorpGroupInfo.avsc +7 -3
- acryl_datahub_cloud/metadata/schemas/CorpGroupKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/CorpGroupSettings.avsc +127 -2
- acryl_datahub_cloud/metadata/schemas/CorpUserEditableInfo.avsc +1 -1
- acryl_datahub_cloud/metadata/schemas/CorpUserInfo.avsc +18 -2
- acryl_datahub_cloud/metadata/schemas/CorpUserInvitationStatus.avsc +106 -0
- acryl_datahub_cloud/metadata/schemas/CorpUserKey.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/CorpUserSettings.avsc +304 -2
- acryl_datahub_cloud/metadata/schemas/CorpUserUsageFeatures.avsc +86 -0
- acryl_datahub_cloud/metadata/schemas/DashboardInfo.avsc +11 -5
- acryl_datahub_cloud/metadata/schemas/DashboardKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/DataContractKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/DataFlowInfo.avsc +15 -5
- acryl_datahub_cloud/metadata/schemas/DataFlowKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/DataHubAiConversationInfo.avsc +256 -0
- acryl_datahub_cloud/metadata/schemas/DataHubAiConversationKey.avsc +22 -0
- acryl_datahub_cloud/metadata/schemas/DataHubFileInfo.avsc +234 -0
- acryl_datahub_cloud/metadata/schemas/DataHubFileKey.avsc +22 -0
- acryl_datahub_cloud/metadata/schemas/DataHubIngestionSourceKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/DataHubOpenAPISchemaKey.avsc +22 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPageModuleKey.avsc +21 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPageModuleProperties.avsc +308 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPageTemplateKey.avsc +21 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPageTemplateProperties.avsc +251 -0
- acryl_datahub_cloud/metadata/schemas/DataHubPolicyInfo.avsc +12 -1
- acryl_datahub_cloud/metadata/schemas/DataJobInfo.avsc +13 -4
- acryl_datahub_cloud/metadata/schemas/DataJobInputOutput.avsc +8 -0
- acryl_datahub_cloud/metadata/schemas/DataJobKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/DataPlatformInfo.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/DataPlatformInstanceProperties.avsc +5 -2
- acryl_datahub_cloud/metadata/schemas/DataProcessKey.avsc +4 -0
- acryl_datahub_cloud/metadata/schemas/DataProductKey.avsc +2 -0
- acryl_datahub_cloud/metadata/schemas/DataProductProperties.avsc +6 -3
- acryl_datahub_cloud/metadata/schemas/DataTransformLogic.avsc +4 -2
- acryl_datahub_cloud/metadata/schemas/DataTypeInfo.avsc +5 -0
- acryl_datahub_cloud/metadata/schemas/DatasetKey.avsc +10 -2
- acryl_datahub_cloud/metadata/schemas/DatasetProperties.avsc +12 -5
- acryl_datahub_cloud/metadata/schemas/DatasetUsageStatistics.avsc +8 -0
- acryl_datahub_cloud/metadata/schemas/DocumentInfo.avsc +407 -0
- acryl_datahub_cloud/metadata/schemas/DocumentKey.avsc +35 -0
- acryl_datahub_cloud/metadata/schemas/DocumentSettings.avsc +79 -0
- acryl_datahub_cloud/metadata/schemas/DomainKey.avsc +2 -0
- acryl_datahub_cloud/metadata/schemas/DomainProperties.avsc +7 -3
- acryl_datahub_cloud/metadata/schemas/EditableContainerProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableDashboardProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableDataFlowProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableDataJobProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableDatasetProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableERModelRelationshipProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableMLFeatureProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableMLFeatureTableProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableMLModelGroupProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableMLModelProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableNotebookProperties.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/EditableSchemaMetadata.avsc +4 -2
- acryl_datahub_cloud/metadata/schemas/EntityTypeInfo.avsc +5 -0
- acryl_datahub_cloud/metadata/schemas/ExecutionRequestArtifactsLocation.avsc +16 -0
- acryl_datahub_cloud/metadata/schemas/ExecutionRequestKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/FormAssignmentStatus.avsc +36 -0
- acryl_datahub_cloud/metadata/schemas/FormInfo.avsc +6 -0
- acryl_datahub_cloud/metadata/schemas/FormKey.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/FormNotifications.avsc +69 -0
- acryl_datahub_cloud/metadata/schemas/FormSettings.avsc +30 -0
- acryl_datahub_cloud/metadata/schemas/GlobalSettingsInfo.avsc +416 -0
- acryl_datahub_cloud/metadata/schemas/GlobalTags.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/GlossaryNodeInfo.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/GlossaryNodeKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/GlossaryTermInfo.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/GlossaryTermKey.avsc +2 -0
- acryl_datahub_cloud/metadata/schemas/IcebergWarehouseInfo.avsc +4 -0
- acryl_datahub_cloud/metadata/schemas/IncidentActivityEvent.avsc +3 -3
- acryl_datahub_cloud/metadata/schemas/IncidentInfo.avsc +3 -3
- acryl_datahub_cloud/metadata/schemas/InferredMetadata.avsc +71 -1
- acryl_datahub_cloud/metadata/schemas/InputFields.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/InviteToken.avsc +26 -0
- acryl_datahub_cloud/metadata/schemas/LineageFeatures.avsc +67 -42
- acryl_datahub_cloud/metadata/schemas/LogicalParent.avsc +145 -0
- acryl_datahub_cloud/metadata/schemas/MLFeatureKey.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/MLFeatureTableKey.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/MLModelDeploymentKey.avsc +7 -1
- acryl_datahub_cloud/metadata/schemas/MLModelDeploymentProperties.avsc +3 -0
- acryl_datahub_cloud/metadata/schemas/MLModelGroupKey.avsc +9 -1
- acryl_datahub_cloud/metadata/schemas/MLModelKey.avsc +9 -1
- acryl_datahub_cloud/metadata/schemas/MLModelProperties.avsc +4 -2
- acryl_datahub_cloud/metadata/schemas/MLPrimaryKeyKey.avsc +4 -1
- acryl_datahub_cloud/metadata/schemas/MetadataChangeEvent.avsc +424 -97
- acryl_datahub_cloud/metadata/schemas/MetadataChangeLog.avsc +65 -44
- acryl_datahub_cloud/metadata/schemas/MetadataChangeProposal.avsc +64 -0
- acryl_datahub_cloud/metadata/schemas/MonitorAnomalyEvent.avsc +84 -29
- acryl_datahub_cloud/metadata/schemas/MonitorInfo.avsc +221 -23
- acryl_datahub_cloud/metadata/schemas/MonitorKey.avsc +9 -1
- acryl_datahub_cloud/metadata/schemas/MonitorSuiteInfo.avsc +128 -3
- acryl_datahub_cloud/metadata/schemas/NotebookInfo.avsc +5 -2
- acryl_datahub_cloud/metadata/schemas/NotebookKey.avsc +1 -0
- acryl_datahub_cloud/metadata/schemas/NotificationRequest.avsc +91 -4
- acryl_datahub_cloud/metadata/schemas/Operation.avsc +17 -0
- acryl_datahub_cloud/metadata/schemas/Ownership.avsc +71 -1
- acryl_datahub_cloud/metadata/schemas/QueryProperties.avsc +4 -2
- acryl_datahub_cloud/metadata/schemas/QuerySubjects.avsc +2 -13
- acryl_datahub_cloud/metadata/schemas/RelationshipChangeEvent.avsc +215 -0
- acryl_datahub_cloud/metadata/schemas/RoleProperties.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/SchemaFieldInfo.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/SchemaFieldKey.avsc +3 -0
- acryl_datahub_cloud/metadata/schemas/SchemaMetadata.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/SemanticContent.avsc +123 -0
- acryl_datahub_cloud/metadata/schemas/StructuredProperties.avsc +69 -0
- acryl_datahub_cloud/metadata/schemas/StructuredPropertyDefinition.avsc +15 -4
- acryl_datahub_cloud/metadata/schemas/StructuredPropertySettings.avsc +9 -0
- acryl_datahub_cloud/metadata/schemas/SubscriptionInfo.avsc +136 -5
- acryl_datahub_cloud/metadata/schemas/SubscriptionKey.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/SystemMetadata.avsc +147 -0
- acryl_datahub_cloud/metadata/schemas/TagProperties.avsc +3 -1
- acryl_datahub_cloud/metadata/schemas/TestInfo.avsc +2 -1
- acryl_datahub_cloud/metadata/schemas/UpstreamLineage.avsc +9 -0
- acryl_datahub_cloud/metadata/schemas/UsageFeatures.avsc +10 -0
- acryl_datahub_cloud/metadata/schemas/__init__.py +3 -3
- acryl_datahub_cloud/notifications/__init__.py +0 -0
- acryl_datahub_cloud/notifications/notification_recipient_builder.py +399 -0
- acryl_datahub_cloud/sdk/__init__.py +69 -0
- acryl_datahub_cloud/sdk/assertion/__init__.py +58 -0
- acryl_datahub_cloud/sdk/assertion/assertion_base.py +779 -0
- acryl_datahub_cloud/sdk/assertion/column_metric_assertion.py +191 -0
- acryl_datahub_cloud/sdk/assertion/column_value_assertion.py +431 -0
- acryl_datahub_cloud/sdk/assertion/freshness_assertion.py +201 -0
- acryl_datahub_cloud/sdk/assertion/schema_assertion.py +268 -0
- acryl_datahub_cloud/sdk/assertion/smart_column_metric_assertion.py +212 -0
- acryl_datahub_cloud/sdk/assertion/smart_freshness_assertion.py +165 -0
- acryl_datahub_cloud/sdk/assertion/smart_sql_assertion.py +156 -0
- acryl_datahub_cloud/sdk/assertion/smart_volume_assertion.py +162 -0
- acryl_datahub_cloud/sdk/assertion/sql_assertion.py +273 -0
- acryl_datahub_cloud/sdk/assertion/types.py +20 -0
- acryl_datahub_cloud/sdk/assertion/volume_assertion.py +156 -0
- acryl_datahub_cloud/sdk/assertion_client/__init__.py +0 -0
- acryl_datahub_cloud/sdk/assertion_client/column_metric.py +545 -0
- acryl_datahub_cloud/sdk/assertion_client/column_value.py +617 -0
- acryl_datahub_cloud/sdk/assertion_client/freshness.py +371 -0
- acryl_datahub_cloud/sdk/assertion_client/helpers.py +166 -0
- acryl_datahub_cloud/sdk/assertion_client/schema.py +358 -0
- acryl_datahub_cloud/sdk/assertion_client/smart_column_metric.py +540 -0
- acryl_datahub_cloud/sdk/assertion_client/smart_freshness.py +373 -0
- acryl_datahub_cloud/sdk/assertion_client/smart_sql.py +411 -0
- acryl_datahub_cloud/sdk/assertion_client/smart_volume.py +380 -0
- acryl_datahub_cloud/sdk/assertion_client/sql.py +410 -0
- acryl_datahub_cloud/sdk/assertion_client/volume.py +446 -0
- acryl_datahub_cloud/sdk/assertion_input/__init__.py +0 -0
- acryl_datahub_cloud/sdk/assertion_input/assertion_input.py +1470 -0
- acryl_datahub_cloud/sdk/assertion_input/column_assertion_constants.py +114 -0
- acryl_datahub_cloud/sdk/assertion_input/column_assertion_utils.py +284 -0
- acryl_datahub_cloud/sdk/assertion_input/column_metric_assertion_input.py +759 -0
- acryl_datahub_cloud/sdk/assertion_input/column_metric_constants.py +109 -0
- acryl_datahub_cloud/sdk/assertion_input/column_value_assertion_input.py +810 -0
- acryl_datahub_cloud/sdk/assertion_input/freshness_assertion_input.py +305 -0
- acryl_datahub_cloud/sdk/assertion_input/schema_assertion_input.py +413 -0
- acryl_datahub_cloud/sdk/assertion_input/smart_column_metric_assertion_input.py +793 -0
- acryl_datahub_cloud/sdk/assertion_input/smart_freshness_assertion_input.py +218 -0
- acryl_datahub_cloud/sdk/assertion_input/smart_sql_assertion_input.py +181 -0
- acryl_datahub_cloud/sdk/assertion_input/smart_volume_assertion_input.py +189 -0
- acryl_datahub_cloud/sdk/assertion_input/sql_assertion_input.py +320 -0
- acryl_datahub_cloud/sdk/assertion_input/volume_assertion_input.py +635 -0
- acryl_datahub_cloud/sdk/assertions_client.py +1074 -0
- acryl_datahub_cloud/sdk/entities/__init__.py +0 -0
- acryl_datahub_cloud/sdk/entities/assertion.py +439 -0
- acryl_datahub_cloud/sdk/entities/monitor.py +291 -0
- acryl_datahub_cloud/sdk/entities/subscription.py +100 -0
- acryl_datahub_cloud/sdk/errors.py +34 -0
- acryl_datahub_cloud/sdk/resolver_client.py +42 -0
- acryl_datahub_cloud/sdk/subscription_client.py +737 -0
- {acryl_datahub_cloud-0.3.10rc4.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/METADATA +49 -43
- {acryl_datahub_cloud-0.3.10rc4.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/RECORD +243 -145
- {acryl_datahub_cloud-0.3.10rc4.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/WHEEL +1 -1
- {acryl_datahub_cloud-0.3.10rc4.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/entry_points.txt +1 -0
- {acryl_datahub_cloud-0.3.10rc4.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Column value assertion client module.
|
|
3
|
+
|
|
4
|
+
This module provides the ColumnValueAssertionClient for creating and managing
|
|
5
|
+
column value assertions that validate individual row values against semantic constraints.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
from datetime import datetime, timezone
|
|
12
|
+
from typing import TYPE_CHECKING, Optional, Union
|
|
13
|
+
|
|
14
|
+
from acryl_datahub_cloud.sdk.assertion.assertion_base import AssertionMode
|
|
15
|
+
from acryl_datahub_cloud.sdk.assertion.column_value_assertion import (
|
|
16
|
+
ColumnValueAssertion,
|
|
17
|
+
)
|
|
18
|
+
from acryl_datahub_cloud.sdk.assertion_client.helpers import (
|
|
19
|
+
DEFAULT_CREATED_BY,
|
|
20
|
+
_merge_field,
|
|
21
|
+
_validate_required_field,
|
|
22
|
+
retrieve_assertion_and_monitor_by_urn,
|
|
23
|
+
)
|
|
24
|
+
from acryl_datahub_cloud.sdk.assertion_input.assertion_input import (
|
|
25
|
+
AssertionIncidentBehaviorInputTypes,
|
|
26
|
+
DetectionMechanismInputTypes,
|
|
27
|
+
)
|
|
28
|
+
from acryl_datahub_cloud.sdk.assertion_input.column_metric_constants import (
|
|
29
|
+
OperatorInputType,
|
|
30
|
+
)
|
|
31
|
+
from acryl_datahub_cloud.sdk.assertion_input.column_value_assertion_input import (
|
|
32
|
+
ColumnValueAssertionParameters,
|
|
33
|
+
FailThresholdInputType,
|
|
34
|
+
FieldTransformInputType,
|
|
35
|
+
_ColumnValueAssertionInput,
|
|
36
|
+
)
|
|
37
|
+
from acryl_datahub_cloud.sdk.entities.assertion import Assertion, TagsInputType
|
|
38
|
+
from acryl_datahub_cloud.sdk.entities.monitor import Monitor
|
|
39
|
+
from acryl_datahub_cloud.sdk.errors import SDKUsageError
|
|
40
|
+
from datahub.metadata import schema_classes as models
|
|
41
|
+
from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn, MonitorUrn
|
|
42
|
+
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from datahub.sdk.main_client import DataHubClient
|
|
45
|
+
|
|
46
|
+
logger = logging.getLogger(__name__)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class ColumnValueAssertionClient:
|
|
50
|
+
"""Client for managing column value assertions."""
|
|
51
|
+
|
|
52
|
+
def __init__(self, client: "DataHubClient"):
|
|
53
|
+
self.client = client
|
|
54
|
+
|
|
55
|
+
def _validate_required_column_value_fields_for_creation(
|
|
56
|
+
self,
|
|
57
|
+
column_name: Optional[str],
|
|
58
|
+
operator: Optional[OperatorInputType],
|
|
59
|
+
) -> None:
|
|
60
|
+
"""Validate required fields for column value assertion creation."""
|
|
61
|
+
_validate_required_field(
|
|
62
|
+
column_name, "column_name", "when creating a new assertion (urn is None)"
|
|
63
|
+
)
|
|
64
|
+
_validate_required_field(
|
|
65
|
+
operator, "operator", "when creating a new assertion (urn is None)"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
def _validate_required_column_value_fields_for_update(
|
|
69
|
+
self,
|
|
70
|
+
column_name: Optional[str],
|
|
71
|
+
operator: Optional[OperatorInputType],
|
|
72
|
+
assertion_urn: Union[str, AssertionUrn],
|
|
73
|
+
) -> None:
|
|
74
|
+
"""Validate required fields after attempting to fetch from existing assertion."""
|
|
75
|
+
context = (
|
|
76
|
+
f"and not found in existing assertion {assertion_urn}. "
|
|
77
|
+
"The existing assertion may be invalid or corrupted."
|
|
78
|
+
)
|
|
79
|
+
_validate_required_field(column_name, "column_name", context)
|
|
80
|
+
_validate_required_field(operator, "operator", context)
|
|
81
|
+
|
|
82
|
+
def _retrieve_assertion_and_monitor(
|
|
83
|
+
self,
|
|
84
|
+
urn: Union[str, AssertionUrn],
|
|
85
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
86
|
+
) -> tuple[Optional[Assertion], MonitorUrn, Optional[Monitor]]:
|
|
87
|
+
"""Retrieve the assertion and monitor entities from the DataHub instance."""
|
|
88
|
+
return retrieve_assertion_and_monitor_by_urn(self.client, urn, dataset_urn)
|
|
89
|
+
|
|
90
|
+
def sync_column_value_assertion(
|
|
91
|
+
self,
|
|
92
|
+
*,
|
|
93
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
94
|
+
column_name: Optional[str] = None,
|
|
95
|
+
operator: Optional[OperatorInputType] = None,
|
|
96
|
+
criteria_parameters: Optional[ColumnValueAssertionParameters] = None,
|
|
97
|
+
transform: Optional[FieldTransformInputType] = None,
|
|
98
|
+
fail_threshold_type: Optional[FailThresholdInputType] = None,
|
|
99
|
+
fail_threshold_value: Optional[int] = None,
|
|
100
|
+
exclude_nulls: Optional[bool] = None,
|
|
101
|
+
urn: Optional[Union[str, AssertionUrn]] = None,
|
|
102
|
+
display_name: Optional[str] = None,
|
|
103
|
+
enabled: Optional[bool] = None,
|
|
104
|
+
detection_mechanism: DetectionMechanismInputTypes = None,
|
|
105
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
|
|
106
|
+
tags: Optional[TagsInputType] = None,
|
|
107
|
+
updated_by: Optional[Union[str, CorpUserUrn]] = None,
|
|
108
|
+
schedule: Optional[Union[str, models.CronScheduleClass]] = None,
|
|
109
|
+
) -> ColumnValueAssertion:
|
|
110
|
+
"""Create or update a column value assertion.
|
|
111
|
+
|
|
112
|
+
See AssertionsClient.sync_column_value_assertion for full documentation.
|
|
113
|
+
"""
|
|
114
|
+
now_utc = datetime.now(timezone.utc)
|
|
115
|
+
|
|
116
|
+
if updated_by is None:
|
|
117
|
+
logger.warning(
|
|
118
|
+
f"updated_by is not set, using {DEFAULT_CREATED_BY} as a placeholder"
|
|
119
|
+
)
|
|
120
|
+
updated_by = DEFAULT_CREATED_BY
|
|
121
|
+
|
|
122
|
+
assertion_input = self._retrieve_and_merge_column_value_assertion_and_monitor(
|
|
123
|
+
dataset_urn=dataset_urn,
|
|
124
|
+
urn=urn,
|
|
125
|
+
column_name=column_name,
|
|
126
|
+
operator=operator,
|
|
127
|
+
criteria_parameters=criteria_parameters,
|
|
128
|
+
transform=transform,
|
|
129
|
+
fail_threshold_type=fail_threshold_type,
|
|
130
|
+
fail_threshold_value=fail_threshold_value,
|
|
131
|
+
exclude_nulls=exclude_nulls,
|
|
132
|
+
display_name=display_name,
|
|
133
|
+
enabled=enabled,
|
|
134
|
+
detection_mechanism=detection_mechanism,
|
|
135
|
+
incident_behavior=incident_behavior,
|
|
136
|
+
tags=tags,
|
|
137
|
+
updated_by=updated_by,
|
|
138
|
+
now_utc=now_utc,
|
|
139
|
+
schedule=schedule,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
assertion_entity, monitor_entity = (
|
|
143
|
+
assertion_input.to_assertion_and_monitor_entities()
|
|
144
|
+
)
|
|
145
|
+
self.client.entities.upsert(assertion_entity)
|
|
146
|
+
self.client.entities.upsert(monitor_entity)
|
|
147
|
+
|
|
148
|
+
return ColumnValueAssertion._from_entities(assertion_entity, monitor_entity)
|
|
149
|
+
|
|
150
|
+
def _extract_fields_from_existing_assertion(
|
|
151
|
+
self,
|
|
152
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
153
|
+
column_name: Optional[str],
|
|
154
|
+
operator: Optional[OperatorInputType],
|
|
155
|
+
criteria_parameters: Optional[ColumnValueAssertionParameters],
|
|
156
|
+
transform: Optional[FieldTransformInputType],
|
|
157
|
+
fail_threshold_type: Optional[FailThresholdInputType],
|
|
158
|
+
fail_threshold_value: Optional[int],
|
|
159
|
+
exclude_nulls: Optional[bool],
|
|
160
|
+
) -> tuple[
|
|
161
|
+
Optional[str],
|
|
162
|
+
Optional[OperatorInputType],
|
|
163
|
+
Optional[ColumnValueAssertionParameters],
|
|
164
|
+
Optional[FieldTransformInputType],
|
|
165
|
+
Optional[FailThresholdInputType],
|
|
166
|
+
Optional[int],
|
|
167
|
+
Optional[bool],
|
|
168
|
+
Optional[tuple],
|
|
169
|
+
]:
|
|
170
|
+
"""Extract missing fields from existing assertion entity."""
|
|
171
|
+
gms_criteria_type_info = None
|
|
172
|
+
|
|
173
|
+
if maybe_assertion_entity is None:
|
|
174
|
+
return (
|
|
175
|
+
column_name,
|
|
176
|
+
operator,
|
|
177
|
+
criteria_parameters,
|
|
178
|
+
transform,
|
|
179
|
+
fail_threshold_type,
|
|
180
|
+
fail_threshold_value,
|
|
181
|
+
exclude_nulls,
|
|
182
|
+
gms_criteria_type_info,
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
assertion_info = maybe_assertion_entity.info
|
|
186
|
+
field_values_assertion = getattr(assertion_info, "fieldValuesAssertion", None)
|
|
187
|
+
if field_values_assertion:
|
|
188
|
+
column_name, operator, transform = self._extract_basic_fields(
|
|
189
|
+
field_values_assertion, column_name, operator, transform
|
|
190
|
+
)
|
|
191
|
+
fail_threshold_type, fail_threshold_value, exclude_nulls = (
|
|
192
|
+
self._extract_threshold_fields(
|
|
193
|
+
field_values_assertion,
|
|
194
|
+
fail_threshold_type,
|
|
195
|
+
fail_threshold_value,
|
|
196
|
+
exclude_nulls,
|
|
197
|
+
)
|
|
198
|
+
)
|
|
199
|
+
if criteria_parameters is None:
|
|
200
|
+
criteria_parameters = self._extract_criteria_parameters(
|
|
201
|
+
field_values_assertion
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
gms_criteria_type_info = (
|
|
205
|
+
ColumnValueAssertion._get_criteria_parameters_with_type(
|
|
206
|
+
maybe_assertion_entity
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
column_name,
|
|
212
|
+
operator,
|
|
213
|
+
criteria_parameters,
|
|
214
|
+
transform,
|
|
215
|
+
fail_threshold_type,
|
|
216
|
+
fail_threshold_value,
|
|
217
|
+
exclude_nulls,
|
|
218
|
+
gms_criteria_type_info,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
def _extract_basic_fields(
|
|
222
|
+
self,
|
|
223
|
+
field_values_assertion: models.FieldValuesAssertionClass,
|
|
224
|
+
column_name: Optional[str],
|
|
225
|
+
operator: Optional[OperatorInputType],
|
|
226
|
+
transform: Optional[FieldTransformInputType],
|
|
227
|
+
) -> tuple[
|
|
228
|
+
Optional[str], Optional[OperatorInputType], Optional[FieldTransformInputType]
|
|
229
|
+
]:
|
|
230
|
+
"""Extract column_name, operator, and transform from field values assertion."""
|
|
231
|
+
if column_name is None:
|
|
232
|
+
field = getattr(field_values_assertion, "field", None)
|
|
233
|
+
if field:
|
|
234
|
+
column_name = getattr(field, "path", None)
|
|
235
|
+
|
|
236
|
+
if operator is None:
|
|
237
|
+
operator = getattr(field_values_assertion, "operator", None)
|
|
238
|
+
|
|
239
|
+
if transform is None:
|
|
240
|
+
fv_transform = getattr(field_values_assertion, "transform", None)
|
|
241
|
+
if fv_transform:
|
|
242
|
+
transform = getattr(fv_transform, "type", None)
|
|
243
|
+
|
|
244
|
+
return column_name, operator, transform
|
|
245
|
+
|
|
246
|
+
def _extract_threshold_fields(
|
|
247
|
+
self,
|
|
248
|
+
field_values_assertion: models.FieldValuesAssertionClass,
|
|
249
|
+
fail_threshold_type: Optional[FailThresholdInputType],
|
|
250
|
+
fail_threshold_value: Optional[int],
|
|
251
|
+
exclude_nulls: Optional[bool],
|
|
252
|
+
) -> tuple[Optional[FailThresholdInputType], Optional[int], Optional[bool]]:
|
|
253
|
+
"""Extract fail threshold and exclude_nulls from field values assertion."""
|
|
254
|
+
threshold = getattr(field_values_assertion, "failThreshold", None)
|
|
255
|
+
if threshold:
|
|
256
|
+
if fail_threshold_type is None:
|
|
257
|
+
fail_threshold_type = getattr(threshold, "type", None)
|
|
258
|
+
if fail_threshold_value is None:
|
|
259
|
+
fail_threshold_value = getattr(threshold, "value", None)
|
|
260
|
+
|
|
261
|
+
if exclude_nulls is None:
|
|
262
|
+
exclude_nulls = getattr(field_values_assertion, "excludeNulls", None)
|
|
263
|
+
|
|
264
|
+
return fail_threshold_type, fail_threshold_value, exclude_nulls
|
|
265
|
+
|
|
266
|
+
def _extract_criteria_parameters(
|
|
267
|
+
self,
|
|
268
|
+
field_values_assertion: models.FieldValuesAssertionClass,
|
|
269
|
+
) -> Optional[ColumnValueAssertionParameters]:
|
|
270
|
+
"""Extract criteria parameters from field values assertion."""
|
|
271
|
+
params = getattr(field_values_assertion, "parameters", None)
|
|
272
|
+
if not params:
|
|
273
|
+
return None
|
|
274
|
+
|
|
275
|
+
value_param = getattr(params, "value", None)
|
|
276
|
+
if value_param:
|
|
277
|
+
return getattr(value_param, "value", None)
|
|
278
|
+
|
|
279
|
+
min_value = getattr(params, "minValue", None)
|
|
280
|
+
max_value = getattr(params, "maxValue", None)
|
|
281
|
+
if min_value and max_value:
|
|
282
|
+
return (min_value.value, max_value.value)
|
|
283
|
+
|
|
284
|
+
return None
|
|
285
|
+
|
|
286
|
+
def _create_existing_assertion_from_entities(
|
|
287
|
+
self,
|
|
288
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
289
|
+
maybe_monitor_entity: Optional[Monitor],
|
|
290
|
+
monitor_urn: MonitorUrn,
|
|
291
|
+
enabled: Optional[bool],
|
|
292
|
+
) -> Optional[ColumnValueAssertion]:
|
|
293
|
+
"""Create existing assertion object from entities, handling missing monitor case."""
|
|
294
|
+
if maybe_assertion_entity and maybe_monitor_entity:
|
|
295
|
+
return ColumnValueAssertion._from_entities(
|
|
296
|
+
maybe_assertion_entity, maybe_monitor_entity
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
if maybe_assertion_entity and not maybe_monitor_entity:
|
|
300
|
+
monitor_mode = (
|
|
301
|
+
"ACTIVE" if enabled else "INACTIVE" if enabled is not None else "ACTIVE"
|
|
302
|
+
)
|
|
303
|
+
return ColumnValueAssertion._from_entities(
|
|
304
|
+
maybe_assertion_entity,
|
|
305
|
+
Monitor(id=monitor_urn, info=("ASSERTION", monitor_mode)),
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
return None
|
|
309
|
+
|
|
310
|
+
def _retrieve_and_merge_column_value_assertion_and_monitor(
|
|
311
|
+
self,
|
|
312
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
313
|
+
urn: Optional[Union[str, AssertionUrn]],
|
|
314
|
+
column_name: Optional[str],
|
|
315
|
+
operator: Optional[OperatorInputType],
|
|
316
|
+
criteria_parameters: Optional[ColumnValueAssertionParameters],
|
|
317
|
+
transform: Optional[FieldTransformInputType],
|
|
318
|
+
fail_threshold_type: Optional[FailThresholdInputType],
|
|
319
|
+
fail_threshold_value: Optional[int],
|
|
320
|
+
exclude_nulls: Optional[bool],
|
|
321
|
+
display_name: Optional[str],
|
|
322
|
+
enabled: Optional[bool],
|
|
323
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
324
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
325
|
+
tags: Optional[TagsInputType],
|
|
326
|
+
updated_by: Union[str, CorpUserUrn],
|
|
327
|
+
now_utc: datetime,
|
|
328
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
329
|
+
) -> _ColumnValueAssertionInput:
|
|
330
|
+
if urn is None:
|
|
331
|
+
logger.info("URN is not set, building a new assertion input")
|
|
332
|
+
self._validate_required_column_value_fields_for_creation(
|
|
333
|
+
column_name, operator
|
|
334
|
+
)
|
|
335
|
+
assert column_name is not None and operator is not None, (
|
|
336
|
+
"Fields guaranteed non-None after validation"
|
|
337
|
+
)
|
|
338
|
+
return _ColumnValueAssertionInput(
|
|
339
|
+
urn=None,
|
|
340
|
+
entity_client=self.client.entities,
|
|
341
|
+
dataset_urn=dataset_urn,
|
|
342
|
+
column_name=column_name,
|
|
343
|
+
operator=operator,
|
|
344
|
+
criteria_parameters=criteria_parameters,
|
|
345
|
+
transform=transform,
|
|
346
|
+
fail_threshold_type=fail_threshold_type,
|
|
347
|
+
fail_threshold_value=fail_threshold_value
|
|
348
|
+
if fail_threshold_value is not None
|
|
349
|
+
else 0,
|
|
350
|
+
exclude_nulls=exclude_nulls if exclude_nulls is not None else True,
|
|
351
|
+
display_name=display_name,
|
|
352
|
+
enabled=enabled if enabled is not None else True,
|
|
353
|
+
detection_mechanism=detection_mechanism,
|
|
354
|
+
incident_behavior=incident_behavior,
|
|
355
|
+
tags=tags,
|
|
356
|
+
created_by=updated_by,
|
|
357
|
+
created_at=now_utc,
|
|
358
|
+
updated_by=updated_by,
|
|
359
|
+
updated_at=now_utc,
|
|
360
|
+
schedule=schedule,
|
|
361
|
+
gms_criteria_type_info=None,
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
maybe_assertion_entity, monitor_urn, maybe_monitor_entity = (
|
|
365
|
+
self._retrieve_assertion_and_monitor(urn, dataset_urn)
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
# Fail fast: Check for dataset URN mismatch before expensive operations
|
|
369
|
+
if maybe_assertion_entity and str(maybe_assertion_entity.dataset) != str(
|
|
370
|
+
dataset_urn
|
|
371
|
+
):
|
|
372
|
+
raise SDKUsageError(
|
|
373
|
+
f"Dataset URN mismatch: assertion {urn} is for dataset "
|
|
374
|
+
f"{maybe_assertion_entity.dataset}, but you're trying to update it "
|
|
375
|
+
f"on dataset {dataset_urn}"
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
(
|
|
379
|
+
column_name,
|
|
380
|
+
operator,
|
|
381
|
+
criteria_parameters,
|
|
382
|
+
transform,
|
|
383
|
+
fail_threshold_type,
|
|
384
|
+
fail_threshold_value,
|
|
385
|
+
exclude_nulls,
|
|
386
|
+
gms_criteria_type_info,
|
|
387
|
+
) = self._extract_fields_from_existing_assertion(
|
|
388
|
+
maybe_assertion_entity,
|
|
389
|
+
column_name,
|
|
390
|
+
operator,
|
|
391
|
+
criteria_parameters,
|
|
392
|
+
transform,
|
|
393
|
+
fail_threshold_type,
|
|
394
|
+
fail_threshold_value,
|
|
395
|
+
exclude_nulls,
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
if maybe_assertion_entity is None:
|
|
399
|
+
self._validate_required_column_value_fields_for_creation(
|
|
400
|
+
column_name, operator
|
|
401
|
+
)
|
|
402
|
+
else:
|
|
403
|
+
self._validate_required_column_value_fields_for_update(
|
|
404
|
+
column_name, operator, urn
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
assert column_name is not None and operator is not None, (
|
|
408
|
+
"Fields guaranteed non-None after validation"
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
if not maybe_assertion_entity:
|
|
412
|
+
logger.info(
|
|
413
|
+
f"No existing assertion entity found for assertion urn {urn}, "
|
|
414
|
+
"building a new assertion input"
|
|
415
|
+
)
|
|
416
|
+
return _ColumnValueAssertionInput(
|
|
417
|
+
urn=urn,
|
|
418
|
+
entity_client=self.client.entities,
|
|
419
|
+
dataset_urn=dataset_urn,
|
|
420
|
+
column_name=column_name,
|
|
421
|
+
operator=operator,
|
|
422
|
+
criteria_parameters=criteria_parameters,
|
|
423
|
+
transform=transform,
|
|
424
|
+
fail_threshold_type=fail_threshold_type,
|
|
425
|
+
fail_threshold_value=fail_threshold_value
|
|
426
|
+
if fail_threshold_value is not None
|
|
427
|
+
else 0,
|
|
428
|
+
exclude_nulls=exclude_nulls if exclude_nulls is not None else True,
|
|
429
|
+
display_name=display_name,
|
|
430
|
+
enabled=enabled if enabled is not None else True,
|
|
431
|
+
detection_mechanism=detection_mechanism,
|
|
432
|
+
incident_behavior=incident_behavior,
|
|
433
|
+
tags=tags,
|
|
434
|
+
created_by=updated_by,
|
|
435
|
+
created_at=now_utc,
|
|
436
|
+
updated_by=updated_by,
|
|
437
|
+
updated_at=now_utc,
|
|
438
|
+
schedule=schedule,
|
|
439
|
+
gms_criteria_type_info=None,
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
assertion_input = _ColumnValueAssertionInput(
|
|
443
|
+
urn=urn,
|
|
444
|
+
entity_client=self.client.entities,
|
|
445
|
+
dataset_urn=dataset_urn,
|
|
446
|
+
column_name=column_name,
|
|
447
|
+
operator=operator,
|
|
448
|
+
criteria_parameters=criteria_parameters,
|
|
449
|
+
transform=transform,
|
|
450
|
+
fail_threshold_type=fail_threshold_type,
|
|
451
|
+
fail_threshold_value=fail_threshold_value
|
|
452
|
+
if fail_threshold_value is not None
|
|
453
|
+
else 0,
|
|
454
|
+
exclude_nulls=exclude_nulls if exclude_nulls is not None else True,
|
|
455
|
+
display_name=display_name,
|
|
456
|
+
detection_mechanism=detection_mechanism,
|
|
457
|
+
incident_behavior=incident_behavior,
|
|
458
|
+
tags=tags,
|
|
459
|
+
created_by=updated_by,
|
|
460
|
+
created_at=now_utc,
|
|
461
|
+
updated_by=updated_by,
|
|
462
|
+
updated_at=now_utc,
|
|
463
|
+
schedule=schedule,
|
|
464
|
+
gms_criteria_type_info=gms_criteria_type_info,
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
existing_assertion = self._create_existing_assertion_from_entities(
|
|
468
|
+
maybe_assertion_entity, maybe_monitor_entity, monitor_urn, enabled
|
|
469
|
+
)
|
|
470
|
+
assert existing_assertion is not None, (
|
|
471
|
+
"existing_assertion is guaranteed non-None after early return check"
|
|
472
|
+
)
|
|
473
|
+
|
|
474
|
+
merged_assertion_input = self._merge_column_value_input(
|
|
475
|
+
dataset_urn=dataset_urn,
|
|
476
|
+
column_name=column_name,
|
|
477
|
+
operator=operator,
|
|
478
|
+
criteria_parameters=criteria_parameters,
|
|
479
|
+
transform=transform,
|
|
480
|
+
fail_threshold_type=fail_threshold_type,
|
|
481
|
+
fail_threshold_value=fail_threshold_value,
|
|
482
|
+
exclude_nulls=exclude_nulls,
|
|
483
|
+
urn=urn,
|
|
484
|
+
display_name=display_name,
|
|
485
|
+
enabled=enabled,
|
|
486
|
+
schedule=schedule,
|
|
487
|
+
detection_mechanism=detection_mechanism,
|
|
488
|
+
incident_behavior=incident_behavior,
|
|
489
|
+
tags=tags,
|
|
490
|
+
now_utc=now_utc,
|
|
491
|
+
assertion_input=assertion_input,
|
|
492
|
+
maybe_assertion_entity=maybe_assertion_entity,
|
|
493
|
+
maybe_monitor_entity=maybe_monitor_entity,
|
|
494
|
+
existing_assertion=existing_assertion,
|
|
495
|
+
gms_criteria_type_info=gms_criteria_type_info,
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
return merged_assertion_input
|
|
499
|
+
|
|
500
|
+
def _merge_column_value_input(
|
|
501
|
+
self,
|
|
502
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
503
|
+
column_name: str,
|
|
504
|
+
operator: OperatorInputType,
|
|
505
|
+
criteria_parameters: Optional[ColumnValueAssertionParameters],
|
|
506
|
+
transform: Optional[FieldTransformInputType],
|
|
507
|
+
fail_threshold_type: Optional[FailThresholdInputType],
|
|
508
|
+
fail_threshold_value: Optional[int],
|
|
509
|
+
exclude_nulls: Optional[bool],
|
|
510
|
+
urn: Union[str, AssertionUrn],
|
|
511
|
+
display_name: Optional[str],
|
|
512
|
+
enabled: Optional[bool],
|
|
513
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
514
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
515
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
516
|
+
tags: Optional[TagsInputType],
|
|
517
|
+
now_utc: datetime,
|
|
518
|
+
assertion_input: _ColumnValueAssertionInput,
|
|
519
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
520
|
+
maybe_monitor_entity: Optional[Monitor],
|
|
521
|
+
existing_assertion: ColumnValueAssertion,
|
|
522
|
+
gms_criteria_type_info: Optional[tuple] = None,
|
|
523
|
+
) -> _ColumnValueAssertionInput:
|
|
524
|
+
"""Merge the input with the existing assertion and monitor entities."""
|
|
525
|
+
merged_assertion_input = _ColumnValueAssertionInput(
|
|
526
|
+
urn=urn,
|
|
527
|
+
entity_client=assertion_input.entity_client,
|
|
528
|
+
dataset_urn=dataset_urn,
|
|
529
|
+
column_name=column_name,
|
|
530
|
+
operator=operator,
|
|
531
|
+
criteria_parameters=criteria_parameters,
|
|
532
|
+
transform=_merge_field(
|
|
533
|
+
transform,
|
|
534
|
+
"transform",
|
|
535
|
+
assertion_input,
|
|
536
|
+
existing_assertion,
|
|
537
|
+
existing_assertion.transform if existing_assertion else None,
|
|
538
|
+
),
|
|
539
|
+
fail_threshold_type=_merge_field(
|
|
540
|
+
fail_threshold_type,
|
|
541
|
+
"fail_threshold_type",
|
|
542
|
+
assertion_input,
|
|
543
|
+
existing_assertion,
|
|
544
|
+
existing_assertion.fail_threshold_type if existing_assertion else None,
|
|
545
|
+
),
|
|
546
|
+
fail_threshold_value=_merge_field(
|
|
547
|
+
fail_threshold_value,
|
|
548
|
+
"fail_threshold_value",
|
|
549
|
+
assertion_input,
|
|
550
|
+
existing_assertion,
|
|
551
|
+
existing_assertion.fail_threshold_value if existing_assertion else 0,
|
|
552
|
+
),
|
|
553
|
+
exclude_nulls=_merge_field(
|
|
554
|
+
exclude_nulls,
|
|
555
|
+
"exclude_nulls",
|
|
556
|
+
assertion_input,
|
|
557
|
+
existing_assertion,
|
|
558
|
+
existing_assertion.exclude_nulls if existing_assertion else True,
|
|
559
|
+
),
|
|
560
|
+
display_name=_merge_field(
|
|
561
|
+
display_name,
|
|
562
|
+
"display_name",
|
|
563
|
+
assertion_input,
|
|
564
|
+
existing_assertion,
|
|
565
|
+
maybe_assertion_entity.description if maybe_assertion_entity else None,
|
|
566
|
+
),
|
|
567
|
+
enabled=_merge_field(
|
|
568
|
+
enabled,
|
|
569
|
+
"enabled",
|
|
570
|
+
assertion_input,
|
|
571
|
+
existing_assertion,
|
|
572
|
+
existing_assertion.mode == AssertionMode.ACTIVE
|
|
573
|
+
if existing_assertion
|
|
574
|
+
else None,
|
|
575
|
+
),
|
|
576
|
+
schedule=_merge_field(
|
|
577
|
+
schedule,
|
|
578
|
+
"schedule",
|
|
579
|
+
assertion_input,
|
|
580
|
+
existing_assertion,
|
|
581
|
+
existing_assertion.schedule if existing_assertion else None,
|
|
582
|
+
),
|
|
583
|
+
detection_mechanism=_merge_field(
|
|
584
|
+
detection_mechanism,
|
|
585
|
+
"detection_mechanism",
|
|
586
|
+
assertion_input,
|
|
587
|
+
existing_assertion,
|
|
588
|
+
ColumnValueAssertion._get_detection_mechanism(
|
|
589
|
+
maybe_assertion_entity, maybe_monitor_entity, default=None
|
|
590
|
+
)
|
|
591
|
+
if maybe_assertion_entity and maybe_monitor_entity
|
|
592
|
+
else None,
|
|
593
|
+
),
|
|
594
|
+
incident_behavior=_merge_field(
|
|
595
|
+
incident_behavior,
|
|
596
|
+
"incident_behavior",
|
|
597
|
+
assertion_input,
|
|
598
|
+
existing_assertion,
|
|
599
|
+
ColumnValueAssertion._get_incident_behavior(maybe_assertion_entity)
|
|
600
|
+
if maybe_assertion_entity
|
|
601
|
+
else None,
|
|
602
|
+
),
|
|
603
|
+
tags=_merge_field(
|
|
604
|
+
tags,
|
|
605
|
+
"tags",
|
|
606
|
+
assertion_input,
|
|
607
|
+
existing_assertion,
|
|
608
|
+
maybe_assertion_entity.tags if maybe_assertion_entity else None,
|
|
609
|
+
),
|
|
610
|
+
created_by=existing_assertion.created_by or DEFAULT_CREATED_BY,
|
|
611
|
+
created_at=existing_assertion.created_at or now_utc,
|
|
612
|
+
updated_by=assertion_input.updated_by,
|
|
613
|
+
updated_at=assertion_input.updated_at,
|
|
614
|
+
gms_criteria_type_info=gms_criteria_type_info,
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
return merged_assertion_input
|