Minor: Remove 'owner' field from JSON in various entities (#17290)

* Remove owner field from json in various entities

* Add Psql migrations for owner

* Modify operator type for query

* chore: Update table_entity JSON structure to include dataModel owners
This commit is contained in:
Ayush Shah 2024-08-05 20:28:07 +05:30 committed by GitHub
parent 1b6b48e7be
commit ab1e400990
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 100 additions and 0 deletions

View File

@ -232,3 +232,55 @@ UPDATE ingestion_pipeline_entity
SET json = JSON_REMOVE(json, '$.owner', '$.service'); SET json = JSON_REMOVE(json, '$.owner', '$.service');
ALTER TABLE thread_entity ADD COLUMN domain VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.domain'); ALTER TABLE thread_entity ADD COLUMN domain VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.domain');
-- Remove owner from json from all entities
update api_collection_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update api_endpoint_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update api_service_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update bot_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update chart_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update dashboard_data_model_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update dashboard_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update dashboard_service_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update data_product_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update database_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update database_schema_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update dbservice_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update di_chart_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update domain_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update event_subscription_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update glossary_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update glossary_term_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update ingestion_pipeline_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update kpi_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update messaging_service_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update metadata_service_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update metric_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update ml_model_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update mlmodel_service_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update persona_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update pipeline_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update pipeline_service_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update policy_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update query_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update report_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update role_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update search_index_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update search_service_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update storage_container_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update storage_service_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update stored_procedure_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update table_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update team_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update thread_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update topic_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update type_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update user_entity set json = JSON_REMOVE(json, '$.owner') where json -> '$.owner' is not null;
update table_entity set json = JSON_SET(
JSON_REMOVE(json, '$.dataModel.owner'),
'$.dataModel.owners',
JSON_ARRAY(
JSON_EXTRACT(json, '$.dataModel.owner')
)
) where json -> '$.dataModel.owner' is not null;

View File

@ -218,3 +218,51 @@ SET json = json::jsonb #- '{service}'
WHERE json #> '{service}' IS NOT NULL; WHERE json #> '{service}' IS NOT NULL;
ALTER TABLE thread_entity ADD COLUMN domain VARCHAR(256) GENERATED ALWAYS AS (json ->> 'domain') STORED; ALTER TABLE thread_entity ADD COLUMN domain VARCHAR(256) GENERATED ALWAYS AS (json ->> 'domain') STORED;
-- Remove owner from json from all entities
update api_collection_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update api_endpoint_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update api_service_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update bot_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update chart_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update dashboard_data_model_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update dashboard_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update dashboard_service_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update data_product_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update database_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update database_schema_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update dbservice_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update di_chart_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update domain_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update event_subscription_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update glossary_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update glossary_term_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update ingestion_pipeline_entity set json = json::jsonb#-'{owner}' where json::jsonb #>> '{owner}' is not null;
update kpi_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update messaging_service_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update metadata_service_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update metric_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update ml_model_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update mlmodel_service_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update persona_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update pipeline_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update pipeline_service_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update policy_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update query_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update report_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update role_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update search_index_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update search_service_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update storage_container_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update storage_service_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update stored_procedure_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update table_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update team_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update thread_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update topic_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update type_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update user_entity set json = json#-'{owner}' where json #>> '{owner}' is not null;
update table_entity set json = jsonb_set(json#-'{dataModel,owner}', '{dataModel,owners}',
jsonb_build_array(json#>'{dataModel,owner}')) where json #>> '{dataModel,owner}' is not null;