Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SNOW-57] re-process fileinventory tables #25

Merged
merged 3 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
USE SCHEMA {{database_name}}.synapse_raw; --noqa: JJ01,PRS,TMP
ALTER TABLE fileinventory ADD COLUMN snapshot_date DATE;
ALTER TABLE fileinventory CLUSTER BY (snapshot_date)

USE WAREHOUSE COMPUTE_MEDIUM;
TRUNCATE TABLE fileinventory;
-- initial load of data
copy into
fileinventory
from (
select
$1:bucket as bucket,
$1:e_tag as e_tag,
$1:encryption_status as encryption_status,
$1:intelligent_tiering_access_tier as intelligent_tiering_access_tier,
$1:is_delete_marker as is_delete_marker,
$1:is_latest as is_latest,
$1:is_multipart_uploaded as is_multipart_uploaded,
$1:key as key,
$1:last_modified_date as last_modified_date,
$1:object_owner as object_owner,
$1:size as size,
$1:storage_class as storage_class,
metadata$file_last_modified as snapshot_date
from
@{{stage_storage_integration}}_stage/inventory --noqa: TMP
)
pattern='.*defaultInventory/data/.*'
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use role accountadmin;
use schema {{database_name}}.synapse_raw; --noqa: JJ01,PRS,TMP
alter task refresh_synapse_warehouse_s3_stage_task suspend;
alter task append_to_fileinventory_task suspend;

create task if not exists append_to_fileinventory_task
user_task_managed_initial_warehouse_size = 'SMALL'
AFTER refresh_synapse_warehouse_s3_stage_task
as
copy into
fileinventory
from (
select
$1:bucket as bucket,
$1:e_tag as e_tag,
$1:encryption_status as encryption_status,
$1:intelligent_tiering_access_tier as intelligent_tiering_access_tier,
$1:is_delete_marker as is_delete_marker,
$1:is_latest as is_latest,
$1:is_multipart_uploaded as is_multipart_uploaded,
$1:key as key,
$1:last_modified_date as last_modified_date,
$1:object_owner as object_owner,
$1:size as size,
$1:storage_class as storage_class,
metadata$file_last_modified as snapshot_date
from
@{{stage_storage_integration}}_stage/inventory --noqa: TMP
)
pattern='.*defaultInventory/data/.*';

alter task append_to_fileinventory_task resume;
alter task refresh_synapse_warehouse_s3_stage_task resume;