-
Notifications
You must be signed in to change notification settings - Fork 38
Add export command for data loader CLI #2617
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 adds a new export
command to the data-loader CLI, implements related parsing utilities and converters, and updates tests and error definitions.
- Introduces
parseMultipleKeyValues
inKeyUtils
and related tests for multi-column key parsing. - Adds CLI parsing utilities (
CommandLineInputUtils
) and converters (SingleColumnKeyValueConverter
,MultiColumnKeyValueConverter
,ScanOrderingConverter
). - Implements
ExportCommand
andExportCommandOptions
to handle export logic, file/path validation, and output formatting; updates tests and error codes.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
data-loader/core/src/main/java/com/scalar/db/dataloader/core/util/KeyUtils.java | Added parseMultipleKeyValues to build a Key from multiple values |
data-loader/core/src/test/java/com/scalar/db/dataloader/core/util/KeyUtilsTest.java | Added test for parseMultipleKeyValues |
data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/util/CommandLineInputUtils.java | Added parseKeyValue and splitByDelimiter with error handling |
data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/SingleColumnKeyValueConverter.java | New converter for single key-value CLI inputs |
data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/MultiColumnKeyValueConverter.java | New converter for multi key-value CLI inputs |
data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ScanOrderingConverter.java | New converter for scan ordering |
data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommandOptions.java | Defined CLI options for export command |
data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommand.java | Implemented export logic, path validation, manager creation |
data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommandTest.java | Updated tests for blank and invalid config paths |
core/src/main/java/com/scalar/db/common/error/CoreError.java | Added new error codes for data loader CLI |
Comments suppressed due to low confidence (2)
data-loader/core/src/test/java/com/scalar/db/dataloader/core/util/KeyUtilsTest.java:249
- The test only asserts the column name; consider also verifying the parsed column value and the total number of columns to improve coverage for parseMultipleKeyValues.
assertEquals(c1, key.getColumnName(0));
data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/command/dataexport/ExportCommandTest.java:16
- This cleanup method is not annotated (e.g., @AfterEach), so it won't run. Add the appropriate JUnit annotation to ensure test artifacts are removed.
void removeFileIfCreated() {
* Convert a keyValue, in the format of <key>=<value>, to a ScalarDB Key instance. | ||
* | ||
* @param keyValues A list of key values in the format of <key>=<value> |
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.
The @param description is misleading: keyValues is a list of ColumnKeyValue objects, not raw strings. Update the documentation to reflect that.
* Convert a keyValue, in the format of <key>=<value>, to a ScalarDB Key instance. | |
* | |
* @param keyValues A list of key values in the format of <key>=<value> | |
* Convert a list of ColumnKeyValue objects to a ScalarDB Key instance. | |
* | |
* @param keyValues A list of ColumnKeyValue objects, where each object contains a column name | |
* and its corresponding value |
Copilot uses AI. Check for mistakes.
validateOutputDirectory(outputFilePath); | ||
return 0; | ||
} | ||
String scalarDbPropertiesFilePath = getScalarDbPropertiesFilePath(); |
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.
Tests expect an IllegalArgumentException when configFilePath is blank, but the current implementation catches all invalid file paths and returns an exit code. Add an explicit check for blank configFilePath and throw IllegalArgumentException with CoreError.DATA_LOADER_FILE_PATH_IS_BLANK to match test expectations.
Copilot uses AI. Check for mistakes.
* @return a {@link ColumnKeyValue} object representing the parsed key-value pair | ||
* @throws IllegalArgumentException if the input is null, empty, or not in the expected format | ||
*/ | ||
public static ColumnKeyValue parseKeyValue(String keyValue) { |
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.
This class is CommandLineInputUtils
and the method name is parseKeyValue()
. So, it doesn't seem to return the specific type ColumnKeyValue
. How about returning more generic type like Pair<K, V>
or Tuple<K, V>
(or Map.Entry<K, V>?) ?
See also #2617 (comment)
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.
@komamitsu san,
I have updated the util method implementation and also made changes to use the function to parse the scan order.
Thank you.
@komamitsu san, |
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.
Left a minor comment. Other than that, LGTM! Thank you!
DATA_LOADER_INVALID_KEY_VALUE_INPUT( | ||
Category.USER_ERROR, "0201", "Invalid key-value format: %s", "", ""), | ||
DATA_LOADER_SPLIT_INPUT_VALUE_NULL(Category.USER_ERROR, "0202", "Value must not be null", "", ""), | ||
|
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.
Please remove this empty line.
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.
@brfrn169 san,
I have removed the empty line.
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.
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!
Co-authored-by: Peckstadt Yves <[email protected]> Co-authored-by: Toshihiro Suzuki <[email protected]>
Co-authored-by: Peckstadt Yves <[email protected]> Co-authored-by: Toshihiro Suzuki <[email protected]>
Co-authored-by: Peckstadt Yves <[email protected]> Co-authored-by: Toshihiro Suzuki <[email protected]>
Co-authored-by: Peckstadt Yves <[email protected]> Co-authored-by: Toshihiro Suzuki <[email protected]>
Co-authored-by: Peckstadt Yves <[email protected]> Co-authored-by: Toshihiro Suzuki <[email protected]>
Description
In this PR I am adding data loader export command and command options for data export.
Related issues and/or PRs
Please review this PR once the below PRs is merged and latest changes from master are merged to this branch
Changes made
I have added the export command options and export command as a CLI command for data export
Checklist
Additional notes (optional)
This is the 2nd PR for dataloader CLI
Release notes
NA