public static StorageSegment newColumnSchema(String name,
                                                 StorageSegment baseSegment,
                                                 List<UpdateColSchema> targetColumnSchema,
                                                 Path storePath) throws IOException {
        validateSchema(targetColumnSchema);

        SegmentSchema baseSchema = baseSegment.schema();

        boolean equals = compareList(baseSchema.getColumns(), targetColumnSchema,
                (c1, c2) -> {
                    return c1.getName().equals(c2.name)
                            && c1.getSqlType() == c2.sqlType
                            && c1.getName().equals(trimAndSpace(c2.value));
                });
        if (equals) {
            return baseSegment;
        }

        SegmentSchema targetSchema = new SegmentSchema(
                targetColumnSchema.stream().map(c -> new ColumnSchema(c.name, c.sqlType, c.isIndexed)).collect(Collectors.toList()));

        int baseColumnCount = baseSchema.getColumns().size();
        StorageSegment.StorageColumnCreator<StorageColumn> scCreator = (ci, cs, rc) -> {
            return getStorageColumn(baseSegment, targetColumnSchema.get(ci), ci, storePath);
        };
        return new StorageSegment<StorageColumn>(baseSegment.version(), baseSegment.mode(), name, targetSchema, baseSegment.rowCount(), scCreator);
    }
Use new columns schema for this segment.

@param name               new segment name.
@param baseSegment        original segment.
@param targetColumnSchema columns the new segment will have.
@param storePath          the location where the new segment stores its newly added columns.
@return the new segment. If nothing is changed, returns the original segment instance.
indexr-segment/src/main/java/io/indexr/segment/storage/UpdateColSegment.java