Skip to content
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

#305 getAncestors Database functionality. #311

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ABLL526
Copy link

@ABLL526 ABLL526 commented Jan 21, 2025

This PR is strictly for the getAncestors DataBase Functionality.
Any feedback is welcome.

1. Made the necessary changes as mentioned by the team.
3. Made the necessary changes to the getAncestors Database functionality.
@ABLL526 ABLL526 added good first issue Good for newcomers DB Issues touching the Database part of the project Server Issues touching the server part of the project labels Jan 21, 2025
Copy link

JaCoCo model module code coverage report - scala 2.13.11

Overall Project 58.76% 🍏

There is no coverage information present for the Files changed

Copy link

JaCoCo agent module code coverage report - scala 2.13.11

Overall Project 78.2% 🍏

There is no coverage information present for the Files changed

Copy link

JaCoCo reader module code coverage report - scala 2.13.11

Overall Project 90.86% 🍏

There is no coverage information present for the Files changed

Copy link

JaCoCo server module code coverage report - scala 2.13.11

Overall Project 68.39% 🍏

There is no coverage information present for the Files changed

@ABLL526 ABLL526 self-assigned this Jan 21, 2025
@ABLL526 ABLL526 changed the title Added the getAncestors Database functionality. #305 getAncestors Database functionality. Jan 21, 2025
@ABLL526 ABLL526 added the enhancement New feature or request label Jan 21, 2025
-- has_more - Flag indicating if there are more partitionings available

-- Status codes:
-- 11 - OK
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super important I suppose but still, according to https://github.com/AbsaOSS/fa-db/blob/master/core/src/main/scala/za/co/absa/db/fadb/status/README.md we would maybe want to use status 10 instead of 11.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as mentioned

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see 11. 😉

--
-------------------------------------------------------------------------------
DECLARE
partitionCreateAt TIMESTAMP;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partitioning

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed as mentioned

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the local variables start with _ by convention - avoids confusion with OUT parameters and column names.

LIMIT i_limit
OFFSET i_offset;

IF FOUND THEN
Copy link
Collaborator

@salamonpavel salamonpavel Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You return status already from the query. And there is no reason to return 42. There are no records returned if ancestors don't exist. Have a look at runs.get_partitioning_checkpoints.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We then simply process the data as

if (results.nonEmpty && results.head.hasMore) ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense although. From runs.get_paritioning_checkpoint_v2 it has a similar logic to this.
What I will do is comment it out for now and determine if it is necessary.

* limitations under the License.
*/

CREATE OR REPLACE FUNCTION runs.get_ancestors(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would name it to runs.get_partitioning_ancestors, otherwise the name is little ambiguous.

-------------------------------------------------------------------------------
--
-- Function: runs.get_ancestors(3)
-- Returns Ancestors' partition ID for the given id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Returns Ancestors' partition ID for the given id
-- Returns the ids and partitionings of the ancestors of the given partitioin id

I think this explains the content better.

--
-- Parameters:
-- i_id_partitioning - id that we asking the Ancestors for
-- i_limit - (optional) maximum number of partitionings to return, default is 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important:
Don't we used 10 as the default limit in our functions?

-- has_more - Flag indicating if there are more partitionings available

-- Status codes:
-- 11 - OK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see 11. 😉

--
-------------------------------------------------------------------------------
DECLARE
partitionCreateAt TIMESTAMP;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the local variables start with _ by convention - avoids confusion with OUT parameters and column names.

-- Status codes:
-- 11 - OK
-- 41 - Partitioning not found
-- 42 - Ancestor Partitioning not found
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need for this status (and error one furthermore). If no ancestors found, it's OK, simple an empty list (particularly with paging).

WHERE
PF2.fk_partitioning = i_id_partitioning
AND
P.created_at < partitionCreateAt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this condition?
Actually I think the whole query is incorrect, unfortunately.
It should be

FROM
            flows.partitioning_to_flow PF
                INNER JOIN flows.flows F ON F.id_flow = PF.id_flow
                INNER JOIN runs.partitionings P ON P.id_partitioning = F.fk_primary_partitioning
        WHERE
            PF.fk_partitioning = i_id_partitioning AND
            P.id_partitioning IS DISTINCT FROM i_id_partitioning 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB Issues touching the Database part of the project enhancement New feature or request good first issue Good for newcomers Server Issues touching the server part of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GET /partitionings/{partId}/parents -> returns all ancestors, not just direct ones
3 participants