Skip to content

Commit

Permalink
Minor: Remove 'owner' field from JSON in various entities (#17290)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ayush-shah authored and IceS2 committed Aug 5, 2024
1 parent 5116fed commit 9819d0f
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
52 changes: 52 additions & 0 deletions bootstrap/sql/migrations/native/1.5.0/mysql/schemaChanges.sql
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,55 @@ UPDATE ingestion_pipeline_entity
SET json = JSON_REMOVE(json, '$.owner', '$.service');

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;
48 changes: 48 additions & 0 deletions bootstrap/sql/migrations/native/1.5.0/postgres/schemaChanges.sql
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,51 @@ SET json = json::jsonb #- '{service}'
WHERE json #> '{service}' IS NOT NULL;

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;

0 comments on commit 9819d0f

Please sign in to comment.