Skip to content

test(spark): Add date logical type test to TestAvroConversionUtils#18584

Open
ashokkumar-allu wants to merge 2 commits intoapache:masterfrom
ashokkumar-allu:allu_oss_commit_porting_02
Open

test(spark): Add date logical type test to TestAvroConversionUtils#18584
ashokkumar-allu wants to merge 2 commits intoapache:masterfrom
ashokkumar-allu:allu_oss_commit_porting_02

Conversation

@ashokkumar-allu
Copy link
Copy Markdown

Describe the issue this Pull Request addresses

TestAvroConversionUtils was missing a test for Avro's date logical type (an int field with logicalType=date). The createConverterToRow utility handles this case by converting epoch-day integers to java.sql.Date, but this conversion path had no dedicated test coverage.

Summary and Changelog

  • Added a "Logical type: date" test in TestAvroConversionUtils that verifies AvroConversionUtils.createConverterToRow correctly converts an Avro record with an integer date field (epoch days) to a java.sql.Date with the expected calendar value.
  • Added import java.time.LocalDate for the assertion helper.

Impact

None — test-only change, no production code modified.

Risk Level

none

Documentation Update

none

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

Add a test case that verifies createConverterToRow correctly handles
Avro's date logical type (int with logicalType=date), ensuring the
conversion from epoch-days integer to java.sql.Date preserves the
correct date value.
@github-actions github-actions Bot added the size:S PR with lines of changes in (10, 100] label Apr 24, 2026
Copy link
Copy Markdown

@hudi-agent hudi-agent left a comment

Choose a reason for hiding this comment

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

🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for the contribution! This PR adds a test for the Avro date logical type conversion in TestAvroConversionUtils. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. A couple of minor naming and clarity suggestions below.

cc @yihua


val dateInputData = Seq(7, 365, 0)
val schema = HoodieSchema.parse(dateSchema)
val convertor = AvroConversionUtils.createConverterToRow(schema, HoodieSchemaConversionUtils.convertHoodieSchemaToStructType(schema))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 nit: convertor looks like a typo — the function being called is createConverterToRow, so converter would be consistent with the rest of the codebase.

- Generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

}
"""

val dateInputData = Seq(7, 365, 0)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 nit: the values 7, 365, and 0 read as arbitrary magic numbers — could you add a brief inline comment (e.g. // one week, one year, epoch) so the intent is clear to future readers?

- Generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Copy link
Copy Markdown

@hudi-agent hudi-agent left a comment

Choose a reason for hiding this comment

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

🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for addressing the feedback! Both prior nits were resolved — convertor was renamed to converter, and the inline comment // one week, one year, epoch was added to clarify the test values. No new issues flagged from this automated pass — a Hudi committer or PMC member can take it from here for a final review.

@hudi-bot
Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S PR with lines of changes in (10, 100]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants