You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2026/01/16 03:54:03 UTC
(iotdb) branch force_ci/support_schema_evolution updated (33dd195284b -> 2d0abd89cbd)
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a change to branch force_ci/support_schema_evolution
in repository https://gitbox.apache.org/repos/asf/iotdb.git
from 33dd195284b fix that copy of EvolvedSchema is not deep enough
new 452ef817e01 spotless
new 2d0abd89cbd add more tests
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../iotdb/relational/it/schema/IoTDBTableIT.java | 108 ++++++++++++++++++---
.../dataregion/tsfile/evolution/EvolvedSchema.java | 12 +--
2 files changed, 102 insertions(+), 18 deletions(-)
(iotdb) 02/02: add more tests
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch force_ci/support_schema_evolution
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 2d0abd89cbde8f0988c5a9491f3eb0118ef1bfb0
Author: Tian Jiang <jt...@163.com>
AuthorDate: Fri Jan 16 11:05:57 2026 +0800
add more tests
---
.../iotdb/relational/it/schema/IoTDBTableIT.java | 89 ++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
index 3fff7ed9a02..803bfb5d10d 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
@@ -1641,4 +1641,93 @@ public class IoTDBTableIT {
}
}
}
+
+ @Test
+ public void testAlterTableAndColumn_RenameTableThenColumn() throws Exception {
+ try (final Connection connection =
+ EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ final Statement statement = connection.createStatement()) {
+ statement.execute("DROP DATABASE IF EXISTS testdb");
+ statement.execute("CREATE DATABASE IF NOT EXISTS testdb");
+ statement.execute("USE testdb");
+
+ statement.execute("CREATE TABLE IF NOT EXISTS tboth (s1 int32)");
+ statement.execute("INSERT INTO tboth (time, s1) VALUES (1, 1)");
+
+ // rename table first
+ statement.execute("ALTER TABLE tboth RENAME TO tboth_new");
+
+ // then rename column on the new table
+ statement.execute("ALTER TABLE tboth_new RENAME COLUMN s1 TO s_new");
+
+ // old table name should not exist anymore
+ try {
+ statement.execute("INSERT INTO tboth (time, s1) VALUES (2, 2)");
+ fail();
+ } catch (final SQLException e) {
+ assertTrue(e.getMessage().startsWith("550") || e.getMessage().toLowerCase().contains("does not exist"));
+ }
+
+ // insert into the renamed table using the renamed column
+ statement.execute("INSERT INTO tboth_new (time, s_new) VALUES (2, 2)");
+
+ ResultSet rs = statement.executeQuery("SELECT * FROM tboth_new");
+ // first row from original name should be present and second row inserted after renames
+ assertTrue(rs.next());
+ assertEquals(1, rs.getLong(1));
+ assertEquals(1, rs.getInt(2));
+ assertTrue(rs.next());
+ assertEquals(2, rs.getLong(1));
+ assertEquals(2, rs.getInt(2));
+ assertFalse(rs.next());
+ }
+ }
+
+ @Test
+ public void testAlterTableAndColumn_RenameColumnThenTable() throws Exception {
+ try (final Connection connection =
+ EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ final Statement statement = connection.createStatement()) {
+ statement.execute("DROP DATABASE IF EXISTS testdb");
+ statement.execute("CREATE DATABASE IF NOT EXISTS testdb");
+ statement.execute("USE testdb");
+
+ statement.execute("CREATE TABLE IF NOT EXISTS tboth2 (c1 int32)");
+ statement.execute("INSERT INTO tboth2 (time, c1) VALUES (1, 1)");
+
+ // rename column first
+ statement.execute("ALTER TABLE tboth2 RENAME COLUMN c1 TO c2");
+
+ // after column rename, old column should not be auto-creatable
+ try {
+ statement.execute("INSERT INTO tboth2 (time, c1) VALUES (2, 2)");
+ fail();
+ } catch (final SQLException e) {
+ assertTrue(e.getMessage().startsWith("616") || e.getMessage().toLowerCase().contains("unknown") || e.getMessage().toLowerCase().contains("cannot"));
+ }
+
+ // then rename the table
+ statement.execute("ALTER TABLE tboth2 RENAME TO tboth2_new");
+
+ // old table name should not exist
+ try {
+ statement.execute("INSERT INTO tboth2 (time, c2) VALUES (3, 3)");
+ fail();
+ } catch (final SQLException e) {
+ assertTrue(e.getMessage().startsWith("550") || e.getMessage().toLowerCase().contains("does not exist"));
+ }
+
+ // insert into the new table using the renamed column
+ statement.execute("INSERT INTO tboth2_new (time, c2) VALUES (2, 2)");
+ statement.execute("INSERT INTO tboth2_new (time, c2) VALUES (3, 3)");
+
+ ResultSet rs = statement.executeQuery("SELECT * FROM tboth2_new ORDER BY time");
+ for (int i = 1; i <= 3; i++) {
+ assertTrue(rs.next());
+ assertEquals(i, rs.getLong(1));
+ assertEquals(i, rs.getInt(2));
+ }
+ assertFalse(rs.next());
+ }
+ }
}
(iotdb) 01/02: spotless
Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch force_ci/support_schema_evolution
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 452ef817e015192f4242b2f49cb4d7cd95cb6b47
Author: Tian Jiang <jt...@163.com>
AuthorDate: Fri Jan 16 10:55:16 2026 +0800
spotless
---
.../iotdb/relational/it/schema/IoTDBTableIT.java | 19 +++++++------------
.../dataregion/tsfile/evolution/EvolvedSchema.java | 12 ++++++------
2 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
index 109b863cc49..3fff7ed9a02 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
@@ -625,7 +625,6 @@ public class IoTDBTableIT {
assertEquals("701: Columns in table shall not share the same name time.", e.getMessage());
}
} catch (final SQLException e) {
- e.printStackTrace();
fail(e.getMessage());
}
}
@@ -1435,7 +1434,8 @@ public class IoTDBTableIT {
statement.execute("ALTER TABLE rename_same RENAME TO rename_same");
fail();
} catch (SQLException e) {
- assertEquals("701: The table's old name shall not be equal to the new one.", e.getMessage());
+ assertEquals(
+ "701: The table's old name shall not be equal to the new one.", e.getMessage());
}
}
}
@@ -1560,12 +1560,7 @@ public class IoTDBTableIT {
assertEquals(2, md.getColumnCount());
String colName = md.getColumnName(2);
// accept either exact quoted name or normalized variant
- assertTrue(
- colName.equals("s-特")
- || colName.equals("s-\u7279")
- || colName.equals("s特")
- || colName.equals("s_特")
- || colName.length() > 0);
+ assertTrue(colName.equals("s-特") || colName.equals("s特") || colName.equals("s_特"));
}
}
@@ -1586,12 +1581,12 @@ public class IoTDBTableIT {
statement.execute("ALTER TABLE tmulti RENAME COLUMN b TO c");
statement.execute("INSERT INTO tmulti (time, c) VALUES (3, 3)");
-//
-// statement.execute("ALTER TABLE tmulti RENAME COLUMN c TO a");
-// statement.execute("INSERT INTO tmulti (time, a) VALUES (4, 4)");
+
+ statement.execute("ALTER TABLE tmulti RENAME COLUMN c TO a");
+ statement.execute("INSERT INTO tmulti (time, a) VALUES (4, 4)");
ResultSet rs = statement.executeQuery("SELECT * FROM tmulti");
- for (int i = 1; i <= 3; i++) {
+ for (int i = 1; i <= 4; i++) {
assertTrue(rs.next());
assertEquals(i, rs.getLong(1));
assertEquals(i, rs.getInt(2));
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/evolution/EvolvedSchema.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/evolution/EvolvedSchema.java
index a90817781e9..e32d3649c94 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/evolution/EvolvedSchema.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/tsfile/evolution/EvolvedSchema.java
@@ -316,17 +316,17 @@ public class EvolvedSchema implements Accountable {
EvolvedSchema newEvolvedSchema = new EvolvedSchema();
newEvolvedSchema.finalToOriginalTableNames =
new LinkedHashMap<>(evolvedSchema.finalToOriginalTableNames);
- newEvolvedSchema.finalToOriginalColumnNames =
- new LinkedHashMap<>();
- for (Entry<String, Map<String, String>> entry : evolvedSchema.finalToOriginalColumnNames.entrySet()) {
+ newEvolvedSchema.finalToOriginalColumnNames = new LinkedHashMap<>();
+ for (Entry<String, Map<String, String>> entry :
+ evolvedSchema.finalToOriginalColumnNames.entrySet()) {
newEvolvedSchema.finalToOriginalColumnNames.put(
entry.getKey(), new LinkedHashMap<>(entry.getValue()));
}
newEvolvedSchema.originalToFinalTableNames =
new LinkedHashMap<>(evolvedSchema.originalToFinalTableNames);
- newEvolvedSchema.originalToFinalColumnNames =
- new LinkedHashMap<>();
- for (Entry<String, Map<String, String>> entry : evolvedSchema.originalToFinalColumnNames.entrySet()) {
+ newEvolvedSchema.originalToFinalColumnNames = new LinkedHashMap<>();
+ for (Entry<String, Map<String, String>> entry :
+ evolvedSchema.originalToFinalColumnNames.entrySet()) {
newEvolvedSchema.originalToFinalColumnNames.put(
entry.getKey(), new LinkedHashMap<>(entry.getValue()));
}