Skip to content

Conversation

@brfrn169
Copy link
Collaborator

@brfrn169 brfrn169 commented Jun 20, 2025

Description

This PR splits the schema-loader errors and the data-loader errors from CoreError.

Related issues and/or PRs

N/A

Changes made

  • Added SchemaLoderError, and moved the schema-loader related errors to it from CoreError.
  • Added DataLoderError, and moved the data-loader related errors to it CoreError.
  • Move CoreError to the package com.scalar.db.common.

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

N/A

@brfrn169 brfrn169 self-assigned this Jun 20, 2025
@brfrn169 brfrn169 requested a review from Copilot June 20, 2025 05:22
Copy link
Contributor

Copilot AI left a 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 extracts schema-loader and data-loader errors from CoreError into their own enums (SchemaLoaderError, DataLoaderError) and updates all references accordingly.

  • Introduced SchemaLoaderError enum and replaced CoreError usage in schema-loader module
  • Introduced DataLoaderError enum and updated tests and code in data-loader and CLI modules to use it
  • Added uniqueness tests for both error enums

Reviewed Changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoaderError.java New enum for schema-loader error codes
schema-loader/src/main/java/com/scalar/db/schemaloader/command/SchemaLoaderCommand.java Replaced CoreError with SchemaLoaderError in CLI commands
schema-loader/src/main/java/com/scalar/db/schemaloader/alteration/TableMetadataAlterationProcessor.java Updated error references to use SchemaLoaderError
schema-loader/src/main/java/com/scalar/db/schemaloader/TableSchema.java Swapped CoreError for SchemaLoaderError in parsing logic
schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaOperator.java Updated table-not-found error to SchemaLoaderError
schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderErrorTest.java Added duplicate-code check for SchemaLoaderError
data-loader/core/src/main/java/com/scalar/db/dataloader/core/DataLoaderError.java New enum for data-loader error codes
data-loader/core/src/main/java/com/scalar/db/dataloader/core/util/*.java Replaced CoreError with DataLoaderError in utility classes
data-loader/core/src/test/java/com/scalar/db/dataloader/core/*.java Updated tests to use DataLoaderError
data-loader/cli/src/main/java/com/scalar/db/dataloader/cli/util/*.java Replaced CoreError with DataLoaderError in CLI utils
data-loader/cli/src/test/java/com/scalar/db/dataloader/cli/util/*.java Updated CLI tests to use DataLoaderError
Comments suppressed due to low confidence (2)

schema-loader/src/main/java/com/scalar/db/schemaloader/command/SchemaLoaderCommand.java:144

  • Consider throwing SchemaLoaderException (or wrapping the IllegalArgumentException) here instead of a raw IllegalArgumentException, to align with the method signature and centralize error handling.
      throw new IllegalArgumentException(

schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoaderError.java:1

  • [nitpick] You may want to add class-level Javadoc to SchemaLoaderError explaining its purpose and how error codes map to user scenarios.
package com.scalar.db.schemaloader;

SPECIFYING_SCHEMA_FILE_REQUIRED_WHEN_USING_ALTER(
Category.USER_ERROR,
"0007",
"Specifying the '--schema-file' option is required when using the '--alter' option",
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

[nitpick] For consistency with other messages, consider adding a trailing period to this error message.

Suggested change
"Specifying the '--schema-file' option is required when using the '--alter' option",
"Specifying the '--schema-file' option is required when using the '--alter' option.",

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

Odd that Copilot suggests the period only here. If we apply the period here, we should apply it consistently to all other messages. However, I believe it was decided that we wouldn't add periods to messages that contained only one sentence.

@brfrn169 brfrn169 force-pushed the split-schema-loder-errors-and-data-loader-errors-from-CoreError branch from f2400a0 to 9902070 Compare June 20, 2025 05:28
import com.scalar.db.common.error.Category;
import com.scalar.db.common.error.ScalarDbError;

public enum DataLoaderError implements ScalarDbError {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@josh-wong IIRC, you haven’t checked the error messages in data-loader yet. If that’s correct, could you please take a look? 🙇

Category.INTERNAL_ERROR, "0006", "Failed to read JSON Lines file. Details: %s", "", ""),
;

private static final String COMPONENT_NAME = "DB-DATA-LOADER";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@feeblefakie The prefix of the error code for data-loader is DB-DATA-LOADER. Is that okay?

Category.USER_ERROR, "0017", "Invalid column type. Table: %s; Column: %s; Type: %s", "", ""),
;

private static final String COMPONENT_NAME = "DB-SCHEMA-LOADER";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@feeblefakie The prefix of the error code for schema-loader is DB-SCHEMA-LOADER. Is that okay?

Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Copy link
Contributor

@ypeckstadt ypeckstadt left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you.

Copy link
Contributor

@inv-jishnu inv-jishnu left a comment

Choose a reason for hiding this comment

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

LGTM!
Thank you!

Copy link
Contributor

@thongdk8 thongdk8 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

Copy link
Member

@josh-wong josh-wong left a comment

Choose a reason for hiding this comment

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

I've added some comments and suggestions. PTAL!

SPECIFYING_SCHEMA_FILE_REQUIRED_WHEN_USING_ALTER(
Category.USER_ERROR,
"0007",
"Specifying the '--schema-file' option is required when using the '--alter' option",
Copy link
Member

Choose a reason for hiding this comment

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

Odd that Copilot suggests the period only here. If we apply the period here, we should apply it consistently to all other messages. However, I believe it was decided that we wouldn't add periods to messages that contained only one sentence.

Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@brfrn169 brfrn169 requested a review from josh-wong June 20, 2025 06:58
@brfrn169
Copy link
Collaborator Author

@josh-wong I've just applied your suggestions. Could you please dobule-check? 🙇

Copy link
Member

@josh-wong josh-wong left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!🙇🏻‍♂️

@brfrn169 brfrn169 merged commit de96782 into master Jun 20, 2025
106 of 108 checks passed
@brfrn169 brfrn169 deleted the split-schema-loder-errors-and-data-loader-errors-from-CoreError branch June 20, 2025 08:41
brfrn169 added a commit that referenced this pull request Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants