@Test
  public void testRenameTagOrAttributeKey() {
    try {
      prepareTimeseries();
      try {
        schemaRegion.renameTagOrAttributeKey(
            "attr1", "attr2", new PartialPath("root.sg.wf01.wt01.v1.s2"));
        Assert.fail();
      } catch (Exception e) {
        Assert.assertTrue(e.getMessage().contains("already has a tag/attribute named"));
      }
      try {
        schemaRegion.renameTagOrAttributeKey(
            "attr3", "newAttr3", new PartialPath("root.sg.wf01.wt01.v1.s2"));
        Assert.fail();
      } catch (Exception e) {
        Assert.assertTrue(e.getMessage().contains("does not have tag/attribute"));
      }
      schemaRegion.renameTagOrAttributeKey(
          "attr1", "newAttr1", new PartialPath("root.sg.wf01.wt01.v1.s2"));
      schemaRegion.renameTagOrAttributeKey(
          "tag1", "newTag1", new PartialPath("root.sg.wf01.wt01.v1.s2"));
      schemaRegion.renameTagOrAttributeKey(
          "attr1", "newAttr1", new PartialPath("root.sg.wf01.aligned_device2.s1"));
      schemaRegion.renameTagOrAttributeKey(
          "tag1", "newTag1", new PartialPath("root.sg.wf01.aligned_device2.s1"));
      checkAttributes(
          "root.sg.wf01.wt01.v1.s2",
          new HashMap<String, String>() {
            {
              put("newAttr1", "a1");
              put("attr2", "a2");
            }
          });
      checkTags(
          "root.sg.wf01.wt01.v1.s2",
          new HashMap<String, String>() {
            {
              put("newTag1", "t1");
              put("tag2", "t2");
            }
          });
      checkAttributes(
          "root.sg.wf01.aligned_device2.s1",
          new HashMap<String, String>() {
            {
              put("newAttr1", "a1");
            }
          });
      checkTags(
          "root.sg.wf01.aligned_device2.s1",
          new HashMap<String, String>() {
            {
              put("newTag1", "t1");
            }
          });
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
Prepare timeseries

<p>"root.sg.wf01.wt01.v1.s1" without tags, attributes and alias

<p>"root.sg.wf01.wt01.v1.s2" with tags, attributes and alias

<p>"root.sg.wf01.aligned_device1.(s1,s2)" aligned without tags, attributes and alias

<p>"root.sg.wf01.aligned_device2.(s1,s2)" aligned with tags, attributes and alias
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/metadata/schemaRegion/SchemaRegionAliasAndTagTest.java