Ram Narayan Balaji 9fd34c8f89
Feat #20586 Implementation of Custom Metrics Measurement Units (#22876)
* Initial Implementation of Custom Metrics Measurement Units

* Update generated TypeScript types

* Removed Regex patterns and length validations as they are not needed

* Add a new column with index for custom units

* Remove comments in the sql

* update ui and add playwright

* fix metric selector

* fix tests

* address feedbacks

* remove unused field

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Karan Hotchandani <33024356+karanh37@users.noreply.github.com>
Co-authored-by: karanh37 <karanh37@gmail.com>
2025-09-11 15:14:38 +05:30

28 lines
1.1 KiB
SQL

-- Add "Data Product Domain Validation" rule to existing entityRulesSettings configuration
UPDATE openmetadata_settings
SET json = jsonb_set(
json,
'{entitySemantics}',
(json->'entitySemantics') || jsonb_build_object(
'name', 'Data Product Domain Validation',
'description', 'Validates that Data Products assigned to an entity match the entity''s domains.',
'rule', '{"validateDataProductDomainMatch":[{"var":"dataProducts"},{"var":"domains"}]}',
'enabled', true,
'provider', 'system'
)::jsonb,
true
)
WHERE configtype = 'entityRulesSettings'
AND json->'entitySemantics' IS NOT NULL
AND NOT EXISTS (
SELECT 1
FROM jsonb_array_elements(json->'entitySemantics') AS rule
WHERE rule->>'name' = 'Data Product Domain Validation'
);
-- Add generated column for customUnitOfMeasurement
ALTER TABLE metric_entity
ADD COLUMN customUnitOfMeasurement VARCHAR(256)
GENERATED ALWAYS AS ((json->>'customUnitOfMeasurement')::VARCHAR(256)) STORED;
-- Add index on the column
CREATE INDEX idx_metric_custom_unit ON metric_entity(customUnitOfMeasurement);