[GitHub] [hudi] codope commented on a diff in pull request #5637: [HUDI-4124] Add valid check in Spark Datasource configs

2022-05-26 Thread GitBox


codope commented on code in PR #5637:
URL: https://github.com/apache/hudi/pull/5637#discussion_r882439372


##
hudi-common/src/main/java/org/apache/hudi/common/config/ConfigProperty.java:
##
@@ -95,33 +99,46 @@ Option>> getInferFunc() {
 return inferFunction;
   }
 
+  public void checkValues(String value) {
+if (validValues != null && !validValues.isEmpty() && 
!validValues.contains(value)) {
+  throw new IllegalArgumentException(
+  "The value of " + key + " should be one of "
+  + String.join(",", validValues) + ", but was " + value);
+}
+  }
+
   public List getAlternatives() {
 return Arrays.asList(alternatives);
   }
 
   public ConfigProperty withDocumentation(String doc) {
 Objects.requireNonNull(doc);
-return new ConfigProperty<>(key, defaultValue, doc, sinceVersion, 
deprecatedVersion, inferFunction, alternatives);
+return new ConfigProperty<>(key, defaultValue, doc, sinceVersion, 
deprecatedVersion, inferFunction, validValues, alternatives);
+  }
+
+  public ConfigProperty withValidValues(List validValues) {

Review Comment:
   From that perspective, I agree list is more consistent. Perf does not matter 
much for just a few elements. 
   @wzx140 sorry for the trouble, but can you revert it back to 
`withValidValues(String... validValues)`



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [hudi] codope commented on a diff in pull request #5637: [HUDI-4124] Add valid check in Spark Datasource configs

2022-05-25 Thread GitBox


codope commented on code in PR #5637:
URL: https://github.com/apache/hudi/pull/5637#discussion_r882337916


##
hudi-common/src/main/java/org/apache/hudi/common/config/ConfigProperty.java:
##
@@ -95,33 +99,46 @@ Option>> getInferFunc() {
 return inferFunction;
   }
 
+  public void checkValues(String value) {
+if (validValues != null && !validValues.isEmpty() && 
!validValues.contains(value)) {
+  throw new IllegalArgumentException(
+  "The value of " + key + " should be one of "
+  + String.join(",", validValues) + ", but was " + value);
+}
+  }
+
   public List getAlternatives() {
 return Arrays.asList(alternatives);
   }
 
   public ConfigProperty withDocumentation(String doc) {
 Objects.requireNonNull(doc);
-return new ConfigProperty<>(key, defaultValue, doc, sinceVersion, 
deprecatedVersion, inferFunction, alternatives);
+return new ConfigProperty<>(key, defaultValue, doc, sinceVersion, 
deprecatedVersion, inferFunction, validValues, alternatives);
+  }
+
+  public ConfigProperty withValidValues(List validValues) {

Review Comment:
   Why List? Why not Set?



##
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/config/HoodieIndexConfig.java:
##
@@ -57,7 +64,11 @@ public class HoodieIndexConfig extends HoodieConfig {
 
   public static final ConfigProperty INDEX_TYPE = ConfigProperty
   .key("hoodie.index.type")
-  .noDefaultValue()
+  .defaultValue(SIMPLE.name())

Review Comment:
   There is already `HoodieIndexConfig#getDefaultIndexType` method which sets 
default which gets called by the builder. That method sets value based on 
execution engine. Why are we setting default here? I am not sure simple index 
(which relies on spark lean join) would work with flink. cc @danny0405 



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org