-
Notifications
You must be signed in to change notification settings - Fork 39
Resolve minor bugs in data loader core #2752
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
Conversation
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.
Pull Request Overview
This PR fixes transactional import counting, enriches column validation errors with detailed context, and ensures failure logs are generated correctly.
- Adjusted success/failure counters to aggregate per record batch
- Extended ColumnUtils to include namespace, table, and invalid value in error messages
- Switched to modifiable lists in ImportTask to prevent
UnsupportedOperationException
and updated CoreError definitions
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
data-loader/core/src/test/java/com/scalar/db/dataloader/core/util/ColumnUtilsTest.java | Updated tests to expect the invalid value in error messages and added a null-result case |
data-loader/core/src/main/java/com/scalar/db/dataloader/core/util/ColumnUtils.java | Extended methods to accept namespace and table parameters and populate ColumnInfo accordingly |
data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataimport/task/ImportTask.java | Changed singleton list to ArrayList for targets and included the source record on validation failure |
data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataimport/processor/ImportProcessor.java | Refactored batch counting logic to correctly sum successes and failures per batch |
core/src/main/java/com/scalar/db/common/error/CoreError.java | Enhanced error message templates to include the invalid value placeholder |
Comments suppressed due to low confidence (3)
data-loader/core/src/main/java/com/scalar/db/dataloader/core/util/ColumnUtils.java:181
- [nitpick] Rename the parameter 'table' to 'tableName' across ColumnUtils methods to align with the existing convention (
columnInfo.getTableName()
) and reduce ambiguity.
String table)
data-loader/core/src/main/java/com/scalar/db/dataloader/core/util/ColumnUtils.java:303
- [nitpick] Similarly, rename the 'table' parameter in
getColumnFromSourceRecord
to 'tableName' for consistency with other method signatures and builder patterns.
String table)
data-loader/core/src/test/java/com/scalar/db/dataloader/core/util/ColumnUtilsTest.java:224
- Consider adding assertions in this test to verify that each returned Column includes the correct namespace and tableName metadata when the result is null.
void getColumnsFromResult_withResultNull_withValidData_shouldReturnColumns()
@@ -689,13 +689,13 @@ public enum CoreError implements ScalarDbError { | |||
DATA_LOADER_INVALID_BASE64_ENCODING_FOR_COLUMN_VALUE( | |||
Category.USER_ERROR, | |||
"0149", | |||
"Invalid base64 encoding for blob value for column %s in table %s in namespace %s", | |||
"Invalid base64 encoding for blob value '%s' for column %s in table %s in namespace %s", |
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.
[nitpick] Add a trailing period to this error message string to match the punctuation style of other CoreError templates (e.g., end with a period).
"Invalid base64 encoding for blob value '%s' for column %s in table %s in namespace %s", | |
"Invalid base64 encoding for blob value '%s' for column %s in table %s in namespace %s.", |
Copilot uses AI. Check for mistakes.
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.
LGTM! 👍
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.
LGTM! Thank you!
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.
LGTM. Thank you.
data-loader/core/src/main/java/com/scalar/db/dataloader/core/dataimport/task/ImportTask.java
Show resolved
Hide resolved
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.
LGTM, thank you!
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.
LGTM! Thank you!
Description
This PR addresses several bugs encountered while testing the CLI application for data import using transactions.
Incorrect success/failure count in transaction import
There was a mismatch in success and failure counts when an import failed within a transaction batch. Although all entries were initially marked as saved, if any transaction failed during the pre-commit check, their statuses were changed to aborted. However, the success/failure counts were calculated before this status update, leading to incorrect reporting.
Updated the logic to determine if any transaction in the batch failed:
Missing namespace and table Names in column validation errors
Column validation error messages were showing null for the namespace and table name. This happened because ColumnInfo was being constructed without these values.
Updated ColumnInfo initialization to include namespace and table names. Also added the invalid value in the error message to improve clarity.
Failure and summary logs not generated on import failure
When an import failed during a transaction batch, failure and summary logs were not being created. This was caused by an attempt to update a singleton list used to store transaction batch results, which threw a java.lang.UnsupportedOperationException.
Changed the list structure to a modifiable list, allowing proper updates and enabling correct logging.
Related issues and/or PRs
NA
Changes made
Checklist
Additional notes (optional)
NA
Release notes
Fixes for minor bugs and issues in data loader core