Jackie-Jiang commented on a change in pull request #7648:
URL: https://github.com/apache/pinot/pull/7648#discussion_r738837374



##########
File path: 
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
##########
@@ -655,35 +655,39 @@ private static void validateFieldConfigList(@Nullable 
List<FieldConfig> fieldCon
       Preconditions.checkState(fieldConfigColSpec != null,
           "Column Name " + columnName + " defined in field config list must be 
a valid column defined in the schema");
 
-      List<String> noDictionaryColumns = 
indexingConfigs.getNoDictionaryColumns();
-      switch (fieldConfig.getEncodingType()) {
-        case DICTIONARY:
-          if (noDictionaryColumns != null) {
-            
Preconditions.checkArgument(!noDictionaryColumns.contains(columnName),
-                "FieldConfig encoding type is different from indexingConfig 
for column: " + columnName);
-          }
-          Preconditions.checkArgument(fieldConfig.getCompressionCodec() == 
null,
-              "Set compression codec to null for dictionary encoding type");
-          break;
-        default:
-          break;
+      if (fieldConfig.getEncodingType() != null && indexingConfigs != null) {

Review comment:
       Since we already have this validation, I'd suggest making the 
`EncodingType` mandatory in the `FieldConfig`. All the fields should have an 
`EncodingType`

##########
File path: 
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
##########
@@ -655,35 +655,39 @@ private static void validateFieldConfigList(@Nullable 
List<FieldConfig> fieldCon
       Preconditions.checkState(fieldConfigColSpec != null,
           "Column Name " + columnName + " defined in field config list must be 
a valid column defined in the schema");
 
-      List<String> noDictionaryColumns = 
indexingConfigs.getNoDictionaryColumns();
-      switch (fieldConfig.getEncodingType()) {
-        case DICTIONARY:
-          if (noDictionaryColumns != null) {
-            
Preconditions.checkArgument(!noDictionaryColumns.contains(columnName),
-                "FieldConfig encoding type is different from indexingConfig 
for column: " + columnName);
-          }
-          Preconditions.checkArgument(fieldConfig.getCompressionCodec() == 
null,
-              "Set compression codec to null for dictionary encoding type");
-          break;
-        default:
-          break;
+      if (fieldConfig.getEncodingType() != null && indexingConfigs != null) {
+        List<String> noDictionaryColumns = 
indexingConfigs.getNoDictionaryColumns();
+        switch (fieldConfig.getEncodingType()) {
+          case DICTIONARY:
+            if (noDictionaryColumns != null) {
+              
Preconditions.checkArgument(!noDictionaryColumns.contains(columnName),
+                  "FieldConfig encoding type is different from indexingConfig 
for column: " + columnName);
+            }
+            Preconditions.checkArgument(fieldConfig.getCompressionCodec() == 
null,
+                "Set compression codec to null for dictionary encoding type");
+            break;
+          default:
+            break;
+        }
       }
 
-      switch (fieldConfig.getIndexType()) {
-        case FST:
-          Preconditions.checkArgument(fieldConfig.getEncodingType() == 
FieldConfig.EncodingType.DICTIONARY,
-              "FST Index is only enabled on dictionary encoded columns");
-          Preconditions.checkState(
-              fieldConfigColSpec.isSingleValueField() && 
fieldConfigColSpec.getDataType() == DataType.STRING,
-              "FST Index is only supported for single value string columns");
-          break;
-        case TEXT:
-          Preconditions.checkState(
-              fieldConfigColSpec.isSingleValueField() && 
fieldConfigColSpec.getDataType() == DataType.STRING,
-              "TEXT Index is only supported for single value string columns");
-          break;
-        default:
-          break;
+      if (fieldConfig.getIndexType() != null) {

Review comment:
       Let's use the new added `getIndexTypes()` for the check

##########
File path: 
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
##########
@@ -655,35 +655,39 @@ private static void validateFieldConfigList(@Nullable 
List<FieldConfig> fieldCon
       Preconditions.checkState(fieldConfigColSpec != null,
           "Column Name " + columnName + " defined in field config list must be 
a valid column defined in the schema");
 
-      List<String> noDictionaryColumns = 
indexingConfigs.getNoDictionaryColumns();
-      switch (fieldConfig.getEncodingType()) {
-        case DICTIONARY:
-          if (noDictionaryColumns != null) {
-            
Preconditions.checkArgument(!noDictionaryColumns.contains(columnName),
-                "FieldConfig encoding type is different from indexingConfig 
for column: " + columnName);
-          }
-          Preconditions.checkArgument(fieldConfig.getCompressionCodec() == 
null,
-              "Set compression codec to null for dictionary encoding type");
-          break;
-        default:
-          break;
+      if (fieldConfig.getEncodingType() != null && indexingConfigs != null) {
+        List<String> noDictionaryColumns = 
indexingConfigs.getNoDictionaryColumns();
+        switch (fieldConfig.getEncodingType()) {
+          case DICTIONARY:
+            if (noDictionaryColumns != null) {
+              
Preconditions.checkArgument(!noDictionaryColumns.contains(columnName),
+                  "FieldConfig encoding type is different from indexingConfig 
for column: " + columnName);
+            }
+            Preconditions.checkArgument(fieldConfig.getCompressionCodec() == 
null,
+                "Set compression codec to null for dictionary encoding type");
+            break;
+          default:
+            break;
+        }
       }
 
-      switch (fieldConfig.getIndexType()) {
-        case FST:
-          Preconditions.checkArgument(fieldConfig.getEncodingType() == 
FieldConfig.EncodingType.DICTIONARY,
-              "FST Index is only enabled on dictionary encoded columns");
-          Preconditions.checkState(
-              fieldConfigColSpec.isSingleValueField() && 
fieldConfigColSpec.getDataType() == DataType.STRING,
-              "FST Index is only supported for single value string columns");
-          break;
-        case TEXT:
-          Preconditions.checkState(
-              fieldConfigColSpec.isSingleValueField() && 
fieldConfigColSpec.getDataType() == DataType.STRING,
-              "TEXT Index is only supported for single value string columns");
-          break;
-        default:
-          break;
+      if (fieldConfig.getIndexType() != null) {
+        switch (fieldConfig.getIndexType()) {
+          case FST:
+            Preconditions.checkArgument(fieldConfig.getEncodingType() == 
FieldConfig.EncodingType.DICTIONARY,

Review comment:
       This check requires encoding type to exist, so I'd suggest just making 
it mandatory in the `FieldConfig`




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to