Skip to content

#765 Add neverRepairPartitions option to skip MSCK REPAIR TABLE in Hive helpers.#766

Merged
yruslan merged 2 commits into
mainfrom
feature/765-allow-disabling-msck-repair-table
Jun 25, 2026
Merged

#765 Add neverRepairPartitions option to skip MSCK REPAIR TABLE in Hive helpers.#766
yruslan merged 2 commits into
mainfrom
feature/765-allow-disabling-msck-repair-table

Conversation

@yruslan

@yruslan yruslan commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #765

Summary by CodeRabbit

  • New Features

    • Added configuration option pramen.hive.never.repair.partitions to control whether partition repair is skipped during Hive table create/update (default: false).
  • Bug Fixes

    • Partition repair behavior is now applied consistently across Hive table (re)creation and sink update flows; when disabled, partition repair is skipped and reported via logs.
  • Tests

    • Updated/extended Hive helper and sink test coverage for both repair-enabled and repair-disabled scenarios.
  • Chores

    • Updated the build tool version.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6ca466d3-06c7-47a9-ab47-265831636978

📥 Commits

Reviewing files that changed from the base of the PR and between d330b9b and 3972fea.

📒 Files selected for processing (4)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelper.scala
  • pramen/extras/src/main/scala/za/co/absa/pramen/extras/sink/EnceladusSink.scala
  • pramen/extras/src/test/scala/za/co/absa/pramen/extras/sink/EnceladusSinkSuite.scala
  • pramen/project/build.properties
✅ Files skipped from review due to trivial changes (1)
  • pramen/project/build.properties
🚧 Files skipped from review as they are similar to previous changes (1)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelper.scala

Walkthrough

A new Hive configuration flag is added and threaded through metastore table-creation paths. Hive helper interfaces and both helper implementations now accept the flag and conditionally skip partition repair. Call sites and tests were updated accordingly. The SBT version was also updated.

Changes

Hive partition repair flag

Layer / File(s) Summary
Config and metastore wiring
pramen/core/src/main/resources/reference.conf, pramen/core/src/main/scala/.../config/Keys.scala, pramen/core/src/main/scala/.../metastore/MetastoreImpl.scala
Adds pramen.hive.never.repair.partitions, defines the key, reads the flag in MetastoreImpl, and passes it through recreation paths.
Hive helper repair gating
pramen/core/src/main/scala/.../utils/hive/HiveHelper.scala, pramen/core/src/main/scala/.../utils/hive/HiveHelperSparkCatalog.scala, pramen/core/src/main/scala/.../utils/hive/HiveHelperSql.scala
Extends the helper signature and changes both helper implementations to skip partition repair when the flag is set.
Call sites and validation
pramen/extras/src/main/scala/.../EnceladusSink.scala, pramen/extras/src/main/scala/.../StandardizationSink.scala, pramen/core/src/test/scala/.../HiveHelperSparkCatalogSuite.scala, pramen/core/src/test/scala/.../HiveHelperSqlSuite.scala
Updates sink call sites to pass the new boolean and adjusts helper suites for the repair and skip cases.

Build tool update

Layer / File(s) Summary
SBT version bump
pramen/project/build.properties
Updates the configured SBT version from 1.12.11 to 1.12.13.

Sequence Diagram(s)

sequenceDiagram
  participant appConfig
  participant MetastoreImpl
  participant HiveHelper
  appConfig->>MetastoreImpl: read pramen.hive.never.repair.partitions
  MetastoreImpl->>HiveHelper: createOrUpdateHiveTable(..., neverRepairPartitions)
  alt partitionBy non-empty and neverRepairPartitions=false
    HiveHelper->>HiveHelper: repairHiveTable()
  else partitionBy empty or neverRepairPartitions=true
    HiveHelper->>HiveHelper: log "Skipping repairing partition"
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AbsaOSS/pramen#737: It also changes the MetastoreImpl Hive schema-update flow and hiveHelper.createOrUpdateHiveTable call paths.

Poem

A bunny hopped through Hive today,
And set a little flag in play.
No repair hop when told to rest,
Just tidy tables doing their best.
Thump-thump! 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The sbt version bump in pramen/project/build.properties is unrelated to disabling Hive repair queries. Remove the sbt version change or explain it as a required dependency update tied to this feature.
✅ 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 describes the main feature: adding a flag to skip Hive partition repair.
Linked Issues check ✅ Passed The PR adds a configurable way to skip MSCK REPAIR TABLE during Hive table creation, matching issue #765.
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/765-allow-disabling-msck-repair-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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelper.scala (1)

31-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Consider a default value to avoid a source-breaking API change.

Adding neverRepairPartitions: Boolean as a required parameter on these public abstract methods breaks every existing implementer and caller of HiveHelper. Defaulting to false preserves the prior behavior and backward compatibility.

♻️ Proposed signature with default
   def createHiveTable(path: String,
                       format: HiveFormat,
                       schema: StructType,
                       partitionBy: Seq[String],
                       databaseName: Option[String],
                       tableName: String,
-                      neverRepairPartitions: Boolean): Unit
+                      neverRepairPartitions: Boolean = false): Unit
 
   def createOrUpdateHiveTable(path: String,
                               format: HiveFormat,
                               schema: StructType,
                               partitionBy: Seq[String],
                               databaseName: Option[String],
                               tableName: String,
-                              neverRepairPartitions: Boolean): Unit
+                              neverRepairPartitions: Boolean = false): Unit
🤖 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/utils/hive/HiveHelper.scala`
around lines 31 - 40, The public HiveHelper API now adds a required
neverRepairPartitions parameter on createOrUpdateHiveTable overloads, which
breaks existing callers and implementers. Update the HiveHelper trait and any
overriding implementations to give neverRepairPartitions a default of false so
the prior behavior remains unchanged and the API stays backward compatible; use
the createOrUpdateHiveTable symbols in HiveHelper.scala to locate the affected
signatures.
pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelperSparkCatalog.scala (1)

41-48: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicated partition-repair gating block.

This exact if (partitionBy.nonEmpty && !neverRepairPartitions) { ... } else { ... } block with the two skip-log messages is now repeated four times (here and createOrUpdateHiveTable in this file, plus both methods in HiveHelperSql). Extracting a small shared helper (e.g. in the HiveHelper companion taking fullTableName, partitionBy, neverRepairPartitions, and a repair thunk) would remove the duplication and keep the skip-logging consistent. Flagging once here; the same applies to the other three occurrences.

🤖 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/utils/hive/HiveHelperSparkCatalog.scala`
around lines 41 - 48, The partition-repair gating logic in this block is
duplicated in multiple places and should be centralized. Extract the repeated
`if (partitionBy.nonEmpty && !neverRepairPartitions)` check and the two skip-log
branches into a shared helper in the `HiveHelper` companion, and have
`repairHiveTable` or a repair thunk passed in so `createOrUpdateHiveTable` and
the `HiveHelperSql` methods can reuse it. Keep the helper responsible for the
consistent skip logging using `fullTableName`, `partitionBy`, and
`neverRepairPartitions`.
🤖 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.

Inline comments:
In
`@pramen/extras/src/main/scala/za/co/absa/pramen/extras/sink/EnceladusSink.scala`:
- Line 452: The `neverRepairPartitions` flag is hardcoded to false in
`EnceladusSink` and similarly in `StandardizationSink`, so these sinks ignore
the runtime `never.repair.partitions` setting. Update the
`createOrUpdateHiveTable` call sites to pass the configured value from the
sink’s runtime/config object instead of a literal, using the same wiring pattern
already exposed through `MetastoreImpl` and the persistence layer.

---

Nitpick comments:
In
`@pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelper.scala`:
- Around line 31-40: The public HiveHelper API now adds a required
neverRepairPartitions parameter on createOrUpdateHiveTable overloads, which
breaks existing callers and implementers. Update the HiveHelper trait and any
overriding implementations to give neverRepairPartitions a default of false so
the prior behavior remains unchanged and the API stays backward compatible; use
the createOrUpdateHiveTable symbols in HiveHelper.scala to locate the affected
signatures.

In
`@pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelperSparkCatalog.scala`:
- Around line 41-48: The partition-repair gating logic in this block is
duplicated in multiple places and should be centralized. Extract the repeated
`if (partitionBy.nonEmpty && !neverRepairPartitions)` check and the two skip-log
branches into a shared helper in the `HiveHelper` companion, and have
`repairHiveTable` or a repair thunk passed in so `createOrUpdateHiveTable` and
the `HiveHelperSql` methods can reuse it. Keep the helper responsible for the
consistent skip logging using `fullTableName`, `partitionBy`, and
`neverRepairPartitions`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3ef99cd2-df99-462d-9bf9-ec364594ea88

📥 Commits

Reviewing files that changed from the base of the PR and between 25f301c and d330b9b.

📒 Files selected for processing (10)
  • pramen/core/src/main/resources/reference.conf
  • pramen/core/src/main/scala/za/co/absa/pramen/core/config/Keys.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/metastore/MetastoreImpl.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelper.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelperSparkCatalog.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelperSql.scala
  • pramen/core/src/test/scala/za/co/absa/pramen/core/tests/utils/hive/HiveHelperSparkCatalogSuite.scala
  • pramen/core/src/test/scala/za/co/absa/pramen/core/tests/utils/hive/HiveHelperSqlSuite.scala
  • pramen/extras/src/main/scala/za/co/absa/pramen/extras/sink/EnceladusSink.scala
  • pramen/extras/src/main/scala/za/co/absa/pramen/extras/sink/StandardizationSink.scala

Comment thread pramen/extras/src/main/scala/za/co/absa/pramen/extras/sink/EnceladusSink.scala Outdated
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Unit Test Coverage

Overall Project 76.88% -0.09% 🍏
Files changed 66.07%

Module Coverage
pramen:core Jacoco Report 77.87% -0.07%
pramen-extras Jacoco Report 66.16% -0.25%
Files
Module File Coverage
pramen:core Jacoco Report HiveHelperSql.scala 88.91% -7.32%
HiveHelper.scala 88.68% -2.52%
MetastoreImpl.scala 86.27% -1.7%
HiveHelperSparkCatalog.scala 85.98% -2.93% 🍏
pramen-extras Jacoco Report StandardizationSink.scala 83.54% 🍏
EnceladusSink.scala 61.15% -1.63%

…lChannelFactoryV2 and add default value to HiveHelper methods.
@yruslan yruslan merged commit b9911cf into main Jun 25, 2026
7 checks passed
@yruslan yruslan deleted the feature/765-allow-disabling-msck-repair-table branch June 25, 2026 14:32
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.

Allow disabling of 'MSCK RAPAIR TABLE' queries when creating new tables

1 participant