-
Notifications
You must be signed in to change notification settings - Fork 106
adapters: configurable error handling for failed batches during snapshot reading #5777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
swanandx
wants to merge
2
commits into
main
Choose a base branch
from
issue5750
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -99,6 +99,21 @@ fn default_num_parsers() -> u32 { | |||||
| 4 | ||||||
| } | ||||||
|
|
||||||
| /// Controls how the Delta table input connector handles errors during snapshot loading. | ||||||
| /// | ||||||
| /// * `ignore` - Log a non-fatal warning and skip the failed batch (default). | ||||||
| /// * `fail` - Treat the error as fatal and stop the pipeline immediately. | ||||||
| #[derive(Default, Debug, Clone, Eq, PartialEq, Deserialize, Serialize, ToSchema)] | ||||||
| #[serde(rename_all = "lowercase")] | ||||||
| pub enum DeltaTableSnapshotErrorMode { | ||||||
| /// Log a non-fatal warning and skip the failed batch. | ||||||
| #[default] | ||||||
| Ignore, | ||||||
|
|
||||||
| /// Treat the error as fatal and stop the pipeline immediately. | ||||||
| Fail, | ||||||
| } | ||||||
|
|
||||||
| /// Delta table transaction mode. | ||||||
| /// | ||||||
| /// Determines how the connector breaks up its input into transactions. | ||||||
|
|
@@ -307,6 +322,13 @@ pub struct DeltaTableReaderConfig { | |||||
| #[serde(default)] | ||||||
| pub verbose: u32, | ||||||
|
|
||||||
| /// Controls how the connector handles errors during snapshot loading. | ||||||
| /// | ||||||
| /// * `"ignore"` - Log a non-fatal warning and skip the failed batch (default). | ||||||
| /// * `"fail"` - Treat the error as fatal and stop the pipeline immediately. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| #[serde(default)] | ||||||
| pub snapshot_error_mode: DeltaTableSnapshotErrorMode, | ||||||
|
|
||||||
| /// Storage options for configuring backend object store. | ||||||
| /// | ||||||
| /// For specific options available for different storage backends, see: | ||||||
|
|
@@ -335,13 +357,57 @@ fn test_delta_reader_config_serde() { | |||||
| let config = serde_json::from_str::<DeltaTableReaderConfig>(config_str).unwrap(); | ||||||
|
|
||||||
| let serialized_config = serde_json::to_string(&config).unwrap(); | ||||||
| let expected = r#"{"uri":"protocol:/path/to/somewhere","mode":"follow","transaction_mode":"none","timestamp_column":"ts","filter":null,"skip_unused_columns":false,"snapshot_filter":"ts BETWEEN '2005-01-01 00:00:00' AND '2010-12-31 23:59:59'","version":null,"datetime":"2010-12-31 00:00:00Z","end_version":null,"cdc_delete_filter":null,"cdc_order_by":null,"num_parsers":4,"max_concurrent_readers":null,"customoption1":"val1","customoption2":"val2","verbose":0}"#; | ||||||
| let expected = r#"{"uri":"protocol:/path/to/somewhere","mode":"follow","transaction_mode":"none","timestamp_column":"ts","filter":null,"skip_unused_columns":false,"snapshot_filter":"ts BETWEEN '2005-01-01 00:00:00' AND '2010-12-31 23:59:59'","version":null,"datetime":"2010-12-31 00:00:00Z","end_version":null,"cdc_delete_filter":null,"cdc_order_by":null,"num_parsers":4,"max_concurrent_readers":null,"snapshot_error_mode":"ignore","customoption1":"val1","customoption2":"val2","verbose":0}"#; | ||||||
| assert_eq!( | ||||||
| serde_json::from_str::<serde_json::Value>(&serialized_config).unwrap(), | ||||||
| serde_json::from_str::<serde_json::Value>(expected).unwrap() | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| #[cfg(test)] | ||||||
| #[test] | ||||||
| fn test_snapshot_error_mode_default() { | ||||||
| let config_str = r#"{ | ||||||
| "uri": "s3://bucket/table", | ||||||
| "mode": "snapshot" | ||||||
| }"#; | ||||||
| let config = serde_json::from_str::<DeltaTableReaderConfig>(config_str).unwrap(); | ||||||
| assert_eq!( | ||||||
| config.snapshot_error_mode, | ||||||
| DeltaTableSnapshotErrorMode::Ignore | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| #[cfg(test)] | ||||||
| #[test] | ||||||
| fn test_snapshot_error_mode_ignore() { | ||||||
| let config_str = r#"{ | ||||||
| "uri": "s3://bucket/table", | ||||||
| "mode": "snapshot", | ||||||
| "snapshot_error_mode": "ignore" | ||||||
| }"#; | ||||||
| let config = serde_json::from_str::<DeltaTableReaderConfig>(config_str).unwrap(); | ||||||
| assert_eq!( | ||||||
| config.snapshot_error_mode, | ||||||
| DeltaTableSnapshotErrorMode::Ignore | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| #[cfg(test)] | ||||||
| #[test] | ||||||
| fn test_snapshot_error_mode_fail() { | ||||||
| let config_str = r#"{ | ||||||
| "uri": "s3://bucket/table", | ||||||
| "mode": "snapshot", | ||||||
| "snapshot_error_mode": "fail" | ||||||
| }"#; | ||||||
| let config = serde_json::from_str::<DeltaTableReaderConfig>(config_str).unwrap(); | ||||||
| assert_eq!( | ||||||
| config.snapshot_error_mode, | ||||||
| DeltaTableSnapshotErrorMode::Fail | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| impl DeltaTableReaderConfig { | ||||||
| /// `true` if the configuration requires taking an initial snapshot of the table. | ||||||
| pub fn snapshot(&self) -> bool { | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.