bbiiaaoo commented on code in PR #10637:
URL: https://github.com/apache/gravitino/pull/10637#discussion_r3198811484
##########
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceNameSpaceOperations.java:
##########
@@ -414,6 +408,56 @@ private <T> T[] buildChanges(
return Stream.concat(setPropertiesStream,
removePropertiesStream).toArray(arrayCreator);
}
+ private static CreateMode parseCreateMode(String instance, String mode) {
+ if (mode == null) {
+ return CreateMode.CREATE;
+ }
+ String normalized = CommonUtil.normalizeToken(mode);
+ if ("CREATE".equals(normalized)) {
+ return CreateMode.CREATE;
+ }
+ if ("EXISTOK".equals(normalized)) {
+ return CreateMode.EXIST_OK;
+ }
+ if ("OVERWRITE".equals(normalized)) {
+ return CreateMode.OVERWRITE;
+ }
+ throw new InvalidInputException(
+ "Unknown create namespace mode: " + mode,
CommonUtil.formatCurrentStackTrace(), instance);
+ }
+
+ private static DropMode parseDropMode(String instance, String mode) {
+ if (mode == null) {
+ return DropMode.FAIL;
+ }
+ String normalized = CommonUtil.normalizeToken(mode);
+ if ("FAIL".equals(normalized)) {
Review Comment:
Thanks for the suggestion. `DropMode.valueOf(normalized)` would work for
this enum since the values are `FAIL` and `SKIP`.
I kept the explicit mapping here to make it consistent with the other mode
parsers, especially `CreateMode`, where `normalizeToken()` turns values like
`exist_ok` into `EXISTOK`, so `CreateMode.valueOf(...)` would not work
directly. The explicit mapping also lets us keep throwing
`InvalidInputException` with the Lance-specific error context instead of
relying on `IllegalArgumentException` from `valueOf()` and wrapping it
separately.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]