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,218 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smart Freshness Assertion Input classes for DataHub.
|
|
3
|
+
|
|
4
|
+
This module contains the _SmartFreshnessAssertionInput class that handles
|
|
5
|
+
input validation and entity creation for smart freshness assertions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from typing import Optional, Union
|
|
10
|
+
|
|
11
|
+
from acryl_datahub_cloud.sdk.assertion_input.assertion_input import (
|
|
12
|
+
DEFAULT_DAILY_SCHEDULE,
|
|
13
|
+
LAST_MODIFIED_ALLOWED_FIELD_TYPES,
|
|
14
|
+
AssertionIncidentBehaviorInputTypes,
|
|
15
|
+
DetectionMechanismInputTypes,
|
|
16
|
+
ExclusionWindowInputTypes,
|
|
17
|
+
FieldSpecType,
|
|
18
|
+
InferenceSensitivity,
|
|
19
|
+
_AssertionInput,
|
|
20
|
+
_AuditLog,
|
|
21
|
+
_DataHubOperation,
|
|
22
|
+
_HasFreshnessFeatures,
|
|
23
|
+
_HasSmartAssertionInputs,
|
|
24
|
+
_InformationSchema,
|
|
25
|
+
_LastModifiedColumn,
|
|
26
|
+
)
|
|
27
|
+
from acryl_datahub_cloud.sdk.entities.assertion import (
|
|
28
|
+
AssertionInfoInputType,
|
|
29
|
+
TagsInputType,
|
|
30
|
+
)
|
|
31
|
+
from acryl_datahub_cloud.sdk.errors import (
|
|
32
|
+
SDKNotYetSupportedError,
|
|
33
|
+
SDKUsageError,
|
|
34
|
+
)
|
|
35
|
+
from datahub.metadata import schema_classes as models
|
|
36
|
+
from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn
|
|
37
|
+
from datahub.sdk.entity_client import EntityClient
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class _SmartFreshnessAssertionInput(
|
|
41
|
+
_AssertionInput, _HasSmartAssertionInputs, _HasFreshnessFeatures
|
|
42
|
+
):
|
|
43
|
+
def __init__(
|
|
44
|
+
self,
|
|
45
|
+
*,
|
|
46
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
47
|
+
entity_client: EntityClient, # Needed to get the schema field spec for the detection mechanism if needed
|
|
48
|
+
urn: Optional[Union[str, AssertionUrn]] = None,
|
|
49
|
+
display_name: Optional[str] = None,
|
|
50
|
+
enabled: bool = True,
|
|
51
|
+
schedule: Optional[Union[str, models.CronScheduleClass]] = None,
|
|
52
|
+
detection_mechanism: DetectionMechanismInputTypes = None,
|
|
53
|
+
sensitivity: Optional[Union[str, InferenceSensitivity]] = None,
|
|
54
|
+
exclusion_windows: Optional[ExclusionWindowInputTypes] = None,
|
|
55
|
+
training_data_lookback_days: Optional[int] = None,
|
|
56
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
|
|
57
|
+
tags: Optional[TagsInputType] = None,
|
|
58
|
+
created_by: Union[str, CorpUserUrn],
|
|
59
|
+
created_at: datetime,
|
|
60
|
+
updated_by: Union[str, CorpUserUrn],
|
|
61
|
+
updated_at: datetime,
|
|
62
|
+
):
|
|
63
|
+
_AssertionInput.__init__(
|
|
64
|
+
self,
|
|
65
|
+
dataset_urn=dataset_urn,
|
|
66
|
+
entity_client=entity_client,
|
|
67
|
+
urn=urn,
|
|
68
|
+
display_name=display_name,
|
|
69
|
+
enabled=enabled,
|
|
70
|
+
schedule=schedule
|
|
71
|
+
if schedule is not None
|
|
72
|
+
else DEFAULT_DAILY_SCHEDULE, # Use provided schedule or default for create case
|
|
73
|
+
detection_mechanism=detection_mechanism,
|
|
74
|
+
incident_behavior=incident_behavior,
|
|
75
|
+
tags=tags,
|
|
76
|
+
source_type=models.AssertionSourceTypeClass.INFERRED, # Smart assertions are of type inferred, not native
|
|
77
|
+
created_by=created_by,
|
|
78
|
+
created_at=created_at,
|
|
79
|
+
updated_by=updated_by,
|
|
80
|
+
updated_at=updated_at,
|
|
81
|
+
)
|
|
82
|
+
_HasSmartAssertionInputs.__init__(
|
|
83
|
+
self,
|
|
84
|
+
sensitivity=sensitivity,
|
|
85
|
+
exclusion_windows=exclusion_windows,
|
|
86
|
+
training_data_lookback_days=training_data_lookback_days,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def _assertion_type(self) -> str:
|
|
90
|
+
"""Get the assertion type."""
|
|
91
|
+
return models.AssertionTypeClass.FRESHNESS
|
|
92
|
+
|
|
93
|
+
def _create_assertion_info(
|
|
94
|
+
self, filter: Optional[models.DatasetFilterClass]
|
|
95
|
+
) -> AssertionInfoInputType:
|
|
96
|
+
"""
|
|
97
|
+
Create a FreshnessAssertionInfoClass for a smart freshness assertion.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
filter: Optional filter to apply to the assertion.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
A FreshnessAssertionInfoClass configured for smart freshness.
|
|
104
|
+
"""
|
|
105
|
+
return models.FreshnessAssertionInfoClass(
|
|
106
|
+
type=models.FreshnessAssertionTypeClass.DATASET_CHANGE, # Currently only dataset change is supported
|
|
107
|
+
entity=str(self.dataset_urn),
|
|
108
|
+
# schedule (optional, must be left empty for smart freshness assertions - managed by the AI inference engine)
|
|
109
|
+
filter=filter,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def _convert_schedule(self) -> models.CronScheduleClass:
|
|
113
|
+
"""Create a schedule for a smart freshness assertion.
|
|
114
|
+
|
|
115
|
+
For create case, uses DEFAULT_DAILY_SCHEDULE. For update case, preserves existing schedule.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
A CronScheduleClass with appropriate schedule settings.
|
|
119
|
+
"""
|
|
120
|
+
assert self.schedule is not None, (
|
|
121
|
+
"Schedule should never be None due to constructor logic"
|
|
122
|
+
)
|
|
123
|
+
return self.schedule
|
|
124
|
+
|
|
125
|
+
def _get_assertion_evaluation_parameters(
|
|
126
|
+
self, source_type: str, field: Optional[FieldSpecType]
|
|
127
|
+
) -> models.AssertionEvaluationParametersClass:
|
|
128
|
+
# Ensure field is either None or FreshnessFieldSpecClass
|
|
129
|
+
freshness_field = None
|
|
130
|
+
if field is not None:
|
|
131
|
+
if not isinstance(field, models.FreshnessFieldSpecClass):
|
|
132
|
+
raise SDKUsageError(
|
|
133
|
+
f"Expected FreshnessFieldSpecClass for freshness assertion, got {type(field).__name__}"
|
|
134
|
+
)
|
|
135
|
+
freshness_field = field
|
|
136
|
+
|
|
137
|
+
return models.AssertionEvaluationParametersClass(
|
|
138
|
+
type=models.AssertionEvaluationParametersTypeClass.DATASET_FRESHNESS,
|
|
139
|
+
datasetFreshnessParameters=models.DatasetFreshnessAssertionParametersClass(
|
|
140
|
+
sourceType=source_type, field=freshness_field
|
|
141
|
+
),
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
def _convert_assertion_source_type_and_field(
|
|
145
|
+
self,
|
|
146
|
+
) -> tuple[str, Optional[FieldSpecType]]:
|
|
147
|
+
"""
|
|
148
|
+
Convert detection mechanism into source type and field specification for freshness assertions.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
A tuple of (source_type, field) where field may be None.
|
|
152
|
+
Note that the source_type is a string, not a models.DatasetFreshnessSourceTypeClass (or other assertion source type) since
|
|
153
|
+
the source type is not a enum in the code generated from the DatasetFreshnessSourceType enum in the PDL.
|
|
154
|
+
|
|
155
|
+
Raises:
|
|
156
|
+
SDKNotYetSupportedError: If the detection mechanism is not supported.
|
|
157
|
+
SDKUsageError: If the field (column) is not found in the dataset,
|
|
158
|
+
and the detection mechanism requires a field. Also if the field
|
|
159
|
+
is not an allowed type for the detection mechanism.
|
|
160
|
+
"""
|
|
161
|
+
source_type = models.DatasetFreshnessSourceTypeClass.INFORMATION_SCHEMA
|
|
162
|
+
field = None
|
|
163
|
+
|
|
164
|
+
if isinstance(self.detection_mechanism, _LastModifiedColumn):
|
|
165
|
+
source_type = models.DatasetFreshnessSourceTypeClass.FIELD_VALUE
|
|
166
|
+
field = self._create_field_spec(
|
|
167
|
+
self.detection_mechanism.column_name,
|
|
168
|
+
LAST_MODIFIED_ALLOWED_FIELD_TYPES,
|
|
169
|
+
"last modified column",
|
|
170
|
+
models.FreshnessFieldKindClass.LAST_MODIFIED,
|
|
171
|
+
self._get_schema_field_spec,
|
|
172
|
+
self._validate_field_type,
|
|
173
|
+
)
|
|
174
|
+
elif isinstance(self.detection_mechanism, _InformationSchema):
|
|
175
|
+
source_type = models.DatasetFreshnessSourceTypeClass.INFORMATION_SCHEMA
|
|
176
|
+
elif isinstance(self.detection_mechanism, _DataHubOperation):
|
|
177
|
+
source_type = models.DatasetFreshnessSourceTypeClass.DATAHUB_OPERATION
|
|
178
|
+
elif isinstance(self.detection_mechanism, _AuditLog):
|
|
179
|
+
source_type = models.DatasetFreshnessSourceTypeClass.AUDIT_LOG
|
|
180
|
+
else:
|
|
181
|
+
raise SDKNotYetSupportedError(
|
|
182
|
+
f"Detection mechanism {self.detection_mechanism} not yet supported for smart freshness assertions"
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
return source_type, field
|
|
186
|
+
|
|
187
|
+
def _create_monitor_info(
|
|
188
|
+
self,
|
|
189
|
+
assertion_urn: AssertionUrn,
|
|
190
|
+
status: models.MonitorStatusClass,
|
|
191
|
+
schedule: models.CronScheduleClass,
|
|
192
|
+
) -> models.MonitorInfoClass:
|
|
193
|
+
"""
|
|
194
|
+
Create a MonitorInfoClass with all the necessary components.
|
|
195
|
+
"""
|
|
196
|
+
source_type, field = self._convert_assertion_source_type_and_field()
|
|
197
|
+
return models.MonitorInfoClass(
|
|
198
|
+
type=models.MonitorTypeClass.ASSERTION,
|
|
199
|
+
status=status,
|
|
200
|
+
assertionMonitor=models.AssertionMonitorClass(
|
|
201
|
+
assertions=[
|
|
202
|
+
models.AssertionEvaluationSpecClass(
|
|
203
|
+
assertion=str(assertion_urn),
|
|
204
|
+
schedule=schedule,
|
|
205
|
+
parameters=self._get_assertion_evaluation_parameters(
|
|
206
|
+
str(source_type), field
|
|
207
|
+
),
|
|
208
|
+
),
|
|
209
|
+
],
|
|
210
|
+
settings=models.AssertionMonitorSettingsClass(
|
|
211
|
+
adjustmentSettings=models.AssertionAdjustmentSettingsClass(
|
|
212
|
+
sensitivity=self._convert_sensitivity(),
|
|
213
|
+
exclusionWindows=self._convert_exclusion_windows(),
|
|
214
|
+
trainingDataLookbackWindowDays=self.training_data_lookback_days,
|
|
215
|
+
),
|
|
216
|
+
),
|
|
217
|
+
),
|
|
218
|
+
)
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smart SQL Assertion Input classes for DataHub.
|
|
3
|
+
|
|
4
|
+
This module contains the _SmartSqlAssertionInput class that handles
|
|
5
|
+
input validation and entity creation for smart SQL assertions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from typing import Optional, Union
|
|
10
|
+
|
|
11
|
+
from acryl_datahub_cloud.sdk.assertion_input.assertion_input import (
|
|
12
|
+
DEFAULT_EVERY_SIX_HOURS_SCHEDULE,
|
|
13
|
+
AssertionIncidentBehaviorInputTypes,
|
|
14
|
+
ExclusionWindowInputTypes,
|
|
15
|
+
FieldSpecType,
|
|
16
|
+
InferenceSensitivity,
|
|
17
|
+
_AssertionInput,
|
|
18
|
+
_HasSmartAssertionInputs,
|
|
19
|
+
)
|
|
20
|
+
from acryl_datahub_cloud.sdk.entities.assertion import (
|
|
21
|
+
AssertionInfoInputType,
|
|
22
|
+
TagsInputType,
|
|
23
|
+
)
|
|
24
|
+
from datahub.metadata import schema_classes as models
|
|
25
|
+
from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn
|
|
26
|
+
from datahub.sdk.entity_client import EntityClient
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class _SmartSqlAssertionInput(_AssertionInput, _HasSmartAssertionInputs):
|
|
30
|
+
"""Input class for smart SQL assertions with AI-powered inference."""
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
*,
|
|
35
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
36
|
+
entity_client: EntityClient,
|
|
37
|
+
statement: Optional[str],
|
|
38
|
+
created_by: Union[str, CorpUserUrn],
|
|
39
|
+
created_at: datetime,
|
|
40
|
+
updated_by: Union[str, CorpUserUrn],
|
|
41
|
+
updated_at: datetime,
|
|
42
|
+
urn: Optional[Union[str, AssertionUrn]] = None,
|
|
43
|
+
display_name: Optional[str] = None,
|
|
44
|
+
enabled: bool = True,
|
|
45
|
+
schedule: Optional[Union[str, models.CronScheduleClass]] = None,
|
|
46
|
+
sensitivity: Optional[Union[str, InferenceSensitivity]] = None,
|
|
47
|
+
exclusion_windows: Optional[ExclusionWindowInputTypes] = None,
|
|
48
|
+
training_data_lookback_days: Optional[int] = None,
|
|
49
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
|
|
50
|
+
tags: Optional[TagsInputType] = None,
|
|
51
|
+
):
|
|
52
|
+
_AssertionInput.__init__(
|
|
53
|
+
self,
|
|
54
|
+
dataset_urn=dataset_urn,
|
|
55
|
+
entity_client=entity_client,
|
|
56
|
+
urn=urn,
|
|
57
|
+
display_name=display_name,
|
|
58
|
+
enabled=enabled,
|
|
59
|
+
schedule=schedule,
|
|
60
|
+
detection_mechanism=None, # Smart SQL assertions don't use detection mechanisms
|
|
61
|
+
incident_behavior=incident_behavior,
|
|
62
|
+
tags=tags,
|
|
63
|
+
source_type=models.AssertionSourceTypeClass.INFERRED, # Smart assertions are of type inferred
|
|
64
|
+
created_by=created_by,
|
|
65
|
+
created_at=created_at,
|
|
66
|
+
updated_by=updated_by,
|
|
67
|
+
updated_at=updated_at,
|
|
68
|
+
)
|
|
69
|
+
_HasSmartAssertionInputs.__init__(
|
|
70
|
+
self,
|
|
71
|
+
sensitivity=sensitivity,
|
|
72
|
+
exclusion_windows=exclusion_windows,
|
|
73
|
+
training_data_lookback_days=training_data_lookback_days,
|
|
74
|
+
)
|
|
75
|
+
self.statement = statement
|
|
76
|
+
|
|
77
|
+
def _create_assertion_info(
|
|
78
|
+
self, filter: Optional[models.DatasetFilterClass]
|
|
79
|
+
) -> AssertionInfoInputType:
|
|
80
|
+
"""
|
|
81
|
+
Create a SqlAssertionInfoClass for a smart SQL assertion.
|
|
82
|
+
|
|
83
|
+
For smart SQL assertions, we use METRIC type with a placeholder operator/parameters
|
|
84
|
+
since the actual thresholds are inferred by AI.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
filter: Optional filter (not used for SQL assertions).
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
A SqlAssertionInfoClass configured for smart SQL.
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
assert self.statement is not None, (
|
|
94
|
+
"statement is required for Smart SQL assertions"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# For smart SQL assertions, we use METRIC type with placeholder values
|
|
98
|
+
# The actual thresholds are inferred by the AI model
|
|
99
|
+
return models.SqlAssertionInfoClass(
|
|
100
|
+
type=models.SqlAssertionTypeClass.METRIC,
|
|
101
|
+
entity=str(self.dataset_urn),
|
|
102
|
+
statement=self.statement,
|
|
103
|
+
changeType=None,
|
|
104
|
+
# Use GREATER_THAN_OR_EQUAL_TO with 0 as a placeholder - AI will infer actual thresholds
|
|
105
|
+
operator=models.AssertionStdOperatorClass.GREATER_THAN_OR_EQUAL_TO,
|
|
106
|
+
parameters=models.AssertionStdParametersClass(
|
|
107
|
+
value=models.AssertionStdParameterClass(
|
|
108
|
+
type=models.AssertionStdParameterTypeClass.NUMBER,
|
|
109
|
+
value="0",
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
def _convert_schedule(self) -> models.CronScheduleClass:
|
|
115
|
+
"""Create a schedule for a smart SQL assertion.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
A CronScheduleClass with appropriate schedule settings.
|
|
119
|
+
"""
|
|
120
|
+
if self.schedule is None:
|
|
121
|
+
return DEFAULT_EVERY_SIX_HOURS_SCHEDULE
|
|
122
|
+
|
|
123
|
+
return models.CronScheduleClass(
|
|
124
|
+
cron=self.schedule.cron,
|
|
125
|
+
timezone=self.schedule.timezone,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def _get_assertion_evaluation_parameters(
|
|
129
|
+
self, source_type: str, field: Optional[FieldSpecType]
|
|
130
|
+
) -> models.AssertionEvaluationParametersClass:
|
|
131
|
+
return models.AssertionEvaluationParametersClass(
|
|
132
|
+
type=models.AssertionEvaluationParametersTypeClass.DATASET_SQL,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def _convert_assertion_source_type_and_field(
|
|
136
|
+
self,
|
|
137
|
+
) -> tuple[str, None]:
|
|
138
|
+
"""SQL assertions do not have source type or field."""
|
|
139
|
+
return "None", None
|
|
140
|
+
|
|
141
|
+
def _create_filter_from_detection_mechanism(
|
|
142
|
+
self,
|
|
143
|
+
) -> Optional[models.DatasetFilterClass]:
|
|
144
|
+
"""SQL assertions do not use filters."""
|
|
145
|
+
return None
|
|
146
|
+
|
|
147
|
+
def _create_monitor_info(
|
|
148
|
+
self,
|
|
149
|
+
assertion_urn: AssertionUrn,
|
|
150
|
+
status: models.MonitorStatusClass,
|
|
151
|
+
schedule: models.CronScheduleClass,
|
|
152
|
+
) -> models.MonitorInfoClass:
|
|
153
|
+
"""
|
|
154
|
+
Create a MonitorInfoClass with all the necessary components for smart SQL assertion.
|
|
155
|
+
"""
|
|
156
|
+
return models.MonitorInfoClass(
|
|
157
|
+
type=models.MonitorTypeClass.ASSERTION,
|
|
158
|
+
status=status,
|
|
159
|
+
assertionMonitor=models.AssertionMonitorClass(
|
|
160
|
+
assertions=[
|
|
161
|
+
models.AssertionEvaluationSpecClass(
|
|
162
|
+
assertion=str(assertion_urn),
|
|
163
|
+
schedule=schedule,
|
|
164
|
+
parameters=self._get_assertion_evaluation_parameters(
|
|
165
|
+
"None", None
|
|
166
|
+
),
|
|
167
|
+
),
|
|
168
|
+
],
|
|
169
|
+
settings=models.AssertionMonitorSettingsClass(
|
|
170
|
+
adjustmentSettings=models.AssertionAdjustmentSettingsClass(
|
|
171
|
+
sensitivity=self._convert_sensitivity(),
|
|
172
|
+
exclusionWindows=self._convert_exclusion_windows(),
|
|
173
|
+
trainingDataLookbackWindowDays=self.training_data_lookback_days,
|
|
174
|
+
),
|
|
175
|
+
),
|
|
176
|
+
),
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
def _assertion_type(self) -> str:
|
|
180
|
+
"""Get the assertion type."""
|
|
181
|
+
return models.AssertionTypeClass.SQL
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smart Volume Assertion Input classes for DataHub.
|
|
3
|
+
|
|
4
|
+
This module contains the _SmartVolumeAssertionInput class that handles
|
|
5
|
+
input validation and entity creation for smart volume assertions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from typing import Optional, Union
|
|
10
|
+
|
|
11
|
+
from acryl_datahub_cloud.sdk.assertion_input.assertion_input import (
|
|
12
|
+
DEFAULT_DAILY_SCHEDULE,
|
|
13
|
+
AssertionIncidentBehaviorInputTypes,
|
|
14
|
+
DetectionMechanismInputTypes,
|
|
15
|
+
ExclusionWindowInputTypes,
|
|
16
|
+
FieldSpecType,
|
|
17
|
+
InferenceSensitivity,
|
|
18
|
+
_AssertionInput,
|
|
19
|
+
_DatasetProfile,
|
|
20
|
+
_HasSmartAssertionInputs,
|
|
21
|
+
_InformationSchema,
|
|
22
|
+
_Query,
|
|
23
|
+
)
|
|
24
|
+
from acryl_datahub_cloud.sdk.entities.assertion import (
|
|
25
|
+
AssertionInfoInputType,
|
|
26
|
+
TagsInputType,
|
|
27
|
+
)
|
|
28
|
+
from acryl_datahub_cloud.sdk.errors import SDKNotYetSupportedError
|
|
29
|
+
from datahub.metadata import schema_classes as models
|
|
30
|
+
from datahub.metadata.urns import AssertionUrn, CorpUserUrn, DatasetUrn
|
|
31
|
+
from datahub.sdk.entity_client import EntityClient
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class _SmartVolumeAssertionInput(_AssertionInput, _HasSmartAssertionInputs):
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
*,
|
|
38
|
+
dataset_urn: Union[str, DatasetUrn],
|
|
39
|
+
entity_client: EntityClient, # Needed to get the schema field spec for the detection mechanism if needed
|
|
40
|
+
urn: Optional[Union[str, AssertionUrn]] = None,
|
|
41
|
+
display_name: Optional[str] = None,
|
|
42
|
+
enabled: bool = True,
|
|
43
|
+
schedule: Optional[Union[str, models.CronScheduleClass]] = None,
|
|
44
|
+
detection_mechanism: DetectionMechanismInputTypes = None,
|
|
45
|
+
sensitivity: Optional[Union[str, InferenceSensitivity]] = None,
|
|
46
|
+
exclusion_windows: Optional[ExclusionWindowInputTypes] = None,
|
|
47
|
+
training_data_lookback_days: Optional[int] = None,
|
|
48
|
+
incident_behavior: Optional[AssertionIncidentBehaviorInputTypes] = None,
|
|
49
|
+
tags: Optional[TagsInputType] = None,
|
|
50
|
+
created_by: Union[str, CorpUserUrn],
|
|
51
|
+
created_at: datetime,
|
|
52
|
+
updated_by: Union[str, CorpUserUrn],
|
|
53
|
+
updated_at: datetime,
|
|
54
|
+
):
|
|
55
|
+
_AssertionInput.__init__(
|
|
56
|
+
self,
|
|
57
|
+
dataset_urn=dataset_urn,
|
|
58
|
+
entity_client=entity_client,
|
|
59
|
+
urn=urn,
|
|
60
|
+
display_name=display_name,
|
|
61
|
+
enabled=enabled,
|
|
62
|
+
schedule=schedule,
|
|
63
|
+
detection_mechanism=detection_mechanism,
|
|
64
|
+
incident_behavior=incident_behavior,
|
|
65
|
+
tags=tags,
|
|
66
|
+
source_type=models.AssertionSourceTypeClass.INFERRED, # Smart assertions are of type inferred, not native
|
|
67
|
+
created_by=created_by,
|
|
68
|
+
created_at=created_at,
|
|
69
|
+
updated_by=updated_by,
|
|
70
|
+
updated_at=updated_at,
|
|
71
|
+
)
|
|
72
|
+
_HasSmartAssertionInputs.__init__(
|
|
73
|
+
self,
|
|
74
|
+
sensitivity=sensitivity,
|
|
75
|
+
exclusion_windows=exclusion_windows,
|
|
76
|
+
training_data_lookback_days=training_data_lookback_days,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
def _create_assertion_info(
|
|
80
|
+
self, filter: Optional[models.DatasetFilterClass]
|
|
81
|
+
) -> AssertionInfoInputType:
|
|
82
|
+
"""
|
|
83
|
+
Create a VolumeAssertionInfoClass for a smart volume assertion.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
filter: Optional filter to apply to the assertion.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
A VolumeAssertionInfoClass configured for smart volume.
|
|
90
|
+
"""
|
|
91
|
+
return models.VolumeAssertionInfoClass(
|
|
92
|
+
type=models.VolumeAssertionTypeClass.ROW_COUNT_TOTAL, # Currently only ROW_COUNT_TOTAL is supported for smart volume
|
|
93
|
+
entity=str(self.dataset_urn),
|
|
94
|
+
filter=filter,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def _convert_schedule(self) -> models.CronScheduleClass:
|
|
98
|
+
"""Create a schedule for a smart volume assertion.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
A CronScheduleClass with appropriate schedule settings.
|
|
102
|
+
"""
|
|
103
|
+
if self.schedule is None:
|
|
104
|
+
return DEFAULT_DAILY_SCHEDULE
|
|
105
|
+
|
|
106
|
+
return models.CronScheduleClass(
|
|
107
|
+
cron=self.schedule.cron,
|
|
108
|
+
timezone=self.schedule.timezone,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
def _get_assertion_evaluation_parameters(
|
|
112
|
+
self, source_type: str, field: Optional[FieldSpecType]
|
|
113
|
+
) -> models.AssertionEvaluationParametersClass:
|
|
114
|
+
return models.AssertionEvaluationParametersClass(
|
|
115
|
+
type=models.AssertionEvaluationParametersTypeClass.DATASET_VOLUME,
|
|
116
|
+
datasetVolumeParameters=models.DatasetVolumeAssertionParametersClass(
|
|
117
|
+
sourceType=source_type,
|
|
118
|
+
),
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
def _convert_assertion_source_type_and_field(
|
|
122
|
+
self,
|
|
123
|
+
) -> tuple[str, Optional[FieldSpecType]]:
|
|
124
|
+
"""
|
|
125
|
+
Convert detection mechanism into source type and field specification for volume assertions.
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
A tuple of (source_type, field) where field may be None.
|
|
129
|
+
Note that the source_type is a string, not a models.DatasetFreshnessSourceTypeClass (or other assertion source type) since
|
|
130
|
+
the source type is not a enum in the code generated from the DatasetFreshnessSourceType enum in the PDL.
|
|
131
|
+
|
|
132
|
+
Raises:
|
|
133
|
+
SDKNotYetSupportedError: If the detection mechanism is not supported.
|
|
134
|
+
SDKUsageError: If the field (column) is not found in the dataset,
|
|
135
|
+
and the detection mechanism requires a field. Also if the field
|
|
136
|
+
is not an allowed type for the detection mechanism.
|
|
137
|
+
"""
|
|
138
|
+
source_type = models.DatasetVolumeSourceTypeClass.INFORMATION_SCHEMA
|
|
139
|
+
field = None
|
|
140
|
+
|
|
141
|
+
if isinstance(self.detection_mechanism, _Query):
|
|
142
|
+
source_type = models.DatasetVolumeSourceTypeClass.QUERY
|
|
143
|
+
elif isinstance(self.detection_mechanism, _InformationSchema):
|
|
144
|
+
source_type = models.DatasetVolumeSourceTypeClass.INFORMATION_SCHEMA
|
|
145
|
+
elif isinstance(self.detection_mechanism, _DatasetProfile):
|
|
146
|
+
source_type = models.DatasetVolumeSourceTypeClass.DATAHUB_DATASET_PROFILE
|
|
147
|
+
else:
|
|
148
|
+
raise SDKNotYetSupportedError(
|
|
149
|
+
f"Detection mechanism {self.detection_mechanism} not yet supported for smart volume assertions"
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
return source_type, field
|
|
153
|
+
|
|
154
|
+
def _create_monitor_info(
|
|
155
|
+
self,
|
|
156
|
+
assertion_urn: AssertionUrn,
|
|
157
|
+
status: models.MonitorStatusClass,
|
|
158
|
+
schedule: models.CronScheduleClass,
|
|
159
|
+
) -> models.MonitorInfoClass:
|
|
160
|
+
"""
|
|
161
|
+
Create a MonitorInfoClass with all the necessary components.
|
|
162
|
+
"""
|
|
163
|
+
source_type, field = self._convert_assertion_source_type_and_field()
|
|
164
|
+
return models.MonitorInfoClass(
|
|
165
|
+
type=models.MonitorTypeClass.ASSERTION,
|
|
166
|
+
status=status,
|
|
167
|
+
assertionMonitor=models.AssertionMonitorClass(
|
|
168
|
+
assertions=[
|
|
169
|
+
models.AssertionEvaluationSpecClass(
|
|
170
|
+
assertion=str(assertion_urn),
|
|
171
|
+
schedule=schedule,
|
|
172
|
+
parameters=self._get_assertion_evaluation_parameters(
|
|
173
|
+
str(source_type), field
|
|
174
|
+
),
|
|
175
|
+
),
|
|
176
|
+
],
|
|
177
|
+
settings=models.AssertionMonitorSettingsClass(
|
|
178
|
+
adjustmentSettings=models.AssertionAdjustmentSettingsClass(
|
|
179
|
+
sensitivity=self._convert_sensitivity(),
|
|
180
|
+
exclusionWindows=self._convert_exclusion_windows(),
|
|
181
|
+
trainingDataLookbackWindowDays=self.training_data_lookback_days,
|
|
182
|
+
),
|
|
183
|
+
),
|
|
184
|
+
),
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
def _assertion_type(self) -> str:
|
|
188
|
+
"""Get the assertion type."""
|
|
189
|
+
return models.AssertionTypeClass.VOLUME
|