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

#303: Get flow checkpoints refactoring #304

Merged
merged 21 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ utils/resources/*.conf
/server/certs/
/server/selfsigned.crt
/server/selfsigned.p12
/.bloop/
Copy link
Contributor

Choose a reason for hiding this comment

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

❓😉

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know which plugin/tool does that but there was .bloop folder generated which I believe shouldn't be part of VCS.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CREATE OR REPLACE FUNCTION flows.get_flow_checkpoints(
IN i_checkpoints_limit INT DEFAULT 5,
IN i_offset BIGINT DEFAULT 0,
IN i_checkpoint_name TEXT DEFAULT NULL,
IN i_latest_first BOOLEAN DEFAULT TRUE,
OUT status INTEGER,
OUT status_text TEXT,
OUT id_checkpoint UUID,
Expand Down Expand Up @@ -61,6 +62,7 @@ $$
-- i_checkpoints_limit - (optional) maximum number of checkpoint to return, returns all of them if NULL
-- i_offset - (optional) offset for checkpoints pagination
-- i_checkpoint_name - (optional) if specified, returns data related to particular checkpoint's name
-- i_latest_first - (optional) if true, checkpoints are ordered by process_start_time in descending order
--
-- Note: i_checkpoint_limit and i_offset are used for pagination purposes;
-- checkpoints are ordered by process_start_time in descending order
Expand Down Expand Up @@ -132,7 +134,13 @@ BEGIN
JOIN flows.partitioning_to_flow PF ON C.fk_partitioning = PF.fk_partitioning
WHERE PF.fk_flow = i_flow_id
AND (i_checkpoint_name IS NULL OR C.checkpoint_name = i_checkpoint_name)
ORDER BY C.process_start_time DESC
ORDER BY
CASE
WHEN i_latest_first THEN C.process_start_time
END DESC,
CASE
WHEN NOT i_latest_first THEN C.process_start_time
END ASC
Copy link
Contributor

Choose a reason for hiding this comment

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

This is tricky on NULL.
Would use an ELSE statement. And probably flip them. So the default is still DESC

Copy link
Contributor

Choose a reason for hiding this comment

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

Or just use a local variable at the beginning
_latest_first := coalesce(i_latest_first, TRUE);

LIMIT i_checkpoints_limit OFFSET i_offset
)
SELECT
Expand All @@ -159,9 +167,15 @@ BEGIN
runs.measure_definitions MD ON M.fk_measure_definition = MD.id_measure_definition
INNER JOIN
runs.partitionings P ON LC.fk_partitioning = P.id_partitioning
ORDER BY LC.process_start_time DESC;
ORDER BY
CASE
WHEN i_latest_first THEN LC.process_start_time
END DESC,
CASE
WHEN NOT i_latest_first THEN LC.process_start_time
END ASC;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

used the coalesce

END;
$$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER;

GRANT EXECUTE ON FUNCTION flows.get_flow_checkpoints(BIGINT, INT, BIGINT, TEXT) TO atum_owner;
GRANT EXECUTE ON FUNCTION flows.get_flow_checkpoints(BIGINT, INT, BIGINT, TEXT, BOOLEAN) TO atum_owner;
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ case class CheckpointItemWithPartitioningFromDB(
checkpointStartTime: ZonedDateTime,
checkpointEndTime: Option[ZonedDateTime],
idPartitioning: Long,
partitioning: Json,
partitioning: Json, // JSON representation of `PartitioningForDB`
partitioningAuthor: String,
hasMore: Boolean
)
Expand Down
Loading