Skip to content

#886 Do not replace primitive to non-ptimitive types and vice versa when copying metadata between schemas - #887

Merged
yruslan merged 1 commit into
masterfrom
bugfix/886-fix-copy-metadata-method
Nov 23, 2026
Merged

yruslan merged 1 commit into
masterfrom
bugfix/886-fix-copy-metadata-method

Conversation

@yruslan

@yruslan yruslan commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes
    • Corrected metadata copying for mismatched schemas: a primitive source field no longer replaces a complex destination field’s data type.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

copyMetadata now copies a source data type only when both corresponding field types are primitive. A test covers schemas with opposite primitive and struct shapes, including the resulting field types and copied metadata.

Changes

Metadata copying

Layer / File(s) Summary
Guard data type copying
spark-cobol/src/main/scala/za/co/absa/cobrix/spark/cobol/utils/SparkUtils.scala, spark-cobol/src/test/scala/za/co/absa/cobrix/spark/cobol/utils/SparkUtilsSuite.scala
copyMetadata checks that both corresponding field types are primitive before copying the source data type. The test checks the result for schemas with opposite primitive and struct shapes, including field types and maxLength metadata.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • Issue 886 describes copyMetadata replacing a struct field with a primitive when copyDataType = true. This change addresses the same behavior by restricting type copying to primitive source and target fields.
Merge Risk: Minimal · up to 8d03b

This change stops copyMetadata from replacing a non-primitive field type with a primitive one when data types are copied. It is narrowly scoped, has test coverage, and the known production caller does not use the affected path. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: copyMetadata no longer replaces a primitive type with a non-primitive type, or the reverse. The raw summary confirms the code now copies a primitive data type only wh…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: copyMetadata no longer replaces a primitive type with a non-primitive type, or the reverse. The raw summary confirms the code now copies a primitive data type only when both source and destination are primitive, and the added test covers the struct-to-primitive case. The PR number prefix is harmless. The title is specific and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks each field with care
Primitive types match pair by pair
A struct keeps its shape in place
Metadata finds its proper space
Then hops away with schemas fair

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a2ff63a5-086c-4268-87e0-e8bc085c7a12
Commits

Reviewing files that changed from the base of the PR and between ab4bfb7 and 8d03bc5.

Files selected for processing: 2

  • spark-cobol/src/main/scala/za/co/absa/cobrix/spark/cobol/utils/SparkUtils.scala
  • spark-cobol/src/test/scala/za/co/absa/cobrix/spark/cobol/utils/SparkUtilsSuite.scala

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@yruslan yruslan changed the title #886 Avoid replacing non-primitive field types when copying metadata. #886 Do not replace primitive to non-ptimitive types and vice versa when copying metadata between schemas Nov 23, 2026
@github-actions

Copy link
Copy Markdown

JaCoCo code coverage report - 'cobol-parser'

Overall Project 90.1% 🍏

There is no coverage information present for the Files changed

@github-actions

Copy link
Copy Markdown

JaCoCo code coverage report - 'spark-cobol'

Overall Project 84.1% 🍏
File Coverage
SparkUtils.scala 92.21% 🍏

@yruslan
yruslan merged commit 03c2148 into master Nov 23, 2026
7 checks passed
@yruslan
yruslan deleted the bugfix/886-fix-copy-metadata-method branch November 23, 2026 07:44
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.

1 participant