OpenMetadata/bootstrap/sql/migrations/native/1.12.0/postgres/postDataMigrationSQLScript.sql
Teddy 6cc7c24278
ISSUE #2681 - Add Missing test parameters in PSQL (#25323)
* fix(dq): psql migration for row insert test parameters

* fix(dq): use name and add trailing new line

* Fix description formatting in postDataMigrationSQLScript.sql

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-16 12:09:15 +01:00

75 lines
2.7 KiB
SQL

UPDATE test_definition
SET json = jsonb_set(
json::jsonb,
'{supportedServices}',
'["Snowflake", "BigQuery", "Athena", "Redshift", "Postgres", "MySQL", "Mssql", "Oracle", "Trino", "SapHana"]'::jsonb
)
WHERE name = 'tableDiff'
AND (
json->'supportedServices' IS NULL
OR json->'supportedServices' = '[]'::jsonb
);
-- Add parameters back in tableRowInsertedCountToBeBetween if missing
UPDATE test_definition
SET json = jsonb_set(
json,
'{parameterDefinition}',
(
SELECT jsonb_agg(elem)
FROM (
-- Keep existing elements
SELECT elem
FROM jsonb_array_elements(json -> 'parameterDefinition') AS elem
UNION ALL
-- Add columnName if not exists
SELECT jsonb_build_object(
'name', 'columnName',
'dataType', 'STRING',
'required', true,
'description', 'Name of the Column to check for new rows inserted.',
'displayName', 'Column Name',
'optionValues', '[]'::jsonb
)
WHERE NOT EXISTS (
SELECT 1 FROM jsonb_array_elements(json -> 'parameterDefinition') AS e
WHERE e ->> 'name' = 'columnName'
)
UNION ALL
-- Add rangeType if not exists
SELECT jsonb_build_object(
'name', 'rangeType',
'dataType', 'STRING',
'required', true,
'description', 'One of ''HOUR'', ''DAY'', ''MONTH'', ''YEAR'' to specify the range type for checking new rows inserted.',
'displayName', 'Range Type',
'optionValues', '[]'::jsonb
)
WHERE NOT EXISTS (
SELECT 1 FROM jsonb_array_elements(json -> 'parameterDefinition') AS e
WHERE e ->> 'name' = 'rangeType'
)
UNION ALL
-- Add rangeInterval if not exists
SELECT jsonb_build_object(
'name', 'rangeInterval',
'dataType', 'INT',
'required', true,
'description', 'Interval Range. E.g. if rangeInterval=1 and rangeType=DAY, we''ll check the numbers of rows inserted where columnName=-1 DAY',
'displayName', 'Interval',
'optionValues', '[]'::jsonb
)
WHERE NOT EXISTS (
SELECT 1 FROM jsonb_array_elements(json -> 'parameterDefinition') AS e
WHERE e ->> 'name' = 'rangeInterval'
)
) AS combined
)
)
WHERE name = 'tableRowInsertedCountToBeBetween';