@Test
  public void testCreateTimeSeriesWithMerge() throws Exception {
    final ISchemaRegion schemaRegion = getSchemaRegion("root.sg", 0);

    final Map<String, String> oldTagMap = Collections.singletonMap("tagK", "tagV");
    final Map<String, String> oldAttrMap = Collections.singletonMap("attrK1", "attrV1");
    schemaRegion.createTimeSeries(
        SchemaRegionWritePlanFactory.getCreateTimeSeriesPlan(
            new MeasurementPath("root.sg.wf01.wt01.v1.s1"),
            TSDataType.BOOLEAN,
            TSEncoding.PLAIN,
            CompressionType.SNAPPY,
            null,
            oldTagMap,
            oldAttrMap,
            null),
        -1);

    final Map<String, String> newTagMap = Collections.singletonMap("tagK", "newTagV");
    final Map<String, String> newAttrMap = Collections.singletonMap("attrK2", "attrV2");
    ICreateTimeSeriesPlan mergePlan =
        SchemaRegionWritePlanFactory.getCreateTimeSeriesPlan(
            new MeasurementPath("root.sg.wf01.wt01.v1.s1"),
            TSDataType.BOOLEAN,
            TSEncoding.RLE,
            CompressionType.ZSTD,
            null,
            newTagMap,
            newAttrMap,
            "alias2");
    ((CreateTimeSeriesPlanImpl) mergePlan).setWithMerge(true);
    schemaRegion.createTimeSeries(mergePlan, -1);

    // The encoding and compressor won't be changed
    // The alias/tags/attributes are updated

    final Map<String, String> resultAttrMap = new HashMap<>(oldAttrMap);
    resultAttrMap.putAll(newAttrMap);

    checkSingleTimeSeries(
        schemaRegion,
        new PartialPath("root.sg.wf01.wt01.v1.s1"),
        false,
        TSDataType.BOOLEAN,
        TSEncoding.PLAIN,
        CompressionType.SNAPPY,
        "alias2",
        newTagMap,
        resultAttrMap);

    // Test illegal plan
    try {
      mergePlan =
          SchemaRegionWritePlanFactory.getCreateTimeSeriesPlan(
              new MeasurementPath("root.sg.wf01.wt01.v1.s1"),
              TSDataType.INT64,
              TSEncoding.PLAIN,
              CompressionType.ZSTD,
              null,
              oldTagMap,
              oldAttrMap,
              null);
      ((CreateTimeSeriesPlanImpl) mergePlan).setWithMerge(true);
      schemaRegion.createTimeSeries(mergePlan, -1);
      Assert.fail("Create time series with merge shall fail if the types are different");
    } catch (final MeasurementAlreadyExistException e) {
      // Success
    }
  }
This class define test cases for {@link ISchemaRegion}. All test cases will be run in both Memory
and PBTree modes. In PBTree mode, there are three kinds of test environment: full memory, partial
memory and non memory.
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionBasicTest.java