#768 Add replaceHivePartitionSchema method to support partition-level schema replacement in Hive helpers.#769
Conversation
…el schema replacement in Hive helpers.
|
Warning Review limit reached
More reviews will be available in 44 minutes and 36 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughAdds Hive support for replacing partition schema, including a new query template and config field, a new helper method, SQL and Spark catalog implementations, and updated tests and fixtures. ChangesHive partition schema replacement support
Sequence Diagram(s)sequenceDiagram
participant HiveConfig
participant HiveHelperSql
participant QueryExecutor
HiveConfig->>HiveHelperSql: provide replacePartitionSchemaTemplate
HiveHelperSql->>HiveHelperSql: validate partitionBy and partitionValues
HiveHelperSql->>HiveHelperSql: render partitionClause and `@schema`
HiveHelperSql->>QueryExecutor: execute ALTER TABLE ... PARTITION (...) REPLACE COLUMNS (...)
Estimated review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/model/HiveConfigSuite.scala (1)
32-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNo assertion covers
replacePartitionSchemaTemplate.The constructor arg lists were extended, but none of these tests assert the new
replacePartitionSchemaTemplateis threaded throughfromConfigWithDefaults/fromDefaults(default fallback and override). Adding an assertion (e.g. in the "overridden config" case wherereplace.partition.schema.templateis absent and should fall back to"replace_part1") would lock in the new wiring.Also applies to: 83-83, 112-112
🤖 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/test/scala/za/co/absa/pramen/core/metastore/model/HiveConfigSuite.scala` at line 32, Add test coverage for the new replacePartitionSchemaTemplate wiring in HiveConfigSuite: the current assertions around fromConfigWithDefaults and fromDefaults do not verify that the extra constructor arg is propagated. Update the existing HiveQueryTemplates-based assertions to include replacePartitionSchemaTemplate, and in the overridden config case assert that when replace.partition.schema.template is missing it falls back to the expected default value like "replace_part1".pramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelperSparkCatalog.scala (1)
107-133: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNo test coverage for the Spark Catalog partition-schema path.
HiveHelperSqlSuitecovers only the SQL helper. ThisHiveHelperSparkCatalog.replaceHivePartitionSchemaimplementation (which builds the clause and emitsDEFAULT_REPLACE_PARTITION_SCHEMA) has no equivalent test, so a regression in clause/DDL construction here would go undetected. Consider adding a catalog-path test analogous to the SQL one.🤖 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 107 - 133, Add test coverage for the Spark Catalog path in HiveHelperSparkCatalog.replaceHivePartitionSchema, since the SQL helper suite does not exercise this implementation. Create a catalog-path test analogous to the existing HiveHelperSqlSuite case and assert the generated partition clause and DEFAULT_REPLACE_PARTITION_SCHEMA SQL are built correctly when SparkUtils.transformSchemaForCatalog and SparkUtils.escapeColumnsSparkDDL are used. Focus the test around replaceHivePartitionSchema so regressions in clause construction, schema filtering, or table-name rendering are caught.
🤖 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/utils/hive/HiveHelperSparkCatalog.scala`:
- Around line 107-133: Add test coverage for the Spark Catalog path in
HiveHelperSparkCatalog.replaceHivePartitionSchema, since the SQL helper suite
does not exercise this implementation. Create a catalog-path test analogous to
the existing HiveHelperSqlSuite case and assert the generated partition clause
and DEFAULT_REPLACE_PARTITION_SCHEMA SQL are built correctly when
SparkUtils.transformSchemaForCatalog and SparkUtils.escapeColumnsSparkDDL are
used. Focus the test around replaceHivePartitionSchema so regressions in clause
construction, schema filtering, or table-name rendering are caught.
In
`@pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/model/HiveConfigSuite.scala`:
- Line 32: Add test coverage for the new replacePartitionSchemaTemplate wiring
in HiveConfigSuite: the current assertions around fromConfigWithDefaults and
fromDefaults do not verify that the extra constructor arg is propagated. Update
the existing HiveQueryTemplates-based assertions to include
replacePartitionSchemaTemplate, and in the overridden config case assert that
when replace.partition.schema.template is missing it falls back to the expected
default value like "replace_part1".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 13b7d731-8282-4deb-9fc9-ec33e1cf039a
📒 Files selected for processing (8)
pramen/core/src/main/scala/za/co/absa/pramen/core/metastore/model/HiveConfig.scalapramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelper.scalapramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelperSparkCatalog.scalapramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveHelperSql.scalapramen/core/src/main/scala/za/co/absa/pramen/core/utils/hive/HiveQueryTemplates.scalapramen/core/src/test/scala/za/co/absa/pramen/core/metastore/model/HiveConfigSuite.scalapramen/core/src/test/scala/za/co/absa/pramen/core/metastore/model/MetaTableSuite.scalapramen/core/src/test/scala/za/co/absa/pramen/core/tests/utils/hive/HiveHelperSqlSuite.scala
…ement of partition schema in Hive.
Unit Test Coverage
Files
|
Closes #768
Summary by CodeRabbit
New Features
Bug Fixes