-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
273 patch partitioningspartidparents #302
base: master
Are you sure you want to change the base?
Conversation
Feature 273 First Commit by Liam Leibrandt
Updated commit, updated tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be ignored.
For my use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be ignored.
For my use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is it good for?
If for private use, don't put it into the repository.
Amended get ancestors functionality.
@@ -32,3 +32,10 @@ to remove them or | |||
sbt flywayBaseline | |||
``` | |||
to set the current state as the baseline. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exact information is already in the readme file. Remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @salamonpavel will remove the file from the PR.
PartitioningWithIdDTO | ||
], Any] = { | ||
apiV2.get | ||
.in(V2Paths.Partitionings / path[Long]("partitioningId") / V2Paths.Partitionings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the path is very likely incorrect ...
according to this design #141 it should be /partitionings/{id}/parents
potentially we can thinks of using 'ancestors' instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, again I think I was doing some testing. I will change it as necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the path is very likely incorrect ... according to this design #141 it should be /partitionings/{id}/parents potentially we can thinks of using 'ancestors' instead
ancestors
is better IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah why not, I'm okay with it. ALthough, potentially consider writing something short about it here in our Vocabulary documentation section: https://github.com/AbsaOSS/atum-service?tab=readme-ov-file#Vocabulary
], Any] = { | ||
apiV2.get | ||
.in(V2Paths.Partitionings / path[Long]("partitioningId") / V2Paths.Parents / path[Long]("partitioningId") / V2Paths.Parents ) | ||
.in(query[String]("byUser")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be no query parameters, only request body ...
put the user into the body of the request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, will fix.
ParentPatchV2DTO | ||
], Any] = { | ||
apiV2.get | ||
.in(V2Paths.Partitionings / path[Long]("partitioningId") / V2Paths.Parents / path[Long]("partitioningId") / V2Paths.Parents ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, I think I was doing some testing. Will change to the correct path.
database/src/test/scala/za/co/absa/atum/database/runs/UpdateParentIntegrationTests.scala
Outdated
Show resolved
Hide resolved
...e/src/test/scala/za/co/absa/atum/database/runs/GetPartitioningMainFlowIntegrationTests.scala
Outdated
Show resolved
Hide resolved
@@ -33,7 +33,7 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.2.0") | |||
lazy val ow2Version = "9.5" | |||
lazy val jacocoVersion = "0.8.11-absa.1" | |||
|
|||
def jacocoUrl(artifactName: String): String = s"https://github.com/AbsaOSS/jacoco/releases/download/$jacocoVersion/org.jacoco.$artifactName-$jacocoVersion.jar" | |||
def jacocoUrl(artifactName: String): String = s"file:///C:/Users/ABLL526/Documents/GitHub/Jar-Store2/org.jacoco.$artifactName-$jacocoVersion.jar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was for my use only. Will remove the file from the PR.
@@ -46,4 +46,4 @@ addSbtPlugin("org.ow2.asm" % "asm" % ow2Version from ow2Url("asm")) | |||
addSbtPlugin("org.ow2.asm" % "asm-commons" % ow2Version from ow2Url("asm-commons")) | |||
addSbtPlugin("org.ow2.asm" % "asm-tree" % ow2Version from ow2Url("asm-tree")) | |||
|
|||
addSbtPlugin("za.co.absa.sbt" % "sbt-jacoco" % "3.4.1-absa.4" from "https://github.com/AbsaOSS/sbt-jacoco/releases/download/3.4.1-absa.4/sbt-jacoco-3.4.1-absa.4.jar") | |||
addSbtPlugin("za.co.absa.sbt" % "sbt-jacoco" % "3.4.1-absa.4" from "file:///C:/Users/ABLL526/Documents/GitHub/Jar-Store2/sbt-jacoco-3.4.1-absa.3.jar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was for my use only. Will remove the file from the PR.
database/src/test/scala/za/co/absa/atum/database/runs/GetAncestorsIntegrationTests.scala
Outdated
Show resolved
Hide resolved
PERFORM 1 FROM runs.partitionings WHERE id_partitioning = i_parent_id; | ||
IF NOT FOUND THEN | ||
status := 41; | ||
status_text := 'Parent Partitioning not found'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, we could distinguish was was not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
AND fk_flow != mainFlow | ||
); | ||
|
||
FOREACH var IN ARRAY flow_id LOOP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loops could be removed
* limitations under the License. | ||
*/ | ||
|
||
CREATE OR REPLACE FUNCTION runs.patch_partitioning_parent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function should set the relationship between the two partitions, considering the conditions are set. And based on input parameter(s) copy the metadata from parent to child.
Conditions to check:
- partition exists
- parent partition exists
- the relationship does not exist already (then it's not an error, just no-op)
- a reverse relationship does not exist
Metadata to copy, if input parameters says so: - measures
- additional data
partitioningId: Long, | ||
parentPartitioningID: Long, | ||
byUser: String | ||
): IO[ErrorResponse, SingleSuccessResponse[ParentPatchV2DTO]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about the return value. Usually PATCH returns updated resource. In our case though we edit/establish relationship in the db. I wonder if instead we should return 200 OK with partitioning and all its parent partitionings or return 200 Ok without data or 204 No Content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am for 200 Ok without any data, or 204 No Content.
- the Id makes no sense
- the partitioning doesn't give much value
- and partitioning with all parents while occasionally useful could be taxing on the DB - better to request explicitly for those rare occasions
server/src/main/scala/za/co/absa/atum/server/api/database/runs/functions/GetAncestors.scala
Outdated
Show resolved
Hide resolved
flow_id := array( | ||
SELECT fk_flow AS flow_id | ||
FROM flows.partitioning_to_flow | ||
WHERE fk_partitioning = i_partitioning_id | ||
AND fk_flow != mainFlow | ||
); | ||
|
||
FOREACH var IN ARRAY flow_id LOOP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Work with Arrays in PG is nto very effective. It's discouraged to operate on them, only use them as input or output.
Particularly bad is to do a FOR loop over them.
database/src/test/scala/za/co/absa/atum/database/runs/UpdateParentIntegrationTests.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is it good for?
If for private use, don't put it into the repository.
partitioningId: Long, | ||
parentPartitioningID: Long, | ||
byUser: String | ||
): IO[ErrorResponse, SingleSuccessResponse[ParentPatchV2DTO]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am for 200 Ok without any data, or 204 No Content.
- the Id makes no sense
- the partitioning doesn't give much value
- and partitioning with all parents while occasionally useful could be taxing on the DB - better to request explicitly for those rare occasions
PartitioningWithIdDTO | ||
], Any] = { | ||
apiV2.get | ||
.in(V2Paths.Partitionings / path[Long]("partitioningId") / V2Paths.Partitionings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the path is very likely incorrect ... according to this design #141 it should be /partitionings/{id}/parents potentially we can thinks of using 'ancestors' instead
ancestors
is better IMHO.
@@ -32,6 +32,12 @@ trait PartitioningController { | |||
partitioningSubmitDTO: PartitioningSubmitV2DTO | |||
): IO[ErrorResponse, (SingleSuccessResponse[PartitioningWithIdDTO], String)] | |||
|
|||
def patchPartitioningParentV2( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion: try to create smaller PRs. In this case, all this could be split into 2 PRs:
- SQL stuff only, with Balta tests that would test proposed DB functions
- Scala part related to the backend - controller, service, repository, scala classes related to DB function wrapping/calls, etc
Also, not only splitting, but approaching this as a 2 step process can save you time, i.e. no need to implement the second part if your DB functions are not yet working or aren't satisfying API and/or functionality completely
.../main/scala/za/co/absa/atum/server/api/database/runs/functions/PatchPartitioningParent.scala
Show resolved
Hide resolved
: PublicEndpoint[(Long, Long, String), ErrorResponse, SingleSuccessResponse[ | ||
ParentPatchV2DTO | ||
], Any] = { | ||
apiV2.get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also should be patch
right? Not get
server/src/main/scala/za/co/absa/atum/server/api/http/Routes.scala
Outdated
Show resolved
Hide resolved
package za.co.absa.atum.server.api.http | ||
|
||
import org.mockito.Mockito.{mock, when} | ||
import sttp.client3.circe.asJson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few unused imports below
This is specifically for the database portion. 1. Changed functionality to simply add a parent. 2. Can copy the Measurements from parent. 3. Can copy the Additional Data from parent.
This is specifically for the database portion. 1. Made the necessary changes as mentioned by the team.
1. Made the necessary changes as mentioned by the team. 2. Made the necessary changes to the add parent Database functionality. 3. Made the necessary changes to the get ancestors Database functionality. 4. Made the necessary changes to the get ancestors Scala implementation. I still need to add the add parents Scala functionality.
Adding get Ancestors feature: