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,358 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Schema assertion client module.
|
|
3
|
+
|
|
4
|
+
This module provides the SchemaAssertionClient for creating and managing
|
|
5
|
+
schema assertions that validate dataset schemas match expected field definitions.
|
|
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.schema_assertion import SchemaAssertion
|
|
16
|
+
from acryl_datahub_cloud.sdk.assertion_client.helpers import (
|
|
17
|
+
DEFAULT_CREATED_BY,
|
|
18
|
+
_merge_field,
|
|
19
|
+
_print_experimental_warning,
|
|
20
|
+
_validate_required_field,
|
|
21
|
+
retrieve_assertion_and_monitor_by_urn,
|
|
22
|
+
)
|
|
23
|
+
from acryl_datahub_cloud.sdk.assertion_input.assertion_input import (
|
|
24
|
+
AssertionIncidentBehaviorInputTypes,
|
|
25
|
+
)
|
|
26
|
+
from acryl_datahub_cloud.sdk.assertion_input.schema_assertion_input import (
|
|
27
|
+
SchemaAssertionCompatibility,
|
|
28
|
+
SchemaAssertionField,
|
|
29
|
+
SchemaAssertionFieldsInputType,
|
|
30
|
+
_parse_schema_assertion_fields,
|
|
31
|
+
_SchemaAssertionInput,
|
|
32
|
+
)
|
|
33
|
+
from acryl_datahub_cloud.sdk.entities.assertion import Assertion, TagsInputType
|
|
34
|
+
from acryl_datahub_cloud.sdk.entities.monitor import Monitor
|
|
35
|
+
from acryl_datahub_cloud.sdk.errors import SDKUsageError
|
|
36
|
+
from datahub.metadata import schema_classes as models
|
|
37
|
+
from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn, MonitorUrn
|
|
38
|
+
|
|
39
|
+
if TYPE_CHECKING:
|
|
40
|
+
from datahub.sdk.main_client import DataHubClient
|
|
41
|
+
|
|
42
|
+
logger = logging.getLogger(__name__)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class SchemaAssertionClient:
|
|
46
|
+
"""Client for managing schema assertions."""
|
|
47
|
+
|
|
48
|
+
def __init__(self, client: "DataHubClient"):
|
|
49
|
+
self.client = client
|
|
50
|
+
|
|
51
|
+
def sync_schema_assertion(
|
|
52
|
+
self,
|
|
53
|
+
*,
|
|
54
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
55
|
+
urn: Optional[Union[str, AssertionUrn]] = None,
|
|
56
|
+
display_name: Optional[str] = None,
|
|
57
|
+
enabled: Optional[bool] = None,
|
|
58
|
+
compatibility: Optional[Union[str, SchemaAssertionCompatibility]] = None,
|
|
59
|
+
fields: Optional[SchemaAssertionFieldsInputType] = None,
|
|
60
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
|
|
61
|
+
tags: Optional[TagsInputType] = None,
|
|
62
|
+
updated_by: Optional[Union[str, CorpUserUrn]] = None,
|
|
63
|
+
schedule: Optional[Union[str, models.CronScheduleClass]] = None,
|
|
64
|
+
) -> SchemaAssertion:
|
|
65
|
+
_print_experimental_warning()
|
|
66
|
+
now_utc = datetime.now(timezone.utc)
|
|
67
|
+
|
|
68
|
+
if updated_by is None:
|
|
69
|
+
logger.warning(
|
|
70
|
+
f"updated_by is not set, using {DEFAULT_CREATED_BY} as a placeholder"
|
|
71
|
+
)
|
|
72
|
+
updated_by = DEFAULT_CREATED_BY
|
|
73
|
+
|
|
74
|
+
# 1. Retrieve and merge the assertion input with any existing assertion and monitor entities,
|
|
75
|
+
# or build a new assertion input if the assertion does not exist:
|
|
76
|
+
assertion_input = self._retrieve_and_merge_schema_assertion_and_monitor(
|
|
77
|
+
dataset_urn=dataset_urn,
|
|
78
|
+
urn=urn,
|
|
79
|
+
display_name=display_name,
|
|
80
|
+
enabled=enabled,
|
|
81
|
+
compatibility=compatibility,
|
|
82
|
+
fields=fields,
|
|
83
|
+
incident_behavior=incident_behavior,
|
|
84
|
+
tags=tags,
|
|
85
|
+
updated_by=updated_by,
|
|
86
|
+
now_utc=now_utc,
|
|
87
|
+
schedule=schedule,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# 2. Upsert the assertion and monitor entities:
|
|
91
|
+
assertion_entity, monitor_entity = (
|
|
92
|
+
assertion_input.to_assertion_and_monitor_entities()
|
|
93
|
+
)
|
|
94
|
+
# If assertion upsert fails, we won't try to upsert the monitor
|
|
95
|
+
self.client.entities.upsert(assertion_entity)
|
|
96
|
+
self.client.entities.upsert(monitor_entity)
|
|
97
|
+
|
|
98
|
+
return SchemaAssertion._from_entities(assertion_entity, monitor_entity)
|
|
99
|
+
|
|
100
|
+
def _retrieve_and_merge_schema_assertion_and_monitor(
|
|
101
|
+
self,
|
|
102
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
103
|
+
urn: Optional[Union[str, AssertionUrn]],
|
|
104
|
+
display_name: Optional[str],
|
|
105
|
+
enabled: Optional[bool],
|
|
106
|
+
compatibility: Optional[Union[str, SchemaAssertionCompatibility]],
|
|
107
|
+
fields: Optional[SchemaAssertionFieldsInputType],
|
|
108
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
109
|
+
tags: Optional[TagsInputType],
|
|
110
|
+
updated_by: Union[str, CorpUserUrn],
|
|
111
|
+
now_utc: datetime,
|
|
112
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
113
|
+
) -> _SchemaAssertionInput:
|
|
114
|
+
"""Retrieve existing assertion if URN provided and merge with new values."""
|
|
115
|
+
# 1. If urn is not provided, build and return a new assertion input directly
|
|
116
|
+
if urn is None:
|
|
117
|
+
logger.info("URN is not set, building a new assertion input")
|
|
118
|
+
# For creation, fields is required
|
|
119
|
+
_validate_required_field(
|
|
120
|
+
fields, "fields", "when creating a new assertion (urn is None)"
|
|
121
|
+
)
|
|
122
|
+
return _SchemaAssertionInput(
|
|
123
|
+
urn=None,
|
|
124
|
+
entity_client=self.client.entities,
|
|
125
|
+
dataset_urn=dataset_urn,
|
|
126
|
+
display_name=display_name,
|
|
127
|
+
enabled=enabled if enabled is not None else True,
|
|
128
|
+
compatibility=compatibility,
|
|
129
|
+
fields=fields,
|
|
130
|
+
incident_behavior=incident_behavior,
|
|
131
|
+
tags=tags,
|
|
132
|
+
created_by=updated_by,
|
|
133
|
+
created_at=now_utc,
|
|
134
|
+
updated_by=updated_by,
|
|
135
|
+
updated_at=now_utc,
|
|
136
|
+
schedule=schedule,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# 2. Build initial assertion input for validation
|
|
140
|
+
assertion_input = _SchemaAssertionInput(
|
|
141
|
+
urn=urn,
|
|
142
|
+
entity_client=self.client.entities,
|
|
143
|
+
dataset_urn=dataset_urn,
|
|
144
|
+
display_name=display_name,
|
|
145
|
+
compatibility=compatibility,
|
|
146
|
+
fields=fields,
|
|
147
|
+
incident_behavior=incident_behavior,
|
|
148
|
+
tags=tags,
|
|
149
|
+
created_by=updated_by, # This will be overridden by the actual created_by
|
|
150
|
+
created_at=now_utc, # This will be overridden by the actual created_at
|
|
151
|
+
updated_by=updated_by,
|
|
152
|
+
updated_at=now_utc,
|
|
153
|
+
schedule=schedule,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# 3. Retrieve any existing assertion and monitor entities:
|
|
157
|
+
maybe_assertion_entity, monitor_urn, maybe_monitor_entity = (
|
|
158
|
+
self._retrieve_assertion_and_monitor(urn, dataset_urn)
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# 4.1 If the assertion and monitor entities exist, create an assertion object from them:
|
|
162
|
+
if maybe_assertion_entity and maybe_monitor_entity:
|
|
163
|
+
existing_assertion = SchemaAssertion._from_entities(
|
|
164
|
+
maybe_assertion_entity, maybe_monitor_entity
|
|
165
|
+
)
|
|
166
|
+
# 4.2 If the assertion exists but the monitor does not, create a placeholder monitor entity
|
|
167
|
+
elif maybe_assertion_entity and not maybe_monitor_entity:
|
|
168
|
+
monitor_mode = (
|
|
169
|
+
"ACTIVE" if enabled else "INACTIVE" if enabled is not None else "ACTIVE"
|
|
170
|
+
)
|
|
171
|
+
existing_assertion = SchemaAssertion._from_entities(
|
|
172
|
+
maybe_assertion_entity,
|
|
173
|
+
Monitor(id=monitor_urn, info=("ASSERTION", monitor_mode)),
|
|
174
|
+
)
|
|
175
|
+
# 4.3 If the assertion does not exist, build and return a new assertion input:
|
|
176
|
+
elif not maybe_assertion_entity:
|
|
177
|
+
logger.info(
|
|
178
|
+
f"No existing assertion entity found for assertion urn {urn}, building a new assertion input"
|
|
179
|
+
)
|
|
180
|
+
# For creation, fields is required
|
|
181
|
+
_validate_required_field(
|
|
182
|
+
fields,
|
|
183
|
+
"fields",
|
|
184
|
+
"when creating a new assertion (no existing assertion found)",
|
|
185
|
+
)
|
|
186
|
+
return _SchemaAssertionInput(
|
|
187
|
+
urn=urn,
|
|
188
|
+
entity_client=self.client.entities,
|
|
189
|
+
dataset_urn=dataset_urn,
|
|
190
|
+
display_name=display_name,
|
|
191
|
+
enabled=enabled if enabled is not None else True,
|
|
192
|
+
compatibility=compatibility,
|
|
193
|
+
fields=fields,
|
|
194
|
+
incident_behavior=incident_behavior,
|
|
195
|
+
tags=tags,
|
|
196
|
+
created_by=updated_by,
|
|
197
|
+
created_at=now_utc,
|
|
198
|
+
updated_by=updated_by,
|
|
199
|
+
updated_at=now_utc,
|
|
200
|
+
schedule=schedule,
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# 5. Validate that we have field definitions (either from input or existing assertion)
|
|
204
|
+
if fields is None and existing_assertion and not existing_assertion.fields:
|
|
205
|
+
raise SDKUsageError(
|
|
206
|
+
f"Cannot update assertion {urn}: existing assertion has no field definitions. "
|
|
207
|
+
"Please provide 'fields' parameter."
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
# 6. Check for any issues e.g. different dataset urns
|
|
211
|
+
if (
|
|
212
|
+
existing_assertion
|
|
213
|
+
and hasattr(existing_assertion, "dataset_urn")
|
|
214
|
+
and existing_assertion.dataset_urn != assertion_input.dataset_urn
|
|
215
|
+
):
|
|
216
|
+
raise SDKUsageError(
|
|
217
|
+
f"Dataset URN mismatch, existing assertion: {existing_assertion.dataset_urn} != new assertion: {dataset_urn}"
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
# 7. Merge the existing assertion with the validated input:
|
|
221
|
+
merged_assertion_input = self._merge_schema_input(
|
|
222
|
+
dataset_urn=dataset_urn,
|
|
223
|
+
urn=urn,
|
|
224
|
+
display_name=display_name,
|
|
225
|
+
enabled=enabled,
|
|
226
|
+
compatibility=compatibility,
|
|
227
|
+
fields=fields,
|
|
228
|
+
incident_behavior=incident_behavior,
|
|
229
|
+
tags=tags,
|
|
230
|
+
now_utc=now_utc,
|
|
231
|
+
assertion_input=assertion_input,
|
|
232
|
+
maybe_assertion_entity=maybe_assertion_entity,
|
|
233
|
+
maybe_monitor_entity=maybe_monitor_entity,
|
|
234
|
+
existing_assertion=existing_assertion,
|
|
235
|
+
schedule=schedule,
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
return merged_assertion_input
|
|
239
|
+
|
|
240
|
+
def _retrieve_assertion_and_monitor(
|
|
241
|
+
self,
|
|
242
|
+
urn: Union[str, AssertionUrn],
|
|
243
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
244
|
+
) -> tuple[Optional[Assertion], MonitorUrn, Optional[Monitor]]:
|
|
245
|
+
"""Retrieve the assertion and monitor entities from the DataHub instance."""
|
|
246
|
+
return retrieve_assertion_and_monitor_by_urn(self.client, urn, dataset_urn)
|
|
247
|
+
|
|
248
|
+
def _merge_schema_input(
|
|
249
|
+
self,
|
|
250
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
251
|
+
urn: Union[str, AssertionUrn],
|
|
252
|
+
display_name: Optional[str],
|
|
253
|
+
enabled: Optional[bool],
|
|
254
|
+
compatibility: Optional[Union[str, SchemaAssertionCompatibility]],
|
|
255
|
+
fields: Optional[SchemaAssertionFieldsInputType],
|
|
256
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes],
|
|
257
|
+
tags: Optional[TagsInputType],
|
|
258
|
+
now_utc: datetime,
|
|
259
|
+
assertion_input: _SchemaAssertionInput,
|
|
260
|
+
maybe_assertion_entity: Optional[Assertion],
|
|
261
|
+
maybe_monitor_entity: Optional[Monitor],
|
|
262
|
+
existing_assertion: SchemaAssertion,
|
|
263
|
+
schedule: Optional[Union[str, models.CronScheduleClass]],
|
|
264
|
+
) -> _SchemaAssertionInput:
|
|
265
|
+
"""
|
|
266
|
+
Merge the input with the existing assertion and monitor entities.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
dataset_urn: The URN of the dataset to validate.
|
|
270
|
+
urn: The URN of the assertion.
|
|
271
|
+
display_name: The display name of the assertion.
|
|
272
|
+
enabled: Whether the assertion is enabled.
|
|
273
|
+
compatibility: The compatibility mode for schema validation.
|
|
274
|
+
fields: The expected schema fields.
|
|
275
|
+
incident_behavior: The incident behavior to be applied to the assertion.
|
|
276
|
+
tags: The tags to be applied to the assertion.
|
|
277
|
+
now_utc: The current UTC time from when the function is called.
|
|
278
|
+
assertion_input: The validated input to the function.
|
|
279
|
+
maybe_assertion_entity: The existing assertion entity from the DataHub instance.
|
|
280
|
+
maybe_monitor_entity: The existing monitor entity from the DataHub instance.
|
|
281
|
+
existing_assertion: The existing assertion from the DataHub instance.
|
|
282
|
+
schedule: The schedule to be applied to the assertion.
|
|
283
|
+
|
|
284
|
+
Returns:
|
|
285
|
+
The merged assertion input.
|
|
286
|
+
"""
|
|
287
|
+
# Merge fields - convert to list of SchemaAssertionField if needed
|
|
288
|
+
merged_fields = _merge_field(
|
|
289
|
+
fields,
|
|
290
|
+
"fields",
|
|
291
|
+
assertion_input,
|
|
292
|
+
existing_assertion,
|
|
293
|
+
existing_assertion.fields if existing_assertion else None,
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
# Ensure fields are parsed if they came from the existing assertion
|
|
297
|
+
if merged_fields and not all(
|
|
298
|
+
isinstance(f, SchemaAssertionField) for f in merged_fields
|
|
299
|
+
):
|
|
300
|
+
merged_fields = _parse_schema_assertion_fields(merged_fields)
|
|
301
|
+
|
|
302
|
+
merged_assertion_input = _SchemaAssertionInput(
|
|
303
|
+
urn=urn,
|
|
304
|
+
entity_client=self.client.entities,
|
|
305
|
+
dataset_urn=dataset_urn,
|
|
306
|
+
display_name=_merge_field(
|
|
307
|
+
display_name,
|
|
308
|
+
"display_name",
|
|
309
|
+
assertion_input,
|
|
310
|
+
existing_assertion,
|
|
311
|
+
maybe_assertion_entity.description if maybe_assertion_entity else None,
|
|
312
|
+
),
|
|
313
|
+
enabled=_merge_field(
|
|
314
|
+
enabled,
|
|
315
|
+
"enabled",
|
|
316
|
+
assertion_input,
|
|
317
|
+
existing_assertion,
|
|
318
|
+
existing_assertion.mode == AssertionMode.ACTIVE
|
|
319
|
+
if existing_assertion
|
|
320
|
+
else None,
|
|
321
|
+
),
|
|
322
|
+
schedule=_merge_field(
|
|
323
|
+
schedule,
|
|
324
|
+
"schedule",
|
|
325
|
+
assertion_input,
|
|
326
|
+
existing_assertion,
|
|
327
|
+
existing_assertion.schedule if existing_assertion else None,
|
|
328
|
+
),
|
|
329
|
+
compatibility=_merge_field(
|
|
330
|
+
compatibility,
|
|
331
|
+
"compatibility",
|
|
332
|
+
assertion_input,
|
|
333
|
+
existing_assertion,
|
|
334
|
+
existing_assertion.compatibility if existing_assertion else None,
|
|
335
|
+
),
|
|
336
|
+
fields=merged_fields,
|
|
337
|
+
incident_behavior=_merge_field(
|
|
338
|
+
incident_behavior,
|
|
339
|
+
"incident_behavior",
|
|
340
|
+
assertion_input,
|
|
341
|
+
existing_assertion,
|
|
342
|
+
SchemaAssertion._get_incident_behavior(maybe_assertion_entity)
|
|
343
|
+
if maybe_assertion_entity
|
|
344
|
+
else None,
|
|
345
|
+
),
|
|
346
|
+
tags=_merge_field(
|
|
347
|
+
tags,
|
|
348
|
+
"tags",
|
|
349
|
+
assertion_input,
|
|
350
|
+
existing_assertion,
|
|
351
|
+
maybe_assertion_entity.tags if maybe_assertion_entity else None,
|
|
352
|
+
),
|
|
353
|
+
created_by=existing_assertion.created_by or DEFAULT_CREATED_BY,
|
|
354
|
+
created_at=existing_assertion.created_at or now_utc,
|
|
355
|
+
updated_by=assertion_input.updated_by,
|
|
356
|
+
updated_at=assertion_input.updated_at,
|
|
357
|
+
)
|
|
358
|
+
return merged_assertion_input
|