Skip to content

#742 Add 'number_of_tasks_completed' field to the 'executions' table.#743

Merged
yruslan merged 3 commits into
mainfrom
feature/742-add-number-of-tasks-in-executions-table
May 14, 2026
Merged

#742 Add 'number_of_tasks_completed' field to the 'executions' table.#743
yruslan merged 3 commits into
mainfrom
feature/742-add-number-of-tasks-in-executions-table

Conversation

@yruslan
Copy link
Copy Markdown
Collaborator

@yruslan yruslan commented May 13, 2026

Closes #742

Summary by CodeRabbit

New Features

  • Pipeline executions now track and report the number of completed tasks for enhanced monitoring and audit capabilities
  • Secondary execution record indexes have been optimized, including new pipeline name-based lookup
  • Database schema upgraded to version 11 to support the new metrics with automatic migration

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@yruslan has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 31 minutes and 30 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 48a651af-db2c-453a-b0de-591ba3b86a32

📥 Commits

Reviewing files that changed from the base of the PR and between efe41ac and c76588c.

📒 Files selected for processing (3)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/journal/JournalDynamoDB.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/sql/dialects/DenodoDialect.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/state/PipelineStateImpl.scala

Walkthrough

The PR adds an optional numberOfTasksCompleted field to the Execution data model to track completed (non-skipped) tasks. PipelineStateImpl computes this by filtering task results that have Succeeded or Failed status, then passes it to the Execution constructor. The field is then persisted to both SQL (via ExecutionsTable with a new nullable column and updated tuple mappings) and NoSQL (via JournalDynamoDB attribute), with a corresponding database migration to version 11.

Changes

Execution completion tracking

Layer / File(s) Summary
Execution model and completion counting
pramen/core/src/main/scala/za/co/absa/pramen/core/journal/model/Execution.scala, pramen/core/src/main/scala/za/co/absa/pramen/core/state/PipelineStateImpl.scala
Execution case class adds optional numberOfTasksCompleted: Option[Long] field. PipelineStateImpl.addJournalEntry computes the count by iterating task results and classifying RunStatus.Succeeded and RunStatus.Failed as not skipped; all other statuses are treated as skipped. The computed count is passed to the Execution constructor.
SQL persistence and migration
pramen/core/src/main/scala/za/co/absa/pramen/core/journal/model/ExecutionsTable.scala, pramen/core/src/main/scala/za/co/absa/pramen/core/rdb/PramenDb.scala
ExecutionsTable adds nullable number_of_tasks_completed column and extends ExecutionTuple mappings (toExecution, fromExecution, * projection) to carry the field. Secondary indexes are updated: idx3 reindexed to pipelineDefinitionId, idx5 pipelineId index renamed, and idx6 added to index pipelineName. PramenDb increments MODEL_VERSION to 11 and adds schema migration to add the column to executionsTable for database versions < 11.
DynamoDB persistence
pramen/core/src/main/scala/za/co/absa/pramen/core/journal/JournalDynamoDB.scala
Adds ATTR_NUMBER_OF_TASKS_COMPLETED constant. JournalDynamoDB.addPipelineEntry now persists execution.numberOfTasksCompleted to the DynamoDB executions table under that attribute.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AbsaOSS/pramen#741: Establishes the executions table infrastructure that this PR extends by adding the number_of_tasks_completed field to both the ORM model and DynamoDB persistence layer.

Poem

🐰 A tale of tasks both done and skipped,
Where counts are tallied, cleanly tipped,
Now numbers dance from code to store,
SQL, DynamoDB, and more—
Completion tracked forevermore! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive The PR includes updates to ExecutionsTable indexes (changing from batchId to pipelineDefinitionId and adding pipelineName index), which may be unrelated to the core feature of adding the new field. Clarify whether the index changes in ExecutionsTable are intentional modifications to support the new field or separate scope changes that should be documented separately.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding a 'number_of_tasks_completed' field to the 'executions' table.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #742: adding the 'number_of_tasks_completed' field to the executions table to avoid needing to join with the journal table.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/742-add-number-of-tasks-in-executions-table

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pramen/core/src/main/scala/za/co/absa/pramen/core/journal/JournalDynamoDB.scala (1)

401-401: ⚡ Quick win

Move constant to the executions table attributes section.

ATTR_NUMBER_OF_TASKS_COMPLETED is defined in the journal table attributes section (lines 385-408) but is actually used for the executions table at line 151. For consistency with the code organization, this constant should be moved to the executions table section (lines 358-383), likely after ATTR_EXEC_FAILURE_REASON at line 379.

♻️ Suggested placement

Move line 401 to appear after line 379 in the executions attributes section:

 val ATTR_EXEC_FAILURE_REASON = "failure_reason"
+val ATTR_NUMBER_OF_TASKS_COMPLETED = "number_of_tasks_completed"
 val ATTR_EXEC_NUMBER_OR_RECORDS_INGESTED = "number_of_records_ingested"

And remove from line 401 in the journal attributes section.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@pramen/core/src/main/scala/za/co/absa/pramen/core/journal/JournalDynamoDB.scala`
at line 401, ATTR_NUMBER_OF_TASKS_COMPLETED is declared in the journal table
attributes block but is used by the executions table; move the constant
declaration to the executions table attributes section and remove it from the
journal section — place the declaration after ATTR_EXEC_FAILURE_REASON in the
executions attributes block so it's grouped with other execution-related
attribute constants.
pramen/core/src/main/scala/za/co/absa/pramen/core/state/PipelineStateImpl.scala (1)

354-361: 💤 Low value

Consider simplifying the counting logic.

The double-negation pattern (isSkipped then !isSkipped) makes this code harder to follow.

♻️ Simpler alternative
-    val notSkippedTasks = taskResults.count { task =>
-      val isSkipped = task.runStatus match {
-        case _: RunStatus.Succeeded => false
-        case _: RunStatus.Failed => false
-        case _ => true
-      }
-      !isSkipped
-    }
+    val notSkippedTasks = taskResults.count { task =>
+      task.runStatus match {
+        case _: RunStatus.Succeeded | _: RunStatus.Failed => true
+        case _ => false
+      }
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@pramen/core/src/main/scala/za/co/absa/pramen/core/state/PipelineStateImpl.scala`
around lines 354 - 361, The counting logic for notSkippedTasks uses a confusing
double-negation; replace it by directly counting tasks whose runStatus is a
RunStatus.Succeeded or RunStatus.Failed. In other words, update the expression
that computes notSkippedTasks (which currently inspects taskResults and matches
on task.runStatus) to match only the two concrete cases (RunStatus.Succeeded and
RunStatus.Failed) and increment the count for those, removing the intermediate
isSkipped boolean and the negation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@pramen/core/src/main/scala/za/co/absa/pramen/core/journal/JournalDynamoDB.scala`:
- Line 401: ATTR_NUMBER_OF_TASKS_COMPLETED is declared in the journal table
attributes block but is used by the executions table; move the constant
declaration to the executions table attributes section and remove it from the
journal section — place the declaration after ATTR_EXEC_FAILURE_REASON in the
executions attributes block so it's grouped with other execution-related
attribute constants.

In
`@pramen/core/src/main/scala/za/co/absa/pramen/core/state/PipelineStateImpl.scala`:
- Around line 354-361: The counting logic for notSkippedTasks uses a confusing
double-negation; replace it by directly counting tasks whose runStatus is a
RunStatus.Succeeded or RunStatus.Failed. In other words, update the expression
that computes notSkippedTasks (which currently inspects taskResults and matches
on task.runStatus) to match only the two concrete cases (RunStatus.Succeeded and
RunStatus.Failed) and increment the count for those, removing the intermediate
isSkipped boolean and the negation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2ade901f-29fd-4f48-b28d-e890ea6c96d2

📥 Commits

Reviewing files that changed from the base of the PR and between 6a604af and efe41ac.

📒 Files selected for processing (5)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/journal/JournalDynamoDB.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/journal/model/Execution.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/journal/model/ExecutionsTable.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/rdb/PramenDb.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/state/PipelineStateImpl.scala

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

Unit Test Coverage

Overall Project 77.25% -0.11% 🍏
Files changed 54.58%

Module Coverage
pramen:core Jacoco Report 78.29% -0.12%
Files
Module File Coverage
pramen:core Jacoco Report Execution.scala 100% -5%
ExecutionsTable.scala 88.12% -5.62%
PipelineStateImpl.scala 83.35% 🍏
PramenDb.scala 56.92% -1.28%
DenodoDialect.scala 42.42% -48.48%
JournalDynamoDB.scala 14.24% -0.49%

@yruslan yruslan merged commit 6c926bf into main May 14, 2026
7 checks passed
@yruslan yruslan deleted the feature/742-add-number-of-tasks-in-executions-table branch May 14, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the number of completed tasks to the executions table

1 participant