Skip to content

Conversation

@Li0k
Copy link
Contributor

@Li0k Li0k commented Nov 13, 2025

Which issue does this PR close?

  • Closes #.

What changes are included in this PR?

Summary

Refactor SnapshotProducer validation methods to use internal state instead of requiring redundant parameters.

Problem

I've noticed that while the current SnapshotProducer API design already equips SnapshotProducer with all necessary state, the current invocations still redundantly pass parameters externally. I believe this could lead to some issues.

  1. Data mismatch risk: Callers could pass different data than what's stored in SnapshotProducer, leading to validating one set of files but committing another
  2. API complexity: As more validations are added (e.g., delete files, file existence checks), each method would require additional parameters, making the API harder to use
  3. Redundant passing: The same data that was already provided during construction has to be passed again

Changes

  • Modified validate_added_data_files() and validate_duplicate_files() to operate on self.added_data_files directly
  • Updated FastAppendAction::commit() to call validation methods without passing added_data_files parameter

Motivation

Previously, added_data_files was passed as a parameter to validation methods even though it was already stored in SnapshotProducer:

// Before
snapshot_producer.validate_added_data_files(&self.added_data_files)?;

// After  
snapshot_producer.validate_added_data_files()?;

Benefits

  1. Better encapsulation - validation operates on object's own state
  2. Safer API - eliminates possibility of data mismatch
  3. Simpler interface - no redundant parameters needed

Discussion

Since SnapshotProducer already holds all necessary state, can we further refine validation by performing it during the new function's execution to improve data consistency and encapsulation?

Are these changes tested?

Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

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

Thanks @Li0k for this fix!

@liurenjie1024 liurenjie1024 merged commit ff408ff into apache:main Nov 13, 2025
18 checks passed
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.

2 participants