Fix: Safer default Mark Deleted Tables (#9065)

* Fix: Safer default Mark Deleted Tables

* Fix: Change Based On Comments

* Fix: Change Based On Comments

* Add: Migration Files

Co-authored-by: Sachin Chaurasiya <sachinchaurasiyachotey87@gmail.com>
This commit is contained in:
Milan Bariya 2022-12-01 16:26:43 +05:30 committed by GitHub
parent 11edcef279
commit 2f9f169de9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 29 deletions

View File

@ -0,0 +1,3 @@
-- Remove markDeletedTablesFromFilterOnly
UPDATE ingestion_pipeline_entity
SET json = JSON_REMOVE(json ,'$.sourceConfig.config.markDeletedTablesFromFilterOnly');

View File

@ -0,0 +1,3 @@
-- Remove markDeletedTablesFromFilterOnly
UPDATE ingestion_pipeline_entity
SET json = json::jsonb #- '{sourceConfig,config,markDeletedTablesFromFilterOnly}';

View File

@ -533,7 +533,12 @@ class DatabaseServiceSource(
logger.info(
f"Mark Deleted Tables set to True. Processing database [{self.context.database.name.__root__}]"
)
if self.source_config.markDeletedTablesFromFilterOnly:
# If markAllDeletedTables is True, all tables Which are not in FilterPattern will be deleted
if self.source_config.markAllDeletedTables:
yield from self.fetch_all_schema_and_delete_tables()
# If markAllDeletedTables is False (Default), Only delete tables which are deleted from the datasource
else:
schema_names_list = self.get_database_schema_names()
for schema_name in schema_names_list:
schema_fqn = fqn.build(
@ -545,5 +550,3 @@ class DatabaseServiceSource(
)
yield from self.delete_schema_tables(schema_fqn)
else:
yield from self.fetch_all_schema_and_delete_tables()

View File

@ -23,8 +23,8 @@
"type": "boolean",
"default": true
},
"markDeletedTablesFromFilterOnly": {
"description": "Optional configuration to mark deleted tables only to the filtered schema",
"markAllDeletedTables": {
"description": "Optional configuration to mark all deleted tables to the filtered schema",
"type": "boolean",
"default": false
},

View File

@ -170,15 +170,14 @@ const AddIngestion = ({
)
: undefined
);
const [markDeletedTablesFromFilterOnly, setMarkDeletedTablesFromFilterOnly] =
useState(
isDatabaseService
? Boolean(
(data?.sourceConfig.config as ConfigClass)
?.markDeletedTablesFromFilterOnly ?? false
)
: undefined
);
const [markAllDeletedTables, setMarkAllDeletedTables] = useState(
isDatabaseService
? Boolean(
(data?.sourceConfig.config as ConfigClass)?.markAllDeletedTables ??
false
)
: undefined
);
const [includeView, setIncludeView] = useState(
Boolean((data?.sourceConfig.config as ConfigClass)?.includeViews)
);
@ -466,7 +465,7 @@ const AddIngestion = ({
showTableFilter
),
markDeletedTables,
markDeletedTablesFromFilterOnly,
markAllDeletedTables,
...DatabaseConfigData,
type: ConfigType.DatabaseMetadata,
};
@ -734,10 +733,10 @@ const AddIngestion = ({
handleIncludeView={() => setIncludeView((pre) => !pre)}
handleIngestSampleData={() => setIngestSampleData((pre) => !pre)}
handleIngestionName={(val) => setIngestionName(val)}
handleMarkDeletedTables={() => setMarkDeletedTables((pre) => !pre)}
handleMarkDeletedTablesFromFilterOnly={() =>
setMarkDeletedTablesFromFilterOnly((pre) => !pre)
handleMarkAllDeletedTables={() =>
setMarkAllDeletedTables((pre) => !pre)
}
handleMarkDeletedTables={() => setMarkDeletedTables((pre) => !pre)}
handleProfileSample={(val) => setProfileSample(val)}
handleQueryLogDuration={(val) => setQueryLogDuration(val)}
handleResultLimit={setResultLimit}
@ -749,8 +748,8 @@ const AddIngestion = ({
includeView={includeView}
ingestSampleData={ingestSampleData}
ingestionName={ingestionName}
markAllDeletedTables={markAllDeletedTables}
markDeletedTables={markDeletedTables}
markDeletedTablesFromFilterOnly={markDeletedTablesFromFilterOnly}
mlModelFilterPattern={mlModelFilterPattern}
pipelineFilterPattern={pipelineFilterPattern}
pipelineType={pipelineType}

View File

@ -42,7 +42,7 @@ const ConfigureIngestion = ({
includeView,
includeTags,
markDeletedTables,
markDeletedTablesFromFilterOnly,
markAllDeletedTables,
serviceCategory,
pipelineType,
showDatabaseFilter,
@ -70,7 +70,7 @@ const ConfigureIngestion = ({
handleIncludeView,
handleIncludeTags,
handleMarkDeletedTables,
handleMarkDeletedTablesFromFilterOnly,
handleMarkAllDeletedTables,
handleIngestSampleData,
handleDatasetServiceName,
handleQueryLogDuration,
@ -234,15 +234,15 @@ const ConfigureIngestion = ({
{getSeparator('')}
</Field>
)}
{!isNil(markDeletedTablesFromFilterOnly) && (
{!isNil(markAllDeletedTables) && (
<Field>
<div className="tw-flex tw-gap-1">
<label>Mark Deleted Tables from Filter Only</label>
<label>Mark All Deleted Tables</label>
<ToggleSwitchV1
checked={markDeletedTablesFromFilterOnly}
checked={markAllDeletedTables}
handleCheck={() => {
if (handleMarkDeletedTablesFromFilterOnly) {
handleMarkDeletedTablesFromFilterOnly();
if (handleMarkAllDeletedTables) {
handleMarkAllDeletedTables();
}
}}
testId="mark-deleted-filter-only"

View File

@ -72,7 +72,7 @@ export interface ConfigureIngestionProps {
includeView: boolean;
includeTags: boolean;
markDeletedTables?: boolean;
markDeletedTablesFromFilterOnly?: boolean;
markAllDeletedTables?: boolean;
enableDebugLog: boolean;
profileSample?: number;
ingestSampleData: boolean;
@ -98,7 +98,7 @@ export interface ConfigureIngestionProps {
handleIncludeView: () => void;
handleIncludeTags: () => void;
handleMarkDeletedTables?: () => void;
handleMarkDeletedTablesFromFilterOnly?: () => void;
handleMarkAllDeletedTables?: () => void;
handleEnableDebugLog: () => void;
handleIngestSampleData: () => void;
getIncludeValue: (value: string[], type: FilterPatternEnum) => void;

View File

@ -23,7 +23,7 @@ export const mockIngestionPipeline = {
config: {
type: 'DatabaseMetadata',
markDeletedTables: true,
markDeletedTablesFromFilterOnly: false,
markAllDeletedTables: false,
includeTables: true,
includeViews: true,
includeTags: true,