Step One: Insert expired data for schema
INSERT INTO reporting_ocpusagelineitem_daily_summary (
report_period_id,
cluster_id,
cluster_alias,
usage_start,
usage_end,
namespace,
node,
resource_id,
pod_usage_cpu_core_hours,
pod_request_cpu_core_hours,
pod_effective_usage_cpu_core_hours,
pod_usage_memory_gigabyte_hours,
pod_request_memory_gigabyte_hours,
pod_effective_usage_memory_gigabyte_hours,
node_capacity_cpu_cores,
node_capacity_cpu_core_hours,
node_capacity_memory_gigabytes,
node_capacity_memory_gigabyte_hours,
cluster_capacity_cpu_core_hours,
cluster_capacity_memory_gigabyte_hours,
data_source,
source_uuid,
source,
year,
month,
day
)
VALUES
(2, 'test_purge','test_purge', DATE '2023-01-01', DATE '2023-01-01', 'test_purge', 'test_purge', 'test_purge', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'test_purge', 'test_purge', '6da12332-d489-4f20-ad4d-29872278442e', '2023', '6', '4'),
(2, 'test_purge','test_purge', DATE '2023-01-01', DATE '2023-01-01', 'test_purge', 'test_purge', 'test_purge', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'test_purge', 'test_purge', '6da12332-d489-4f20-ad4d-29872278442e', '2022', '6', '4'),
(2, 'test_purge','test_purge', DATE '2023-01-01', DATE'2023-01-01', 'test_purge', 'test_purge', 'test_purge', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'test_purge', 'test_purge', '6da12332-d489-4f20-ad4d-29872278442e', '2021', '5', '4'),
(2, 'test_purge','test_purge', DATE '2023-01-01', DATE '2023-01-01', 'test_purge', 'test_purge', 'test_purge', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'test_purge', 'test_purge', '123', '2023', '2', '4'),
(2, 'test_purge','test_purge', DATE '2023-01-01', DATE '2023-01-01', 'test_purge', 'test_purge', 'test_purge', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'test_purge', 'test_purge', '123', '2022', '1', '4'),
(2, 'test_purge','test_purge', DATE '2023-01-01', DATE'2023-01-01', 'test_purge', 'test_purge', 'test_purge', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'test_purge', 'test_purge', '123', '2021', '5', '4')
- Create a schema where the table does not exist:
CREATE SCHEMA no_ocp_table
- Create a separate schema where it does exist:
CREATE SCHEMA ocp_table_two
- create table on the
ocp_table_two
schema
CREATE TABLE IF NOT EXISTS reporting_ocpusagelineitem_daily_summary (
uuid varchar,
report_period_id int,
cluster_id varchar,
cluster_alias varchar,
data_source varchar,
usage_start date,
usage_end date,
namespace varchar,
node varchar,
resource_id varchar,
pod_labels varchar,
pod_usage_cpu_core_hours double,
pod_request_cpu_core_hours double,
pod_effective_usage_cpu_core_hours double,
pod_limit_cpu_core_hours double,
pod_usage_memory_gigabyte_hours double,
pod_request_memory_gigabyte_hours double,
pod_effective_usage_memory_gigabyte_hours double,
pod_limit_memory_gigabyte_hours double,
node_capacity_cpu_cores double,
node_capacity_cpu_core_hours double,
node_capacity_memory_gigabytes double,
node_capacity_memory_gigabyte_hours double,
cluster_capacity_cpu_core_hours double,
cluster_capacity_memory_gigabyte_hours double,
persistentvolumeclaim varchar,
persistentvolume varchar,
storageclass varchar,
volume_labels varchar,
persistentvolumeclaim_capacity_gigabyte double,
persistentvolumeclaim_capacity_gigabyte_months double,
volume_request_storage_gigabyte_months double,
persistentvolumeclaim_usage_gigabyte_months double,
source_uuid varchar,
infrastructure_usage_cost varchar,
csi_volume_handle varchar,
cost_category_id int,
source varchar,
year varchar,
month varchar,
day varchar
) WITH(format = 'PARQUET', partitioned_by=ARRAY['source', 'year', 'month', 'day'])
;
- Repeat step one on the
ocp_table_two
schema