acryl-datahub-cloud 0.3.11rc0__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/models.py +5 -3
- acryl_datahub_cloud/action_request/action_request_owner_source.py +36 -6
- 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 +37 -13
- acryl_datahub_cloud/datahub_reporting/datahub_form_reporting.py +55 -24
- acryl_datahub_cloud/datahub_reporting/extract_graph.py +4 -3
- acryl_datahub_cloud/datahub_reporting/extract_sql.py +242 -51
- 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 +518 -77
- 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 +2296 -1900
- 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 +4 -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 +12 -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/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 +25091 -20557
- acryl_datahub_cloud/metadata/schema_classes.py +29269 -23863
- 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 +353 -215
- 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 +166 -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/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/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/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/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 +418 -97
- acryl_datahub_cloud/metadata/schemas/MetadataChangeLog.avsc +62 -44
- acryl_datahub_cloud/metadata/schemas/MetadataChangeProposal.avsc +61 -0
- acryl_datahub_cloud/metadata/schemas/MonitorAnomalyEvent.avsc +54 -9
- acryl_datahub_cloud/metadata/schemas/MonitorInfo.avsc +163 -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/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 +61 -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/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.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/METADATA +55 -49
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/RECORD +235 -142
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/WHEEL +1 -1
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/entry_points.txt +1 -0
- acryl_datahub_cloud/_sdk_extras/__init__.py +0 -4
- acryl_datahub_cloud/_sdk_extras/assertion.py +0 -15
- acryl_datahub_cloud/_sdk_extras/assertions_client.py +0 -23
- {acryl_datahub_cloud-0.3.11rc0.dist-info → acryl_datahub_cloud-0.3.16.1rc0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from typing import TYPE_CHECKING, Optional, Union
|
|
6
|
+
|
|
7
|
+
from acryl_datahub_cloud.sdk.assertion.assertion_base import (
|
|
8
|
+
AssertionMode,
|
|
9
|
+
_HasColumnMetricFunctionality,
|
|
10
|
+
)
|
|
11
|
+
from acryl_datahub_cloud.sdk.assertion.column_metric_assertion import (
|
|
12
|
+
ColumnMetricAssertion,
|
|
13
|
+
)
|
|
14
|
+
from acryl_datahub_cloud.sdk.assertion_client.helpers import (
|
|
15
|
+
DEFAULT_CREATED_BY,
|
|
16
|
+
_merge_field,
|
|
17
|
+
_validate_required_field,
|
|
18
|
+
retrieve_assertion_and_monitor_by_urn,
|
|
19
|
+
)
|
|
20
|
+
from acryl_datahub_cloud.sdk.assertion_input.assertion_input import (
|
|
21
|
+
AssertionIncidentBehaviorInputTypes,
|
|
22
|
+
DetectionMechanismInputTypes,
|
|
23
|
+
)
|
|
24
|
+
from acryl_datahub_cloud.sdk.assertion_input.column_metric_assertion_input import (
|
|
25
|
+
ColumnMetricAssertionParameters,
|
|
26
|
+
_ColumnMetricAssertionInput,
|
|
27
|
+
)
|
|
28
|
+
from acryl_datahub_cloud.sdk.assertion_input.column_metric_constants import (
|
|
29
|
+
MetricInputType,
|
|
30
|
+
OperatorInputType,
|
|
31
|
+
)
|
|
32
|
+
from acryl_datahub_cloud.sdk.entities.assertion import Assertion, TagsInputType
|
|
33
|
+
from acryl_datahub_cloud.sdk.entities.monitor import Monitor
|
|
34
|
+
from acryl_datahub_cloud.sdk.errors import SDKUsageError
|
|
35
|
+
from datahub.metadata import schema_classes as models
|
|
36
|
+
from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn, MonitorUrn
|
|
37
|
+
|
|
38
|
+
if TYPE_CHECKING:
|
|
39
|
+
from datahub.sdk.main_client import DataHubClient
|
|
40
|
+
|
|
41
|
+
logger = logging.getLogger(__name__)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class ColumnMetricAssertionClient:
|
|
45
|
+
"""Client for managing column metric assertions."""
|
|
46
|
+
|
|
47
|
+
def __init__(self, client: "DataHubClient"):
|
|
48
|
+
self.client = client
|
|
49
|
+
|
|
50
|
+
def _validate_required_column_fields_for_creation(
|
|
51
|
+
self,
|
|
52
|
+
column_name: Optional[str],
|
|
53
|
+
metric_type: Optional[MetricInputType],
|
|
54
|
+
operator: Optional[OperatorInputType],
|
|
55
|
+
) -> None:
|
|
56
|
+
"""Validate required fields for column metric assertion creation."""
|
|
57
|
+
_validate_required_field(
|
|
58
|
+
column_name, "column_name", "when creating a new assertion (urn is None)"
|
|
59
|
+
)
|
|
60
|
+
_validate_required_field(
|
|
61
|
+
metric_type, "metric_type", "when creating a new assertion (urn is None)"
|
|
62
|
+
)
|
|
63
|
+
_validate_required_field(
|
|
64
|
+
operator, "operator", "when creating a new assertion (urn is None)"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
def _validate_required_column_fields_for_update(
|
|
68
|
+
self,
|
|
69
|
+
column_name: Optional[str],
|
|
70
|
+
metric_type: Optional[MetricInputType],
|
|
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 = f"and not found in existing assertion {assertion_urn}. The existing assertion may be invalid or corrupted."
|
|
76
|
+
_validate_required_field(column_name, "column_name", context)
|
|
77
|
+
_validate_required_field(metric_type, "metric_type", context)
|
|
78
|
+
_validate_required_field(operator, "operator", context)
|
|
79
|
+
|
|
80
|
+
def _retrieve_assertion_and_monitor(
|
|
81
|
+
self,
|
|
82
|
+
urn: Union[str, AssertionUrn],
|
|
83
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
84
|
+
) -> tuple[Optional[Assertion], MonitorUrn, Optional[Monitor]]:
|
|
85
|
+
"""Retrieve the assertion and monitor entities from the DataHub instance.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
urn: The assertion URN.
|
|
89
|
+
dataset_urn: The dataset URN.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
The assertion and monitor entities.
|
|
93
|
+
"""
|
|
94
|
+
return retrieve_assertion_and_monitor_by_urn(self.client, urn, dataset_urn)
|
|
95
|
+
|
|
96
|
+
def sync_column_metric_assertion(
|
|
97
|
+
self,
|
|
98
|
+
*,
|
|
99
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
100
|
+
column_name: Optional[str] = None,
|
|
101
|
+
metric_type: Optional[MetricInputType] = None,
|
|
102
|
+
operator: Optional[OperatorInputType] = None,
|
|
103
|
+
criteria_parameters: Optional[ColumnMetricAssertionParameters] = None,
|
|
104
|
+
urn: Optional[Union[str, AssertionUrn]] = None,
|
|
105
|
+
display_name: Optional[str] = None,
|
|
106
|
+
enabled: Optional[bool] = None,
|
|
107
|
+
detection_mechanism: DetectionMechanismInputTypes = None,
|
|
108
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
|
|
109
|
+
tags: Optional[TagsInputType] = None,
|
|
110
|
+
updated_by: Optional[Union[str, CorpUserUrn]] = None,
|
|
111
|
+
schedule: Optional[Union[str, models.CronScheduleClass]] = None,
|
|
112
|
+
) -> ColumnMetricAssertion:
|
|
113
|
+
now_utc = datetime.now(timezone.utc)
|
|
114
|
+
|
|
115
|
+
if updated_by is None:
|
|
116
|
+
logger.warning(
|
|
117
|
+
f"updated_by is not set, using {DEFAULT_CREATED_BY} as a placeholder"
|
|
118
|
+
)
|
|
119
|
+
updated_by = DEFAULT_CREATED_BY
|
|
120
|
+
|
|
121
|
+
# 1. Retrieve and merge the assertion input with any existing assertion and monitor entities,
|
|
122
|
+
# or build a new assertion input if the assertion does not exist:
|
|
123
|
+
assertion_input = self._retrieve_and_merge_column_metric_assertion_and_monitor(
|
|
124
|
+
dataset_urn=dataset_urn,
|
|
125
|
+
urn=urn,
|
|
126
|
+
column_name=column_name,
|
|
127
|
+
metric_type=metric_type,
|
|
128
|
+
operator=operator,
|
|
129
|
+
criteria_parameters=criteria_parameters,
|
|
130
|
+
display_name=display_name,
|
|
131
|
+
enabled=enabled,
|
|
132
|
+
detection_mechanism=detection_mechanism,
|
|
133
|
+
incident_behavior=incident_behavior,
|
|
134
|
+
tags=tags,
|
|
135
|
+
updated_by=updated_by,
|
|
136
|
+
now_utc=now_utc,
|
|
137
|
+
schedule=schedule,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# 2. Upsert the assertion and monitor entities:
|
|
141
|
+
assertion_entity, monitor_entity = (
|
|
142
|
+
assertion_input.to_assertion_and_monitor_entities()
|
|
143
|
+
)
|
|
144
|
+
# If assertion upsert fails, we won't try to upsert the monitor
|
|
145
|
+
self.client.entities.upsert(assertion_entity)
|
|
146
|
+
# TODO: Wrap monitor upsert in a try-except and delete the assertion if monitor upsert fails (once delete is implemented https://linear.app/acryl-data/issue/OBS-1350/add-delete-method-to-entity-clientpy)
|
|
147
|
+
# try:
|
|
148
|
+
self.client.entities.upsert(monitor_entity)
|
|
149
|
+
# except Exception as e:
|
|
150
|
+
# logger.error(f"Error upserting monitor: {e}")
|
|
151
|
+
# self.client.entities.delete(assertion_entity)
|
|
152
|
+
# raise e
|
|
153
|
+
|
|
154
|
+
return ColumnMetricAssertion._from_entities(assertion_entity, monitor_entity)
|
|
155
|
+
|
|
156
|
+
def _extract_fields_from_existing_assertion(
|
|
157
|
+
self,
|
|
158
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
159
|
+
column_name: Optional[str],
|
|
160
|
+
metric_type: Optional[MetricInputType],
|
|
161
|
+
operator: Optional[OperatorInputType],
|
|
162
|
+
criteria_parameters: Optional[ColumnMetricAssertionParameters],
|
|
163
|
+
) -> tuple[
|
|
164
|
+
Optional[str],
|
|
165
|
+
Optional[MetricInputType],
|
|
166
|
+
Optional[OperatorInputType],
|
|
167
|
+
Optional[ColumnMetricAssertionParameters],
|
|
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
|
+
metric_type,
|
|
177
|
+
operator,
|
|
178
|
+
criteria_parameters,
|
|
179
|
+
gms_criteria_type_info,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
assertion_info = maybe_assertion_entity.info
|
|
183
|
+
if (
|
|
184
|
+
hasattr(assertion_info, "fieldMetricAssertion")
|
|
185
|
+
and assertion_info.fieldMetricAssertion
|
|
186
|
+
):
|
|
187
|
+
field_metric_assertion = assertion_info.fieldMetricAssertion
|
|
188
|
+
|
|
189
|
+
# Extract column_name
|
|
190
|
+
if (
|
|
191
|
+
column_name is None
|
|
192
|
+
and hasattr(field_metric_assertion, "field")
|
|
193
|
+
and hasattr(field_metric_assertion.field, "path")
|
|
194
|
+
):
|
|
195
|
+
column_name = field_metric_assertion.field.path
|
|
196
|
+
|
|
197
|
+
# Extract metric_type
|
|
198
|
+
if metric_type is None and hasattr(field_metric_assertion, "metric"):
|
|
199
|
+
metric_type = field_metric_assertion.metric
|
|
200
|
+
|
|
201
|
+
# Extract operator
|
|
202
|
+
if operator is None and hasattr(field_metric_assertion, "operator"):
|
|
203
|
+
operator = field_metric_assertion.operator
|
|
204
|
+
|
|
205
|
+
# Extract criteria_parameters
|
|
206
|
+
if criteria_parameters is None and hasattr(
|
|
207
|
+
field_metric_assertion, "parameters"
|
|
208
|
+
):
|
|
209
|
+
params = field_metric_assertion.parameters
|
|
210
|
+
if params and hasattr(params, "value") and params.value:
|
|
211
|
+
criteria_parameters = params.value.value
|
|
212
|
+
elif (
|
|
213
|
+
params
|
|
214
|
+
and hasattr(params, "minValue")
|
|
215
|
+
and hasattr(params, "maxValue")
|
|
216
|
+
and params.minValue
|
|
217
|
+
and params.maxValue
|
|
218
|
+
):
|
|
219
|
+
criteria_parameters = (params.minValue.value, params.maxValue.value)
|
|
220
|
+
|
|
221
|
+
# Extract gms_criteria_type_info (outside the fieldMetricAssertion check)
|
|
222
|
+
gms_criteria_type_info = (
|
|
223
|
+
_HasColumnMetricFunctionality._get_criteria_parameters_with_type(
|
|
224
|
+
maybe_assertion_entity
|
|
225
|
+
)
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
column_name,
|
|
230
|
+
metric_type,
|
|
231
|
+
operator,
|
|
232
|
+
criteria_parameters,
|
|
233
|
+
gms_criteria_type_info,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
def _create_existing_assertion_from_entities(
|
|
237
|
+
self,
|
|
238
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
239
|
+
maybe_monitor_entity: Optional[Monitor],
|
|
240
|
+
monitor_urn: MonitorUrn,
|
|
241
|
+
enabled: Optional[bool],
|
|
242
|
+
) -> Optional[ColumnMetricAssertion]:
|
|
243
|
+
"""Create existing assertion object from entities, handling missing monitor case."""
|
|
244
|
+
if maybe_assertion_entity and maybe_monitor_entity:
|
|
245
|
+
return ColumnMetricAssertion._from_entities(
|
|
246
|
+
maybe_assertion_entity, maybe_monitor_entity
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
if maybe_assertion_entity and not maybe_monitor_entity:
|
|
250
|
+
monitor_mode = (
|
|
251
|
+
"ACTIVE" if enabled else "INACTIVE" if enabled is not None else "ACTIVE"
|
|
252
|
+
)
|
|
253
|
+
return ColumnMetricAssertion._from_entities(
|
|
254
|
+
maybe_assertion_entity,
|
|
255
|
+
Monitor(id=monitor_urn, info=("ASSERTION", monitor_mode)),
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
return None
|
|
259
|
+
|
|
260
|
+
def _retrieve_and_merge_column_metric_assertion_and_monitor(
|
|
261
|
+
self,
|
|
262
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
263
|
+
urn: Optional[Union[str, AssertionUrn]],
|
|
264
|
+
column_name: Optional[str],
|
|
265
|
+
metric_type: Optional[MetricInputType],
|
|
266
|
+
operator: Optional[OperatorInputType],
|
|
267
|
+
criteria_parameters: Optional[ColumnMetricAssertionParameters],
|
|
268
|
+
display_name: Optional[str],
|
|
269
|
+
enabled: Optional[bool],
|
|
270
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
271
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
272
|
+
tags: Optional[TagsInputType],
|
|
273
|
+
updated_by: Union[str, CorpUserUrn],
|
|
274
|
+
now_utc: datetime,
|
|
275
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
276
|
+
) -> _ColumnMetricAssertionInput:
|
|
277
|
+
# 1. If urn is not provided, validate required fields and build a new assertion input directly
|
|
278
|
+
if urn is None:
|
|
279
|
+
logger.info("URN is not set, building a new assertion input")
|
|
280
|
+
self._validate_required_column_fields_for_creation(
|
|
281
|
+
column_name, metric_type, operator
|
|
282
|
+
)
|
|
283
|
+
assert (
|
|
284
|
+
column_name is not None
|
|
285
|
+
and metric_type is not None
|
|
286
|
+
and operator is not None
|
|
287
|
+
), "Fields guaranteed non-None after validation"
|
|
288
|
+
return _ColumnMetricAssertionInput(
|
|
289
|
+
urn=None,
|
|
290
|
+
entity_client=self.client.entities,
|
|
291
|
+
dataset_urn=dataset_urn,
|
|
292
|
+
column_name=column_name,
|
|
293
|
+
metric_type=metric_type,
|
|
294
|
+
operator=operator,
|
|
295
|
+
criteria_parameters=criteria_parameters,
|
|
296
|
+
display_name=display_name,
|
|
297
|
+
enabled=enabled if enabled is not None else True,
|
|
298
|
+
detection_mechanism=detection_mechanism,
|
|
299
|
+
incident_behavior=incident_behavior,
|
|
300
|
+
tags=tags,
|
|
301
|
+
created_by=updated_by,
|
|
302
|
+
created_at=now_utc,
|
|
303
|
+
updated_by=updated_by,
|
|
304
|
+
updated_at=now_utc,
|
|
305
|
+
schedule=schedule,
|
|
306
|
+
gms_criteria_type_info=None,
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
# 2. Retrieve any existing assertion and monitor entities
|
|
310
|
+
maybe_assertion_entity, monitor_urn, maybe_monitor_entity = (
|
|
311
|
+
self._retrieve_assertion_and_monitor(urn, dataset_urn)
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
# 3. Extract missing required fields and gms_criteria_type_info from existing assertion
|
|
315
|
+
(
|
|
316
|
+
column_name,
|
|
317
|
+
metric_type,
|
|
318
|
+
operator,
|
|
319
|
+
criteria_parameters,
|
|
320
|
+
gms_criteria_type_info,
|
|
321
|
+
) = self._extract_fields_from_existing_assertion(
|
|
322
|
+
maybe_assertion_entity,
|
|
323
|
+
column_name,
|
|
324
|
+
metric_type,
|
|
325
|
+
operator,
|
|
326
|
+
criteria_parameters,
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
# 4. Validate required fields
|
|
330
|
+
if maybe_assertion_entity is None:
|
|
331
|
+
self._validate_required_column_fields_for_creation(
|
|
332
|
+
column_name, metric_type, operator
|
|
333
|
+
)
|
|
334
|
+
else:
|
|
335
|
+
self._validate_required_column_fields_for_update(
|
|
336
|
+
column_name, metric_type, operator, urn
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
assert (
|
|
340
|
+
column_name is not None and metric_type is not None and operator is not None
|
|
341
|
+
), "Fields guaranteed non-None after validation"
|
|
342
|
+
|
|
343
|
+
# 5. If the assertion does not exist, build and return a new assertion input
|
|
344
|
+
if not maybe_assertion_entity:
|
|
345
|
+
logger.info(
|
|
346
|
+
f"No existing assertion entity found for assertion urn {urn}, building a new assertion input"
|
|
347
|
+
)
|
|
348
|
+
return _ColumnMetricAssertionInput(
|
|
349
|
+
urn=urn,
|
|
350
|
+
entity_client=self.client.entities,
|
|
351
|
+
dataset_urn=dataset_urn,
|
|
352
|
+
column_name=column_name,
|
|
353
|
+
metric_type=metric_type,
|
|
354
|
+
operator=operator,
|
|
355
|
+
criteria_parameters=criteria_parameters,
|
|
356
|
+
display_name=display_name,
|
|
357
|
+
enabled=enabled if enabled is not None else True,
|
|
358
|
+
detection_mechanism=detection_mechanism,
|
|
359
|
+
incident_behavior=incident_behavior,
|
|
360
|
+
tags=tags,
|
|
361
|
+
created_by=updated_by,
|
|
362
|
+
created_at=now_utc,
|
|
363
|
+
updated_by=updated_by,
|
|
364
|
+
updated_at=now_utc,
|
|
365
|
+
schedule=schedule,
|
|
366
|
+
gms_criteria_type_info=None,
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
# 6. Build assertion input for validation
|
|
370
|
+
assertion_input = _ColumnMetricAssertionInput(
|
|
371
|
+
urn=urn,
|
|
372
|
+
entity_client=self.client.entities,
|
|
373
|
+
dataset_urn=dataset_urn,
|
|
374
|
+
column_name=column_name,
|
|
375
|
+
metric_type=metric_type,
|
|
376
|
+
operator=operator,
|
|
377
|
+
criteria_parameters=criteria_parameters,
|
|
378
|
+
display_name=display_name,
|
|
379
|
+
detection_mechanism=detection_mechanism,
|
|
380
|
+
incident_behavior=incident_behavior,
|
|
381
|
+
tags=tags,
|
|
382
|
+
created_by=updated_by,
|
|
383
|
+
created_at=now_utc,
|
|
384
|
+
updated_by=updated_by,
|
|
385
|
+
updated_at=now_utc,
|
|
386
|
+
schedule=schedule,
|
|
387
|
+
gms_criteria_type_info=gms_criteria_type_info,
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
# 7. Create existing assertion from entities
|
|
391
|
+
existing_assertion = self._create_existing_assertion_from_entities(
|
|
392
|
+
maybe_assertion_entity, maybe_monitor_entity, monitor_urn, enabled
|
|
393
|
+
)
|
|
394
|
+
assert existing_assertion is not None, (
|
|
395
|
+
"existing_assertion is guaranteed non-None after early return check"
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
# 8. Check for any issues e.g. different dataset urns
|
|
399
|
+
if (
|
|
400
|
+
existing_assertion
|
|
401
|
+
and hasattr(existing_assertion, "dataset_urn")
|
|
402
|
+
and existing_assertion.dataset_urn != assertion_input.dataset_urn
|
|
403
|
+
):
|
|
404
|
+
raise SDKUsageError(
|
|
405
|
+
f"Dataset URN mismatch, existing assertion: {existing_assertion.dataset_urn} != new assertion: {dataset_urn}"
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
# 9. Merge the existing assertion with the validated input
|
|
409
|
+
merged_assertion_input = self._merge_column_metric_input(
|
|
410
|
+
dataset_urn=dataset_urn,
|
|
411
|
+
column_name=column_name,
|
|
412
|
+
metric_type=metric_type,
|
|
413
|
+
operator=operator,
|
|
414
|
+
criteria_parameters=criteria_parameters,
|
|
415
|
+
urn=urn,
|
|
416
|
+
display_name=display_name,
|
|
417
|
+
enabled=enabled,
|
|
418
|
+
schedule=schedule,
|
|
419
|
+
detection_mechanism=detection_mechanism,
|
|
420
|
+
incident_behavior=incident_behavior,
|
|
421
|
+
tags=tags,
|
|
422
|
+
now_utc=now_utc,
|
|
423
|
+
assertion_input=assertion_input,
|
|
424
|
+
maybe_assertion_entity=maybe_assertion_entity,
|
|
425
|
+
maybe_monitor_entity=maybe_monitor_entity,
|
|
426
|
+
existing_assertion=existing_assertion,
|
|
427
|
+
gms_criteria_type_info=gms_criteria_type_info,
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
return merged_assertion_input
|
|
431
|
+
|
|
432
|
+
def _merge_column_metric_input(
|
|
433
|
+
self,
|
|
434
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
435
|
+
column_name: str,
|
|
436
|
+
metric_type: MetricInputType,
|
|
437
|
+
operator: OperatorInputType,
|
|
438
|
+
criteria_parameters: Optional[ColumnMetricAssertionParameters],
|
|
439
|
+
urn: Union[str, AssertionUrn],
|
|
440
|
+
display_name: Optional[str],
|
|
441
|
+
enabled: Optional[bool],
|
|
442
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
443
|
+
detection_mechanism: DetectionMechanismInputTypes,
|
|
444
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
445
|
+
tags: Optional[TagsInputType],
|
|
446
|
+
now_utc: datetime,
|
|
447
|
+
assertion_input: _ColumnMetricAssertionInput,
|
|
448
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
449
|
+
maybe_monitor_entity: Optional[Monitor],
|
|
450
|
+
existing_assertion: ColumnMetricAssertion,
|
|
451
|
+
gms_criteria_type_info: Optional[tuple] = None,
|
|
452
|
+
) -> _ColumnMetricAssertionInput:
|
|
453
|
+
"""Merge the input with the existing assertion and monitor entities.
|
|
454
|
+
|
|
455
|
+
Args:
|
|
456
|
+
dataset_urn: The urn of the dataset to be monitored.
|
|
457
|
+
column_name: The name of the column to be monitored.
|
|
458
|
+
metric_type: The type of the metric to be monitored.
|
|
459
|
+
operator: The operator to be used for the assertion.
|
|
460
|
+
criteria_parameters: The criteria parameters for the assertion.
|
|
461
|
+
urn: The urn of the assertion.
|
|
462
|
+
display_name: The display name of the assertion.
|
|
463
|
+
enabled: Whether the assertion is enabled.
|
|
464
|
+
schedule: The schedule to be applied to the assertion.
|
|
465
|
+
detection_mechanism: The detection mechanism to be used for the assertion.
|
|
466
|
+
incident_behavior: The incident behavior to be applied to the assertion.
|
|
467
|
+
tags: The tags to be applied to the assertion.
|
|
468
|
+
now_utc: The current UTC time from when the function is called.
|
|
469
|
+
assertion_input: The validated input to the function.
|
|
470
|
+
maybe_assertion_entity: The existing assertion entity from the DataHub instance.
|
|
471
|
+
maybe_monitor_entity: The existing monitor entity from the DataHub instance.
|
|
472
|
+
existing_assertion: The existing assertion from the DataHub instance.
|
|
473
|
+
gms_criteria_type_info: The criteria type info from the existing assertion.
|
|
474
|
+
|
|
475
|
+
Returns:
|
|
476
|
+
The merged assertion input.
|
|
477
|
+
"""
|
|
478
|
+
merged_assertion_input = _ColumnMetricAssertionInput(
|
|
479
|
+
urn=urn,
|
|
480
|
+
entity_client=assertion_input.entity_client,
|
|
481
|
+
dataset_urn=dataset_urn,
|
|
482
|
+
column_name=column_name,
|
|
483
|
+
metric_type=metric_type,
|
|
484
|
+
operator=operator,
|
|
485
|
+
criteria_parameters=criteria_parameters,
|
|
486
|
+
display_name=_merge_field(
|
|
487
|
+
display_name,
|
|
488
|
+
"display_name",
|
|
489
|
+
assertion_input,
|
|
490
|
+
existing_assertion,
|
|
491
|
+
maybe_assertion_entity.description if maybe_assertion_entity else None,
|
|
492
|
+
),
|
|
493
|
+
enabled=_merge_field(
|
|
494
|
+
enabled,
|
|
495
|
+
"enabled",
|
|
496
|
+
assertion_input,
|
|
497
|
+
existing_assertion,
|
|
498
|
+
existing_assertion.mode == AssertionMode.ACTIVE
|
|
499
|
+
if existing_assertion
|
|
500
|
+
else None,
|
|
501
|
+
),
|
|
502
|
+
schedule=_merge_field(
|
|
503
|
+
schedule,
|
|
504
|
+
"schedule",
|
|
505
|
+
assertion_input,
|
|
506
|
+
existing_assertion,
|
|
507
|
+
existing_assertion.schedule if existing_assertion else None,
|
|
508
|
+
),
|
|
509
|
+
detection_mechanism=_merge_field(
|
|
510
|
+
detection_mechanism,
|
|
511
|
+
"detection_mechanism",
|
|
512
|
+
assertion_input,
|
|
513
|
+
existing_assertion,
|
|
514
|
+
ColumnMetricAssertion._get_detection_mechanism(
|
|
515
|
+
maybe_assertion_entity, maybe_monitor_entity, default=None
|
|
516
|
+
)
|
|
517
|
+
if maybe_assertion_entity and maybe_monitor_entity
|
|
518
|
+
else None,
|
|
519
|
+
),
|
|
520
|
+
incident_behavior=_merge_field(
|
|
521
|
+
incident_behavior,
|
|
522
|
+
"incident_behavior",
|
|
523
|
+
assertion_input,
|
|
524
|
+
existing_assertion,
|
|
525
|
+
ColumnMetricAssertion._get_incident_behavior(maybe_assertion_entity)
|
|
526
|
+
if maybe_assertion_entity
|
|
527
|
+
else None,
|
|
528
|
+
),
|
|
529
|
+
tags=_merge_field(
|
|
530
|
+
tags,
|
|
531
|
+
"tags",
|
|
532
|
+
assertion_input,
|
|
533
|
+
existing_assertion,
|
|
534
|
+
maybe_assertion_entity.tags if maybe_assertion_entity else None,
|
|
535
|
+
),
|
|
536
|
+
created_by=existing_assertion.created_by
|
|
537
|
+
or DEFAULT_CREATED_BY, # Override with the existing assertion's created_by or the default created_by if not set
|
|
538
|
+
created_at=existing_assertion.created_at
|
|
539
|
+
or now_utc, # Override with the existing assertion's created_at or now if not set
|
|
540
|
+
updated_by=assertion_input.updated_by, # Override with the input's updated_by
|
|
541
|
+
updated_at=assertion_input.updated_at, # Override with the input's updated_at (now)
|
|
542
|
+
gms_criteria_type_info=gms_criteria_type_info,
|
|
543
|
+
)
|
|
544
|
+
|
|
545
|
+
return merged_assertion_input
|