xiarixiaoyao commented on issue #8020:
URL: https://github.com/apache/hudi/issues/8020#issuecomment-1443122303

   @simonjobs 
   1)  pls cherry-pick https://github.com/apache/hudi/pull/7326,  
   0.12.1 cannot do type change.    
   2)  hooide require that decimal must be expanded with precision and scale at 
the same time
   if we just want to expand precision,   SchemaChangeUtils.isTypeUpdateAllow  
should relax restrictions
   ```
     public static boolean isTypeUpdateAllow(Type src, Type dsr) {
       if (src.isNestedType() || dsr.isNestedType()) {
         throw new IllegalArgumentException("only support update primitive 
type");
       }
       if (src.equals(dsr)) {
         return true;
       }
       switch (src.typeId()) {
         case INT:
           return dsr == Types.LongType.get() || dsr == Types.FloatType.get()
               || dsr == Types.DoubleType.get() || dsr == 
Types.StringType.get() || dsr.typeId() == Type.TypeID.DECIMAL;
         case LONG:
           return dsr == Types.FloatType.get() || dsr == Types.DoubleType.get() 
|| dsr == Types.StringType.get() || dsr.typeId() == Type.TypeID.DECIMAL;
         case FLOAT:
           return dsr == Types.DoubleType.get() || dsr == 
Types.StringType.get() || dsr.typeId() == Type.TypeID.DECIMAL;
         case DOUBLE:
           return dsr == Types.StringType.get() || dsr.typeId() == 
Type.TypeID.DECIMAL;
         case DATE:
           return dsr == Types.StringType.get();
         case DECIMAL:
           if (dsr.typeId() == Type.TypeID.DECIMAL) {
             Types.DecimalType decimalSrc = (Types.DecimalType)src;
             Types.DecimalType decimalDsr = (Types.DecimalType)dsr;
             if (decimalDsr.isWiderThan(decimalSrc)) {
               return true;
             }
             if (decimalDsr.precision() >= decimalSrc.precision() && 
decimalDsr.scale() == decimalSrc.scale()) {
               return true;
             }
           } else if (dsr.typeId() == Type.TypeID.STRING) {
             return true;
           }
           break;
         case STRING:
           return dsr == Types.DateType.get() || dsr.typeId() == 
Type.TypeID.DECIMAL;
         default:
           return false;
       }
       return false;
     }
   
   
   ```
   


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

Reply via email to