-
Notifications
You must be signed in to change notification settings - Fork 38
Add import command for data loader CLI #2618
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
base: master
Are you sure you want to change the base?
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 import
command to the data loader CLI, including command options, implementation, and a basic unit test.
- Introduce
ImportCommandOptions
with various CLI flags for importing - Implement
ImportCommand
to wire options intoImportManager
and handle validation/logging - Add
ImportCommandTest
to verify behavior when required inputs are missing
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
ImportCommandOptions.java | Defined new PicoCLI options for the import command |
ImportCommand.java | Implemented import command logic, validation, and wiring to core import APIs |
ImportCommandTest.java | Added a test for missing/invalid config and import file |
Comments suppressed due to low confidence (2)
data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/command/dataimport/ImportCommand.java:148
- Typo in variable name
scalarDbStorageManger
(should bescalarDbStorageManager
).
ScalarDbStorageManager scalarDbStorageManger =
data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/command/dataimport/ImportCommandTest.java:50
- The test expects
IllegalArgumentException
, but the command may throw aParameterException
or other exception type. Update the assertion to expect the correct exception or add more precise error checking.
assertThrows(IllegalArgumentException.class, () -> importCommand.call());
protected char delimiter; | ||
|
||
@CommandLine.Option( | ||
names = {"--header", "-h"}, |
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 short option '-h' typically maps to help; consider choosing a different short flag to avoid clashing with PicoCLI's default help option.
names = {"--header", "-h"}, | |
names = {"--header", "-hdr"}, |
Copilot uses AI. Check for mistakes.
* @throws ParameterException if the path is invalid | ||
*/ | ||
private Optional<ControlFile> parseControlFileFromPath(String controlFilePath) { | ||
if (controlFilePath == 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.
parseControlFileFromPath
only checks for null but not blank strings; an empty ""
path will cause ObjectMapper
to try reading a non-existent file. Consider using StringUtils.isBlank(controlFilePath)
.
if (controlFilePath == null) { | |
if (StringUtils.isBlank(controlFilePath)) { |
Copilot uses AI. Check for mistakes.
builder.importMode(importMode); | ||
} | ||
if (!splitLogMode) { | ||
builder.logMode(LogMode.SINGLE_FILE); |
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 splitLogMode
flag is only used to set SINGLE_FILE mode; when true, you never set LogMode.SPLIT_BY_DATA_CHUNK
. Add an else
block to set the split-chunk mode.
builder.logMode(LogMode.SINGLE_FILE); | |
builder.logMode(LogMode.SINGLE_FILE); | |
} else { | |
builder.logMode(LogMode.SPLIT_BY_DATA_CHUNK); |
Copilot uses AI. Check for mistakes.
|
||
@CommandLine.Command(name = "import", description = "Import data into a ScalarDB table") | ||
@CommandLine.Command(name = "import", description = "import data into a ScalarDB table") |
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] The command description was changed to start with a lowercase letter; for consistency with other commands, consider capitalizing the first word.
@CommandLine.Command(name = "import", description = "import data into a ScalarDB table") | |
@CommandLine.Command(name = "import", description = "Import data into a ScalarDB table") |
Copilot uses AI. Check for mistakes.
Description
In this PR I am adding data loader import command and command options for data import.
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 import command options and import command as a CLI command for data import
Checklist
Additional notes (optional)
This is the third PR for data loader CLI.
Release notes
NA