feat(FILE_ARCHIVER): Update SQL query in ARCHIVE_TABLE_DATA for improved archival statistics and column order consistency
This commit is contained in:
@@ -483,6 +483,12 @@ AS
|
|||||||
-- FILE_COUNT, ROW_COUNT, TOTAL_SIZE: all files regardless of workflow success (never zero due to workflow filter)
|
-- FILE_COUNT, ROW_COUNT, TOTAL_SIZE: all files regardless of workflow success (never zero due to workflow filter)
|
||||||
-- OVER_ARCH_THRESOLD_*: IS_WORKFLOW_SUCCESS_REQUIRED-aware count of eligible files
|
-- OVER_ARCH_THRESOLD_*: IS_WORKFLOW_SUCCESS_REQUIRED-aware count of eligible files
|
||||||
-- WORKFLOW_SUCCESS_*: informational count of files with WORKFLOW_SUCCESSFUL='Y'
|
-- WORKFLOW_SUCCESS_*: informational count of files with WORKFLOW_SUCCESSFUL='Y'
|
||||||
|
-- Column order MUST match A_TABLE_STAT column definition order for positional INTO vStats to work:
|
||||||
|
-- 1:A_TABLE_STAT_KEY, 2:A_SOURCE_FILE_CONFIG_KEY, 3:TABLE_NAME, 4:CREATED, 5:ARCHIVAL_STRATEGY,
|
||||||
|
-- 6:ARCH_MINIMUM_AGE_MONTHS, 7:ARCH_THRESHOLD_DAYS, 8:IS_WORKFLOW_SUCCESS_REQUIRED,
|
||||||
|
-- 9:FILE_COUNT, 10:ROW_COUNT, 11:TOTAL_SIZE,
|
||||||
|
-- 12:OVER_ARCH_THRESOLD_FILE_COUNT, 13:OVER_ARCH_THRESOLD_ROW_COUNT, 14:OVER_ARCH_THRESOLD_TOTAL_SIZE,
|
||||||
|
-- 15:WORKFLOW_SUCCESS_FILE_COUNT, 16:WORKFLOW_SUCCESS_ROW_COUNT, 17:WORKFLOW_SUCCESS_TOTAL_SIZE
|
||||||
vQuery :=
|
vQuery :=
|
||||||
'with tmp as (
|
'with tmp as (
|
||||||
select
|
select
|
||||||
@@ -506,23 +512,23 @@ AS
|
|||||||
group by filename
|
group by filename
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
NULL as A_TABLE_STAT_KEY
|
NULL as A_TABLE_STAT_KEY
|
||||||
,'||pSourceFileConfigKey||' as A_SOURCE_FILE_CONFIG_KEY
|
,'||pSourceFileConfigKey||' as A_SOURCE_FILE_CONFIG_KEY
|
||||||
,'''||vTableName||''' as TABLE_NAME
|
,'''||vTableName||''' as TABLE_NAME
|
||||||
,count(*) as FILE_COUNT
|
,systimestamp as CREATED
|
||||||
,nvl(sum(case when ' || vOverThresholdWhereClause || ' then 1 else 0 end), 0) as OLD_FILE_COUNT
|
,'''||vSourceFileConfig.ARCHIVAL_STRATEGY||''' as ARCHIVAL_STRATEGY
|
||||||
,nvl(sum(row_count_per_file), 0) as ROW_COUNT
|
,'||COALESCE(TO_CHAR(vSourceFileConfig.MINIMUM_AGE_MONTHS), 'NULL')||' as ARCH_MINIMUM_AGE_MONTHS
|
||||||
,nvl(sum(case when ' || vOverThresholdWhereClause || ' then row_count_per_file else 0 end), 0) as OLD_ROW_COUNT
|
,'||COALESCE(TO_CHAR(vSourceFileConfig.ARCHIVE_THRESHOLD_DAYS), 'NULL')||' as ARCH_THRESHOLD_DAYS
|
||||||
,nvl(sum(r.bytes), 0) as TOTAL_SIZE
|
,'''||vSourceFileConfig.IS_WORKFLOW_SUCCESS_REQUIRED||''' as IS_WORKFLOW_SUCCESS_REQUIRED
|
||||||
,nvl(sum(case when ' || vOverThresholdWhereClause || ' then r.bytes else 0 end), 0) as OLD_BYTES
|
,count(*) as FILE_COUNT
|
||||||
,'||COALESCE(TO_CHAR(vSourceFileConfig.ARCHIVE_THRESHOLD_DAYS), 'NULL')||' as ARCHIVE_THRESHOLD_DAYS
|
,nvl(sum(row_count_per_file), 0) as ROW_COUNT
|
||||||
,systimestamp as CREATED
|
,nvl(sum(r.bytes), 0) as TOTAL_SIZE
|
||||||
,'''||vSourceFileConfig.ARCHIVAL_STRATEGY||''' as ARCHIVAL_STRATEGY
|
,nvl(sum(case when ' || vOverThresholdWhereClause || ' then 1 else 0 end), 0) as OVER_ARCH_THRESOLD_FILE_COUNT
|
||||||
,'||COALESCE(TO_CHAR(vSourceFileConfig.MINIMUM_AGE_MONTHS), 'NULL')||' as ARCH_MINIMUM_AGE_MONTHS
|
,nvl(sum(case when ' || vOverThresholdWhereClause || ' then row_count_per_file else 0 end), 0) as OVER_ARCH_THRESOLD_ROW_COUNT
|
||||||
,'''||vSourceFileConfig.IS_WORKFLOW_SUCCESS_REQUIRED||''' as IS_WORKFLOW_SUCCESS_REQUIRED
|
,nvl(sum(case when ' || vOverThresholdWhereClause || ' then r.bytes else 0 end), 0) as OVER_ARCH_THRESOLD_TOTAL_SIZE
|
||||||
,nvl(sum(case when workflow_successful = ''Y'' then 1 else 0 end), 0) as WORKFLOW_SUCCESS_FILE_COUNT
|
,nvl(sum(case when workflow_successful = ''Y'' then 1 else 0 end), 0) as WORKFLOW_SUCCESS_FILE_COUNT
|
||||||
,nvl(sum(case when workflow_successful = ''Y'' then row_count_per_file else 0 end), 0) as WORKFLOW_SUCCESS_ROW_COUNT
|
,nvl(sum(case when workflow_successful = ''Y'' then row_count_per_file else 0 end), 0) as WORKFLOW_SUCCESS_ROW_COUNT
|
||||||
,nvl(sum(case when workflow_successful = ''Y'' then r.bytes else 0 end), 0) as WORKFLOW_SUCCESS_TOTAL_SIZE
|
,nvl(sum(case when workflow_successful = ''Y'' then r.bytes else 0 end), 0) as WORKFLOW_SUCCESS_TOTAL_SIZE
|
||||||
from tmp_gr t
|
from tmp_gr t
|
||||||
join (SELECT * from DBMS_CLOUD.LIST_OBJECTS(
|
join (SELECT * from DBMS_CLOUD.LIST_OBJECTS(
|
||||||
credential_name => '''||CT_MRDS.ENV_MANAGER.gvCredentialName||''',
|
credential_name => '''||CT_MRDS.ENV_MANAGER.gvCredentialName||''',
|
||||||
|
|||||||
Reference in New Issue
Block a user