@Test
public void testResultSchema() {

    TableSchema expectSchema = new TableSchema(
        new String[]{"f0", "f1", "f2", "res"},
        new TypeInformation[]{
            TypeInformation.of(String.class),
            TypeInformation.of(Long.class),
            TypeInformation.of(Integer.class),
            TypeInformation.of(String.class)
        }
    );
    OutputColsHelper helper = new OutputColsHelper(
        tableSchema, "res",
        TypeInformation.of(String.class)
    );
    Assert.assertEquals(helper.getResultSchema(), expectSchema);
    expectSchema = new TableSchema(
        new String[]{"f0", "res"},
        new TypeInformation[]{
            TypeInformation.of(String.class),
            TypeInformation.of(String.class)
        }
    );
    helper = new OutputColsHelper(
        tableSchema, "res",
        TypeInformation.of(String.class),
        reservedColNames
    );
    Assert.assertEquals(helper.getResultSchema(), expectSchema);
    expectSchema = new TableSchema(
        new String[]{"f0", "res1", "res2"},
        new TypeInformation[]{
            TypeInformation.of(String.class),
            TypeInformation.of(String.class),
            TypeInformation.of(Integer.class)
        }
    );
    helper = new OutputColsHelper(
        tableSchema,
        new String[]{"res1", "res2"},
        new TypeInformation[]{
            TypeInformation.of(String.class),
            TypeInformation.of(Integer.class)},
        reservedColNames
    );
    Assert.assertEquals(helper.getResultSchema(), expectSchema);
    expectSchema = new TableSchema(
        new String[]{"f0", "f1", "f2", "res"},
        new TypeInformation[]{
            TypeInformation.of(String.class),
            TypeInformation.of(Long.class),
            TypeInformation.of(Integer.class),
            TypeInformation.of(String.class)
        }
    );
    helper = new OutputColsHelper(
        tableSchema, "res",
        TypeInformation.of(String.class)
    );
    Assert.assertEquals(helper.getResultSchema(), expectSchema);
    expectSchema = new TableSchema(
        new String[]{"f0", "f1", "f2"},
        new TypeInformation[]{
            TypeInformation.of(Integer.class),
            TypeInformation.of(Long.class),
            TypeInformation.of(Integer.class)
        }
    );
    helper = new OutputColsHelper(
        tableSchema, "f0",
        TypeInformation.of(Integer.class)
    );
    Assert.assertEquals(helper.getResultSchema(), expectSchema);
    expectSchema = new TableSchema(
        new String[]{"f0", "f1", "f2"},
        new TypeInformation[]{
            TypeInformation.of(Integer.class),
            TypeInformation.of(Long.class),
            TypeInformation.of(String.class)
        }
    );
    helper = new OutputColsHelper(
        tableSchema, new String[]{"f0", "f2"},
        new TypeInformation[]{
            TypeInformation.of(Integer.class),
            TypeInformation.of(String.class)
        }
    );
    Assert.assertEquals(helper.getResultSchema(), expectSchema);
    expectSchema = new TableSchema(
        new String[]{"f0", "res"},
        new TypeInformation[]{
            TypeInformation.of(String.class),
            TypeInformation.of(Integer.class)
        }
    );
    helper = new OutputColsHelper(
        tableSchema, new String[]{"res", "f0"},
        new TypeInformation[]{
            TypeInformation.of(Integer.class),
            TypeInformation.of(String.class)
        },
        reservedColNames
    );
    Assert.assertEquals(helper.getResultSchema(), expectSchema);
    expectSchema = new TableSchema(
        new String[]{"f0", "f1", "res"},
        new TypeInformation[]{
            TypeInformation.of(String.class),
            TypeInformation.of(Long.class),
            TypeInformation.of(Integer.class)
        }
    );
    helper = new OutputColsHelper(
        tableSchema, new String[]{"res"},
        new TypeInformation[]{
            TypeInformation.of(Integer.class),
            TypeInformation.of(String.class)},
        new String[]{"f1", "f0"}
    );
    Assert.assertEquals(helper.getResultSchema(), expectSchema);
}