Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (1)
Super Collaborator

Hi,

In this article, let us take a look at how to delete a schema from the Hortonworks Schema Registry.

Let me start with a word of caution that the approach is not recommended for Production systems and use these steps at your own risk. Also, would like to thank Brian Goerlitz for his ideas towards this post.

Currently it is not possible to delete a schema from the UI. So the steps below shows how to delete the schema from its backend datastore. I am using MySQL as my backend datastore for the schema registry and the queries will be related to MySQL. You should change them according to your database type.


Step 1
Verify that the two tables schema_version_info and schema_field_info have CASCADE ON UPDATE and CASCADE ON DELETE enabled.

This can be done by the below queries on information_schema database

select UPDATE_RULE,DELETE_RULE,REFERENCED_TABLE_NAME from REFERENTIAL_CONSTRAINTS where table_name='schema_version_info';
and
select UPDATE_RULE,DELETE_RULE,REFERENCED_TABLE_NAME from REFERENTIAL_CONSTRAINTS where table_name='schema_field_info';

93544-screen-shot-2018-11-08-at-104543-pm.png

Step 2
Stop Schema Registry Service from Ambari

Step 3
Backup the database

Below is the content of my schema registry before the delete operation and I am interested in deleting the person.demographic.details schema

93545-screen-shot-2018-11-08-at-103320-pm.png


Step 4
Identify the id of the schema to be deleted.

For this, you need to switch to the database provisioned to store the schema registry information. In my case it is 'registry' and issue the select query.

select id from schema_metadata_info where name ='person.demographic.details';

93546-screen-shot-2018-11-08-at-105206-pm.png


Step 5
Delete the schema from schema_serdes_mapping based on the id we queried in step 4 above

delete from schema_serdes_mapping where schemaMetadataId=1;

Step 6
Delete the schema from schema_metadata_info based on the id we queried in step 4 above

delete from schema_metadata_info where id =1;

93547-screen-shot-2018-11-08-at-105915-pm.png

We observe that the schema has been deleted from the tables.

Step 7
Start the schema registry service via Ambari, and verify that the schema is deleted.

93548-screen-shot-2018-11-08-at-103447-pm.png


Optionally we can recreate the schema with the same name on the UI and explore the front-end and back-end to ensure the schema can be re-created with no issues.

93549-screen-shot-2018-11-08-at-110541-pm.png

93550-screen-shot-2018-11-08-at-110719-pm.png

We observe that the new schema was created with the same name and a different id.

Thanks
-Arun A K-

697 Views
Comments
Super Collaborator

Tested against HDF Version 3.1.0

Super Guru

Tested with HDF 3.2 as well.

Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
2 of 2
Last update:
‎08-17-2019 05:50 AM
Updated by:
 
Contributors
Top Kudoed Authors