-
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.
Merge branch 'master' into feature/278-docker-zio-compatibility
- Loading branch information
Showing
26 changed files
with
725 additions
and
311 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
database/src/main/postgres/runs/V1.9.12__get_partitioning.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,82 @@ | ||
/* | ||
* 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( | ||
IN i_partitioning JSONB, | ||
OUT status INTEGER, | ||
OUT status_text TEXT, | ||
OUT id BIGINT, | ||
OUT o_partitioning JSONB, | ||
OUT author TEXT | ||
) RETURNS record AS | ||
$$ | ||
------------------------------------------------------------------------------- | ||
-- | ||
-- Function: runs.get_partitioning(1) | ||
-- Retrieves a partitioning by its JSONB representation. | ||
-- | ||
-- Parameters: | ||
-- i_partitioning - partitioning to search for, a valid example: | ||
-- { | ||
-- "keys": ["one", "two", "three"], | ||
-- "version": 1, | ||
-- "keysToValues": { | ||
-- "one": "DatasetA", | ||
-- "two": "Version1", | ||
-- "three": "2022-12-20" | ||
-- } | ||
-- } | ||
-- | ||
-- Returns: | ||
-- status - status of the operation: | ||
-- status_text - textual representation of the status | ||
-- id - ID of the partitioning | ||
-- o_partitioning - partitioning data | ||
-- author - author of the partitioning | ||
-- | ||
-- Status codes: | ||
-- 11 - OK | ||
-- 41 - Partitioning not found | ||
-- | ||
------------------------------------------------------------------------------- | ||
BEGIN | ||
-- Initialize status and status_text | ||
status := 41; | ||
status_text := 'Partitioning not found'; | ||
|
||
-- Retrieve partitioning ID | ||
id := runs._get_id_partitioning(i_partitioning); | ||
|
||
-- If ID is found, retrieve partitioning details | ||
IF id IS NOT NULL THEN | ||
SELECT GPBI.id, GPBI.partitioning, GPBI.author | ||
INTO get_partitioning.id, get_partitioning.o_partitioning, get_partitioning.author | ||
FROM runs.get_partitioning_by_id(id) AS GPBI; | ||
|
||
-- Update status if partitioning is found | ||
IF FOUND THEN | ||
status := 11; | ||
status_text := 'OK'; | ||
END IF; | ||
END IF; | ||
|
||
RETURN; | ||
END; | ||
$$ | ||
LANGUAGE plpgsql IMMUTABLE SECURITY DEFINER; | ||
|
||
ALTER FUNCTION runs.get_partitioning(i_partitioning JSONB) OWNER TO atum_owner; | ||
GRANT EXECUTE ON FUNCTION runs.get_partitioning(i_partitioning JSONB) TO atum_user; |
117 changes: 117 additions & 0 deletions
117
database/src/test/scala/za/co/absa/atum/database/runs/GetPartitioningIntegrationTests.scala
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,117 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package za.co.absa.atum.database.runs | ||
|
||
import io.circe.Json | ||
import za.co.absa.balta.DBTestSuite | ||
import za.co.absa.balta.classes.JsonBString | ||
|
||
class GetPartitioningIntegrationTests extends DBTestSuite { | ||
|
||
private val fnCreatePartitioning = "runs.create_partitioning" | ||
private val fnGetPartitioning = "runs.get_partitioning" | ||
|
||
private val partitioning1Value = | ||
""" | ||
|{ | ||
| "version":1, | ||
| "keys":["key1","key2","key3","key4"], | ||
| "keysToValues":{ | ||
| "key1":"valueX", | ||
| "key2":"valueY", | ||
| "key3":"valueZ", | ||
| "key4":"valueA" | ||
| } | ||
|} | ||
|""".stripMargin | ||
|
||
private val partitioning1 = JsonBString(partitioning1Value) | ||
|
||
private val partitioning2 = JsonBString( | ||
""" | ||
|{ | ||
| "version":1, | ||
| "keys":["key1","key2","key3","key4"], | ||
| "keysToValues":{ | ||
| "key1":"valueX", | ||
| "key2":"valueX", | ||
| "key3":"valueX", | ||
| "key4":"valueX" | ||
| } | ||
|} | ||
|""".stripMargin | ||
) | ||
|
||
test("Existing (correct) partitioning is returned") { | ||
val partitioning1ID = function(fnCreatePartitioning) | ||
.setParam("i_partitioning", partitioning1) | ||
.setParam("i_by_user", "Fantômas") | ||
.setParamNull("i_parent_partitioning_id") | ||
.execute { queryResult => | ||
assert(queryResult.hasNext) | ||
val row = queryResult.next() | ||
assert(row.getInt("status").contains(11)) | ||
assert(row.getString("status_text").contains("Partitioning created")) | ||
row.getLong("id_partitioning").get | ||
} | ||
|
||
function(fnCreatePartitioning) | ||
.setParam("i_partitioning", partitioning2) | ||
.setParam("i_by_user", "Fantômas") | ||
.setParamNull("i_parent_partitioning_id") | ||
.execute { queryResult => | ||
assert(queryResult.hasNext) | ||
val row = queryResult.next() | ||
assert(row.getInt("status").contains(11)) | ||
assert(row.getString("status_text").contains("Partitioning created")) | ||
} | ||
|
||
function(fnGetPartitioning) | ||
.setParam("i_partitioning", partitioning1) | ||
.execute { queryResult => | ||
assert(queryResult.hasNext) | ||
val row = queryResult.next() | ||
assert(row.getInt("status").contains(11)) | ||
assert(row.getString("status_text").contains("OK")) | ||
assert(row.getLong("id").contains(partitioning1ID)) | ||
assert { | ||
val retrievedPartitioningAsJson = Json.fromString(row.getJsonB("o_partitioning").get.value) | ||
val expectedPartitioningAsJson = Json.fromString(partitioning1Value) | ||
retrievedPartitioningAsJson \\ "keysToValues" == expectedPartitioningAsJson \\ "keysToValues" && | ||
retrievedPartitioningAsJson \\ "keys" == expectedPartitioningAsJson \\ "keys" | ||
} | ||
assert(row.getString("author").contains("Fantômas")) | ||
assert(!queryResult.hasNext) | ||
} | ||
} | ||
|
||
test("Non-existent partitioning is not returned") { | ||
function(fnGetPartitioning) | ||
.setParam("i_partitioning", partitioning1) | ||
.execute { queryResult => | ||
assert(queryResult.hasNext) | ||
val row = queryResult.next() | ||
assert(row.getInt("status").contains(41)) | ||
assert(row.getString("status_text").contains("Partitioning not found")) | ||
assert(row.getLong("id").isEmpty) | ||
assert(row.getJsonB("o_partitioning").isEmpty) | ||
assert(row.getString("author").isEmpty) | ||
assert(!queryResult.hasNext) | ||
} | ||
} | ||
|
||
} |
45 changes: 0 additions & 45 deletions
45
server/src/main/scala/za/co/absa/atum/server/Constants.scala
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.