Drop features
Feature deletion in FeatureQL allows you to remove features from the registry when they're no longer needed. The system enforces dependency constraints to maintain data integrity.
To run the examples of this page, you must previously have created the features in the feature registry by running the queries of the Create features page.
Single feature deletion
Based on the available examples, here's how feature deletion works:
DROP FEATURE IF EXISTS FM.TUTORIALS.CAD.FEATURE1;
This removes a single feature from the registry. The IF EXISTS
clause prevents errors if the feature doesn't exist.
Dependency constraints
When dropping features that have dependencies, FeatureQL prevents deletion to keep the registry consistent:
-- This will fail if FEATURE4 depends on FEATURE2 or FEATURE3
DROP FEATURES IF EXISTS FM.TUTORIALS.CAD.FEATURE2, FM.TUTORIALS.CAD.FEATURE3;
The error message clearly identifies which dependent features must be handled first:
ERROR: You must drop all dependant features {'FM.TUTORIALS.CAD.FEATURE4'} before dropping this feature.
Multiple feature deletion
You can drop multiple features in a single statement. You don't need to drop dependencies first.
DROP FEATURES IF EXISTS FM.TUTORIALS.CAD.FEATURE2, FM.TUTORIALS.CAD.FEATURE3, FM.TUTORIALS.CAD.FEATURE4;
You can also drop features in a multiple statement.
START TRANSACTION;
DROP FEATURE IF EXISTS FM.TUTORIALS.CAD.FEATURE2;
DROP FEATURE IF EXISTS FM.TUTORIALS.CAD.FEATURE3;
DROP FEATURE IF EXISTS FM.TUTORIALS.CAD.FEATURE4;
COMMIT;
As long as the multiple statements are in the same transaction, the dependencies will be resolved correctly to delete the features in the correct order.
Mixing DROP and CREATE statements in a single transaction
You can mix DROP and CREATE statements in the same transaction and the system will resolve the dependencies correctly, by dropping the dependencies first, then the features, then the CREATE statements.
You can also use CREATE OR REPLACE
statements that will replace the features with the new definition.