amrishlal commented on a change in pull request #7259:
URL: https://github.com/apache/pinot/pull/7259#discussion_r683861872



##########
File path: pinot-spi/src/main/java/org/apache/pinot/spi/data/Schema.java
##########
@@ -673,7 +679,15 @@ public boolean isBackwardCompatibleWith(Schema oldSchema) {
       FieldSpec oldSchemaFieldSpec = entry.getValue();
       FieldSpec fieldSpec = getFieldSpecFor(oldSchemaColumnName);
       if (!fieldSpec.equals(oldSchemaFieldSpec)) {
-        return false;
+        if (fieldSpec.getDataType() == DataType.BOOLEAN) {
+          // For BOOLEAN data type, replace with STRING and compare again to 
keep backward-compatibility
+          fieldSpec.setDataType(DataType.STRING);
+          if (!fieldSpec.equals(oldSchemaFieldSpec)) {
+            return false;
+          }
+        } else {
+          return false;
+        }
       }

Review comment:
       Would suggest simplifying this code block (three nested if statements 
and three returns) to:
   ```
   if (fieldSpec.getDataType() == DataType.BOOLEAN && 
oldSchemaFieldSpec.getDataType() == DataType.STRING) {
     // Replace BOOLEAN with STRING if existing FieldSpec is STRING.
     fieldSpec.setDataType(DataType.STRING);
   }
   
   if (fieldSpec.equals(oldSchemaFieldSpec)) {
     return false;
   }
   ```
   otherwise, LGTM.




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