public static void applySchemaChangeEvent(SchemaChangeEvent event) {
        TableId tableId = event.tableId();
        if (event instanceof CreateTableEvent) {
            if (!globalTables.containsKey(tableId)) {
                globalTables.put(
                        tableId, new ValuesTable(tableId, ((CreateTableEvent) event).getSchema()));
            }
        } else if (event instanceof DropTableEvent) {
            globalTables.remove(tableId);
        } else if (event instanceof TruncateTableEvent) {
            if (globalTables.containsKey(tableId)) {
                ValuesTable table = globalTables.get(event.tableId());
                table.applyTruncateTableEvent((TruncateTableEvent) event);
            }
        } else {
            ValuesTable table = globalTables.get(event.tableId());
            Preconditions.checkNotNull(table, event.tableId() + " is not existed");
            table.applySchemaChangeEvent(event);
        }
    }
@Test
    public void testApplySchemaChangeEvent() throws SchemaEvolveException {
        AddColumnEvent.ColumnWithPosition columnWithPosition =
                new AddColumnEvent.ColumnWithPosition(
                        Column.physicalColumn("col3", new CharType()));
        AddColumnEvent addColumnEvent =
                new AddColumnEvent(table1, Collections.singletonList(columnWithPosition));
        metadataApplier.applySchemaChange(addColumnEvent);
        Schema schema =
                Schema.newBuilder()
                        .physicalColumn("col1", new CharType())
                        .physicalColumn("col2", new CharType())
                        .physicalColumn("col3", new CharType())
                        .primaryKey("col1")
                        .build();
        Assert.assertEquals(schema, metadataAccessor.getTableSchema(table1));

        Map<String, String> nameMapping = new HashMap<>();
        nameMapping.put("col2", "newCol2");
        nameMapping.put("col3", "newCol3");
        RenameColumnEvent renameColumnEvent = new RenameColumnEvent(table1, nameMapping);
        metadataApplier.applySchemaChange(renameColumnEvent);
        schema =
                Schema.newBuilder()
                        .physicalColumn("col1", new CharType())
                        .physicalColumn("newCol2", new CharType())
                        .physicalColumn("newCol3", new CharType())
                        .primaryKey("col1")
                        .build();
        Assert.assertEquals(schema, metadataAccessor.getTableSchema(table1));

        DropColumnEvent dropColumnEvent =
                new DropColumnEvent(table1, Collections.singletonList("newCol2"));
        metadataApplier.applySchemaChange(dropColumnEvent);
        schema =
                Schema.newBuilder()
                        .physicalColumn("col1", new CharType())
                        .physicalColumn("newCol3", new CharType())
                        .primaryKey("col1")
                        .build();
        Assert.assertEquals(schema, metadataAccessor.getTableSchema(table1));

        Map<String, DataType> typeMapping = new HashMap<>();
        typeMapping.put("newCol3", new VarCharType());
        AlterColumnTypeEvent alterColumnTypeEvent = new AlterColumnTypeEvent(table1, typeMapping);
        metadataApplier.applySchemaChange(alterColumnTypeEvent);
        schema =
                Schema.newBuilder()
                        .physicalColumn("col1", new CharType())
                        .physicalColumn("newCol3", new VarCharType())
                        .primaryKey("col1")
                        .build();
        Assert.assertEquals(schema, metadataAccessor.getTableSchema(table1));
    }