public void checkSchemaChangeAllowed(Column other) throws DdlException {
        if (other.isGeneratedColumn()) {
            return;
        }

        if (Strings.isNullOrEmpty(other.name)) {
            throw new DdlException("Dest column name is empty");
        }

        if (!ColumnType.isSchemaChangeAllowed(type, other.type)) {
            throw new DdlException("Can not change " + getType() + " to " + other.getType());
        }

        if (this.aggregationType != other.aggregationType) {
            throw new DdlException("Can not change aggregation type");
        }

        if (this.isAllowNull && !other.isAllowNull) {
            throw new DdlException("Can not change from nullable to non-nullable");
        }

        // Adding a default value to a column without a default value is not supported
        if (!this.isSameDefaultValue(other)) {
            throw new DdlException(CAN_NOT_CHANGE_DEFAULT_VALUE);
        }

        if ((getPrimitiveType() == PrimitiveType.VARCHAR && other.getPrimitiveType() == PrimitiveType.VARCHAR)
                || (getPrimitiveType() == PrimitiveType.CHAR && other.getPrimitiveType() == PrimitiveType.VARCHAR)
                || (getPrimitiveType() == PrimitiveType.CHAR && other.getPrimitiveType() == PrimitiveType.CHAR)) {
            if (getStrLen() > other.getStrLen()) {
                throw new DdlException("Cannot shorten string length");
            }
        }
        if (getPrimitiveType().isJsonType() && other.getPrimitiveType().isCharFamily()) {
            if (other.getStrLen() <= getPrimitiveType().getTypeSize()) {
                throw new DdlException("JSON needs minimum length of " + getPrimitiveType().getTypeSize());
            }
        }
    }
@Test
    public void testSchemaChangeAllowNormal() throws DdlException {
        Column oldColumn = new Column("user", ScalarType.createType(PrimitiveType.INT), true, null, false,
                NULL_DEFAULT_VALUE, "");
        Column newColumn = new Column("user", ScalarType.createType(PrimitiveType.VARCHAR), true, null, false,
                NULL_DEFAULT_VALUE, "");
        oldColumn.checkSchemaChangeAllowed(newColumn);

        oldColumn = new Column("user", ScalarType.createType(PrimitiveType.VARCHAR), true, null, false,
                new ColumnDef.DefaultValueDef(true, new StringLiteral("0")), "");
        newColumn = new Column("user", ScalarType.createType(PrimitiveType.VARCHAR), true, null, false,
                new ColumnDef.DefaultValueDef(true, new StringLiteral("0")), "");
        oldColumn.checkSchemaChangeAllowed(newColumn);

        oldColumn = new Column("user", ScalarType.createType(PrimitiveType.DATETIME), true, null, false,
                CURRENT_TIMESTAMP_VALUE, "");
        newColumn = new Column("user", ScalarType.createType(PrimitiveType.DATETIME), true, null, false,
                CURRENT_TIMESTAMP_VALUE, "");
        oldColumn.checkSchemaChangeAllowed(newColumn);
    }