-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
166 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
database/src/main/postgres/runs/V1.8.1__get_partitioning_measures.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2021 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
CREATE OR REPLACE FUNCTION runs.get_partitioning_measures( | ||
IN i_partitioning JSONB, | ||
OUT status INTEGER, | ||
OUT status_text TEXT, | ||
OUT measure_name TEXT, | ||
OUT measured_columns TEXT[] | ||
) RETURNS SETOF record AS | ||
$$ | ||
------------------------------------------------------------------------------- | ||
-- | ||
-- Function: runs.get_partitioning_measures(1) | ||
-- Returns measures for the given partitioning | ||
-- | ||
-- Parameters: | ||
-- i_partitioning - partitioning we are asking the measures for | ||
-- | ||
-- Returns: | ||
-- status - Status code | ||
-- status_text - Status message | ||
-- measure_name - Name of the measure | ||
-- measured_columns - Array of columns associated with the measure | ||
|
||
-- Status codes: | ||
-- 11 - OK | ||
-- 41 - Partitioning not found | ||
-- | ||
------------------------------------------------------------------------------- | ||
|
||
DECLARE | ||
_fk_partitioning BIGINT; | ||
BEGIN | ||
_fk_partitioning = runs._get_id_partitioning(i_partitioning); | ||
|
||
IF _fk_partitioning IS NULL THEN | ||
status := 41; | ||
status_text := 'The partitioning does not exist.'; | ||
RETURN NEXT; | ||
RETURN; | ||
END IF; | ||
|
||
status := 11; | ||
status_text := 'OK'; | ||
|
||
RETURN QUERY | ||
SELECT status, status_text, md.measure_name, md.measured_columns | ||
FROM runs.measure_definitions AS md | ||
WHERE md.fk_partitioning = _fk_partitioning; | ||
|
||
END; | ||
$$ | ||
LANGUAGE plpgsql VOLATILE SECURITY DEFINER; | ||
|
||
ALTER FUNCTION runs.get_partitioning_measures(JSONB) OWNER TO atum_owner; | ||
GRANT EXECUTE ON FUNCTION runs.get_partitioning_measures(JSONB) TO atum_user; |
71 changes: 71 additions & 0 deletions
71
database/src/main/postgres/runs/V1.8.2__get_partitioning_additional_data.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2021 ABSA Group Limited | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
CREATE OR REPLACE FUNCTION runs.get_partitioning_additional_data( | ||
IN i_partitioning JSONB, | ||
OUT status INTEGER, | ||
OUT status_text TEXT, | ||
OUT ad_name TEXT, | ||
OUT ad_value TEXT | ||
) RETURNS SETOF record AS | ||
|
||
$$ | ||
------------------------------------------------------------------------------- | ||
-- | ||
-- Function: runs.get_partitioning_additional_data(1) | ||
-- Returns additional data for the given partitioning | ||
-- | ||
-- Parameters: | ||
-- i_partitioning - partitioning for requested additional data | ||
-- | ||
-- Returns: | ||
-- status - Status code | ||
-- status_text - Status message | ||
-- ad_name - Name of the additional data | ||
-- ad_value - Value of the additional data | ||
-- | ||
-- Status codes: | ||
-- 11 - OK | ||
-- 41 - Partitioning not found | ||
-- | ||
------------------------------------------------------------------------------- | ||
|
||
DECLARE | ||
_fk_partitioning BIGINT; | ||
BEGIN | ||
_fk_partitioning = runs._get_id_partitioning(i_partitioning); | ||
|
||
IF _fk_partitioning IS NULL THEN | ||
status := 41; | ||
status_text := 'The partitioning does not exist.'; | ||
RETURN NEXT; | ||
RETURN; | ||
END IF; | ||
|
||
status = 11; | ||
status_text = 'OK'; | ||
|
||
RETURN QUERY | ||
SELECT status, status_text, ad.ad_name, ad.ad_value | ||
FROM runs.additional_data AS ad | ||
WHERE ad.fk_partitioning = _fk_partitioning; | ||
|
||
END; | ||
$$ | ||
LANGUAGE plpgsql VOLATILE SECURITY DEFINER; | ||
|
||
ALTER FUNCTION runs.get_partitioning_additional_data(JSONB) OWNER TO atum_owner; | ||
GRANT EXECUTE ON FUNCTION runs.get_partitioning_additional_data(JSONB) TO atum_user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters