This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 2d436e06897 Optimized the error code when table/column does not exist
& Reduced some unnecessary IT execution
2d436e06897 is described below
commit 2d436e0689704cd7efad14ac0cb7aafeff31f0d6
Author: Caideyipi <[email protected]>
AuthorDate: Fri Jan 10 12:13:40 2025 +0800
Optimized the error code when table/column does not exist & Reduced some
unnecessary IT execution
---
.../relational/it/db/it/IoTDBDeletionTableIT.java | 2 +-
.../relational/it/db/it/IoTDBInsertTableIT.java | 2 +-
.../IoTDBAlignByDeviceWithTemplateTableIT.java | 4 +--
...oTDBNoSelectExpressionAfterAnalyzedTableIT.java | 6 ++---
.../it/query/old/query/IoTDBResultSetTableIT.java | 2 +-
.../iotdb/relational/it/schema/IoTDBDeviceIT.java | 10 ++++----
.../iotdb/relational/it/schema/IoTDBTableIT.java | 4 +--
.../it/session/IoTDBSessionRelationalIT.java | 29 +++-------------------
.../confignode/persistence/schema/ConfigMTree.java | 6 ++---
.../schema/source/TableDeviceQuerySource.java | 4 +--
.../relational/analyzer/ExpressionAnalyzer.java | 6 ++---
.../plan/relational/analyzer/Scope.java | 8 +++++-
.../relational/analyzer/StatementAnalyzer.java | 13 +++++-----
.../relational/metadata/TableMetadataImpl.java | 14 +++++++++++
.../metadata/fetcher/TableDeviceSchemaFetcher.java | 4 +--
.../fetcher/TableHeaderSchemaValidator.java | 3 ++-
.../schemaengine/table/InformationSchemaUtils.java | 2 +-
.../exception}/table/ColumnNotExistsException.java | 2 +-
.../table/TableAlreadyExistsException.java | 2 +-
.../exception}/table/TableNotExistsException.java | 2 +-
20 files changed, 62 insertions(+), 63 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java
index b69a557b41a..99dfe05db99 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBDeletionTableIT.java
@@ -593,7 +593,7 @@ public class IoTDBDeletionTableIT {
try (ResultSet ignored = statement.executeQuery("SELECT * FROM vehicle"
+ testNum)) {
fail("Exception expected");
} catch (SQLException e) {
- assertEquals("701: Table 'test.vehicle12' does not exist",
e.getMessage());
+ assertEquals("550: Table 'test.vehicle12' does not exist.",
e.getMessage());
}
statement.execute(
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
index 71b1eb4a8c0..e751ab6423f 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java
@@ -464,7 +464,7 @@ public class IoTDBInsertTableIT {
st1.execute("insert into wt14(time, s1, s2) values(100, null, 1), (101,
null, 2)");
fail();
} catch (SQLException e) {
- assertEquals("507: Table wt14 does not exist", e.getMessage());
+ assertEquals("550: Table 'test.wt14' does not exist.", e.getMessage());
}
try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT)) {
try (Statement st2 = connection.createStatement()) {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceWithTemplateTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceWithTemplateTableIT.java
index c221dc40167..bf9e7f89db0 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceWithTemplateTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceWithTemplateTableIT.java
@@ -187,7 +187,7 @@ public class IoTDBAlignByDeviceWithTemplateTableIT {
statement.executeQuery("SELECT s3,s1,s_null FROM table1 order by
device_id")) {
fail("should throw exception to indicate that s_null doesn't exist");
} catch (SQLException e) {
- assertEquals("701: Column 's_null' cannot be resolved",
e.getMessage());
+ assertEquals("616: Column 's_null' cannot be resolved",
e.getMessage());
}
}
} catch (SQLException e) {
@@ -277,7 +277,7 @@ public class IoTDBAlignByDeviceWithTemplateTableIT {
statement.executeQuery("SELECT * FROM table1 WHERE s_null > 1
order by device_id")) {
fail("should throw exception to indicate that s_null doesn't exist");
} catch (SQLException e) {
- assertEquals("701: Column 's_null' cannot be resolved",
e.getMessage());
+ assertEquals("616: Column 's_null' cannot be resolved",
e.getMessage());
}
}
} catch (SQLException e) {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBNoSelectExpressionAfterAnalyzedTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBNoSelectExpressionAfterAnalyzedTableIT.java
index de0dbea13d9..27d14c0e1fc 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBNoSelectExpressionAfterAnalyzedTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBNoSelectExpressionAfterAnalyzedTableIT.java
@@ -64,7 +64,7 @@ public class IoTDBNoSelectExpressionAfterAnalyzedTableIT {
String[] retArray = new String[] {};
tableAssertTestFail(
"select s2 from sg where s1>0 order by device",
- "701: Column 's2' cannot be resolved",
+ "616: Column 's2' cannot be resolved",
DATABASE_NAME);
// TODO After Aggregation supported
@@ -81,14 +81,14 @@ public class IoTDBNoSelectExpressionAfterAnalyzedTableIT {
tableAssertTestFail(
"select s1, s2 from sg where s1>0 order by device",
- "701: Column 's2' cannot be resolved",
+ "616: Column 's2' cannot be resolved",
DATABASE_NAME);
}
@Test
public void testAlignByTime() {
tableAssertTestFail(
- "select s2 from sg where s1>0", "701: Column 's2' cannot be resolved",
DATABASE_NAME);
+ "select s2 from sg where s1>0", "616: Column 's2' cannot be resolved",
DATABASE_NAME);
/*tableResultSetEqualTest("select count(s2) from sg where s1>0",
expectedHeader, retArray,DATABASE_NAME);*/
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBResultSetTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBResultSetTableIT.java
index 31a8cb21aa2..a7ad4a07be9 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBResultSetTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/query/IoTDBResultSetTableIT.java
@@ -144,7 +144,7 @@ public class IoTDBResultSetTableIT {
@Test
public void emptyQueryTest1() {
- tableAssertTestFail("select * from sg1", "701: Table 'test.sg1' does not
exist", DATABASE_NAME);
+ tableAssertTestFail("select * from sg1", "550: Table 'test.sg1' does not
exist", DATABASE_NAME);
}
@Test
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java
index a7c6f5f3dd9..d2479f68f35 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDeviceIT.java
@@ -153,14 +153,14 @@ public class IoTDBDeviceIT {
statement.executeQuery("show devices from table2");
fail("Show devices shall fail for non-exist table");
} catch (final Exception e) {
- assertEquals("701: Table 'test.table2' does not exist.",
e.getMessage());
+ assertEquals("550: Table 'test.table2' does not exist.",
e.getMessage());
}
try {
statement.executeQuery("count devices from table2");
fail("Count devices shall fail for non-exist table");
} catch (final Exception e) {
- assertEquals("701: Table 'test.table2' does not exist.",
e.getMessage());
+ assertEquals("550: Table 'test.table2' does not exist.",
e.getMessage());
}
try {
@@ -176,7 +176,7 @@ public class IoTDBDeviceIT {
statement.executeQuery("count devices from table0 where a = 1");
fail("Count devices shall fail for non-exist column");
} catch (final Exception e) {
- assertEquals("701: Column 'a' cannot be resolved", e.getMessage());
+ assertEquals("616: Column 'a' cannot be resolved", e.getMessage());
}
// Test fully qualified name
@@ -193,7 +193,7 @@ public class IoTDBDeviceIT {
statement.execute("update table2 set model = '1'");
fail("Update shall fail for non-exist table");
} catch (final Exception e) {
- assertEquals("701: Table 'test.table2' does not exist.",
e.getMessage());
+ assertEquals("550: Table 'test.table2' does not exist.",
e.getMessage());
}
try {
@@ -214,7 +214,7 @@ public class IoTDBDeviceIT {
statement.execute("update table0 set col = '1'");
fail("Update shall fail for non-exist column");
} catch (final Exception e) {
- assertEquals("701: Column 'col' cannot be resolved", e.getMessage());
+ assertEquals("616: Column 'col' cannot be resolved", e.getMessage());
}
try {
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 2def42f0dcc..1bfd554dde2 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
@@ -424,14 +424,14 @@ public class IoTDBTableIT {
statement.executeQuery("select color from table2");
fail();
} catch (final SQLException e) {
- assertEquals("701: Column 'color' cannot be resolved",
e.getMessage());
+ assertEquals("616: Column 'color' cannot be resolved",
e.getMessage());
}
try {
statement.executeQuery("select speed from table2");
fail();
} catch (final SQLException e) {
- assertEquals("701: Column 'speed' cannot be resolved",
e.getMessage());
+ assertEquals("616: Column 'speed' cannot be resolved",
e.getMessage());
}
try {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
index b2d45d55466..1f70341892b 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/session/IoTDBSessionRelationalIT.java
@@ -23,8 +23,6 @@ import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
-import org.apache.iotdb.itbase.category.ClusterIT;
-import org.apache.iotdb.itbase.category.LocalStandaloneIT;
import org.apache.iotdb.itbase.category.TableClusterIT;
import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
import org.apache.iotdb.rpc.IoTDBConnectionException;
@@ -222,7 +220,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalSqlTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -334,7 +331,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void partialInsertSQLTest() throws IoTDBConnectionException,
StatementExecutionException {
try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
// disable auto-creation only for this test
@@ -365,7 +361,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void partialInsertRelationalTabletTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ISession session = EnvFactory.getEnv().getSessionConnection()) {
@@ -510,7 +505,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalTabletTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -587,7 +581,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalTabletWithCacheLeaderTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -669,7 +662,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void autoCreateNontagColumnTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -744,7 +736,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void autoCreateTableTest() throws IoTDBConnectionException,
StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
@@ -803,7 +794,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void autoCreateTagColumnTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -882,7 +872,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void autoAdjustTagTest() throws IoTDBConnectionException,
StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
@@ -950,7 +939,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalSqlWithoutDBTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -1008,7 +996,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalSqlAnotherDBTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -1057,7 +1044,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertNonExistTableTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -1070,7 +1056,7 @@ public class IoTDBSessionRelationalIT {
0, "tag:" + 0, "attr:" + 0, 0 * 1.0));
fail("Exception expected");
} catch (StatementExecutionException e) {
- assertEquals("507: Table table13 does not exist", e.getMessage());
+ assertEquals("550: Table 'db1.table13' does not exist.",
e.getMessage());
}
try {
@@ -1080,13 +1066,12 @@ public class IoTDBSessionRelationalIT {
0, "tag:" + 0, "attr:" + 0, 0 * 1.0));
fail("Exception expected");
} catch (StatementExecutionException e) {
- assertEquals("507: Table table13 does not exist", e.getMessage());
+ assertEquals("550: Table 'db2.table13' does not exist.",
e.getMessage());
}
}
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertNonExistDBTest() throws IoTDBConnectionException,
StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE \"db1\"");
@@ -1098,13 +1083,12 @@ public class IoTDBSessionRelationalIT {
0, "tag:" + 0, "attr:" + 0, 0 * 1.0));
fail("Exception expected");
} catch (StatementExecutionException e) {
- assertEquals("507: Table table13 does not exist", e.getMessage());
+ assertEquals("550: Table 'db3.table13' does not exist.",
e.getMessage());
}
}
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertWithoutMeasurementTest()
throws IoTDBConnectionException, StatementExecutionException {
try (ITableSession session =
EnvFactory.getEnv().getTableSessionConnection()) {
@@ -1356,7 +1340,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalTabletWithAutoCastTest()
throws IoTDBConnectionException, StatementExecutionException {
int testNum = 14;
@@ -1380,7 +1363,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void deleteTableAndWriteDifferentTypeTest()
throws IoTDBConnectionException, StatementExecutionException {
int testNum = 15;
@@ -1410,7 +1392,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void dropTableOfTheSameNameTest()
throws IoTDBConnectionException, StatementExecutionException {
int testNum = 16;
@@ -1441,13 +1422,12 @@ public class IoTDBSessionRelationalIT {
session.executeQueryStatement("select * from db2.table" + testNum + "
order by time");
fail("expected exception");
} catch (StatementExecutionException e) {
- assertEquals("701: Table 'db2.table16' does not exist",
e.getMessage());
+ assertEquals("550: Table 'db2.table16' does not exist.",
e.getMessage());
}
}
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void insertRelationalRowWithAutoCastTest()
throws IoTDBConnectionException, StatementExecutionException {
int testNum = 17;
@@ -1471,7 +1451,6 @@ public class IoTDBSessionRelationalIT {
}
@Test
- @Category({LocalStandaloneIT.class, ClusterIT.class})
public void autoCreateTagColumnTest2()
throws IoTDBConnectionException, StatementExecutionException {
int testNum = 18;
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
index 45e6fda8fcd..0b4bf3f840c 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
@@ -23,6 +23,9 @@ import org.apache.iotdb.common.rpc.thrift.TSchemaNode;
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.exception.IoTDBException;
import org.apache.iotdb.commons.exception.MetadataException;
+import org.apache.iotdb.commons.exception.table.ColumnNotExistsException;
+import org.apache.iotdb.commons.exception.table.TableAlreadyExistsException;
+import org.apache.iotdb.commons.exception.table.TableNotExistsException;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.path.PathPatternTree;
import org.apache.iotdb.commons.schema.node.role.IDatabaseMNode;
@@ -42,9 +45,6 @@ import
org.apache.iotdb.db.exception.metadata.DatabaseConflictException;
import org.apache.iotdb.db.exception.metadata.DatabaseNotSetException;
import org.apache.iotdb.db.exception.metadata.PathAlreadyExistException;
import org.apache.iotdb.db.exception.metadata.PathNotExistException;
-import org.apache.iotdb.db.exception.metadata.table.ColumnNotExistsException;
-import
org.apache.iotdb.db.exception.metadata.table.TableAlreadyExistsException;
-import org.apache.iotdb.db.exception.metadata.table.TableNotExistsException;
import org.apache.iotdb.db.exception.sql.SemanticException;
import
org.apache.iotdb.db.schemaengine.schemaregion.mtree.traverser.collector.DatabaseCollector;
import
org.apache.iotdb.db.schemaengine.schemaregion.mtree.traverser.collector.MNodeAboveDBCollector;
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/schema/source/TableDeviceQuerySource.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/schema/source/TableDeviceQuerySource.java
index dfa0cf4baf1..fd18ff5ed83 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/schema/source/TableDeviceQuerySource.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/schema/source/TableDeviceQuerySource.java
@@ -27,6 +27,7 @@ import
org.apache.iotdb.commons.schema.filter.impl.DeviceFilterUtil;
import org.apache.iotdb.commons.schema.table.TsTable;
import org.apache.iotdb.commons.schema.table.column.TsTableColumnCategory;
import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema;
+import
org.apache.iotdb.db.queryengine.plan.relational.metadata.TableMetadataImpl;
import org.apache.iotdb.db.schemaengine.schemaregion.ISchemaRegion;
import
org.apache.iotdb.db.schemaengine.schemaregion.read.resp.info.IDeviceSchemaInfo;
import
org.apache.iotdb.db.schemaengine.schemaregion.read.resp.reader.ISchemaReader;
@@ -189,8 +190,7 @@ public class TableDeviceQuerySource implements
ISchemaSource<IDeviceSchemaInfo>
final String tableName,
final List<List<SchemaFilter>> idDeterminedPredicateList) {
if (Objects.isNull(DataNodeTableCache.getInstance().getTable(database,
tableName))) {
- throw new SchemaExecutionException(
- String.format("Table '%s.%s' does not exist.", database, tableName));
+ TableMetadataImpl.throwTableNotExistsException(database, tableName);
}
return DeviceFilterUtil.convertToDevicePattern(
database,
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java
index e551638b69c..1798a0ed0b7 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java
@@ -33,6 +33,7 @@ import
org.apache.iotdb.db.queryengine.plan.relational.metadata.Metadata;
import
org.apache.iotdb.db.queryengine.plan.relational.metadata.OperatorNotFoundException;
import
org.apache.iotdb.db.queryengine.plan.relational.metadata.QualifiedObjectName;
import
org.apache.iotdb.db.queryengine.plan.relational.metadata.ResolvedFunction;
+import
org.apache.iotdb.db.queryengine.plan.relational.metadata.TableMetadataImpl;
import org.apache.iotdb.db.queryengine.plan.relational.planner.Symbol;
import org.apache.iotdb.db.queryengine.plan.relational.security.AccessControl;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ArithmeticBinaryExpression;
@@ -419,8 +420,7 @@ public class ExpressionAnalyzer {
return handleResolvedField(node, resolvedField.get(), context);
}
if (!scope.isColumnReference(qualifiedName)) {
- throw new SemanticException(
- String.format("Column '%s' cannot be resolved", qualifiedName));
+ TableMetadataImpl.throwColumnNotExistsException(qualifiedName);
}
}
@@ -450,7 +450,7 @@ public class ExpressionAnalyzer {
}
if (rowFieldType == null) {
- throw new SemanticException(String.format("Column '%s' cannot be
resolved", qualifiedName));
+ TableMetadataImpl.throwColumnNotExistsException(qualifiedName);
}
return setExpressionType(node, rowFieldType);
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/Scope.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/Scope.java
index dfcc21e4e9c..0e7588a59f4 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/Scope.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/Scope.java
@@ -19,11 +19,13 @@
package org.apache.iotdb.db.queryengine.plan.relational.analyzer;
+import org.apache.iotdb.commons.exception.IoTDBException;
import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.AllColumns;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.QualifiedName;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.WithQuery;
+import org.apache.iotdb.rpc.TSStatusCode;
import com.google.common.collect.ImmutableMap;
@@ -228,7 +230,11 @@ public class Scope {
public ResolvedField resolveField(Expression expression, QualifiedName name)
{
return tryResolveField(expression, name)
.orElseThrow(
- () -> new SemanticException(String.format("Column '%s' cannot be
resolved", name)));
+ () ->
+ new SemanticException(
+ new IoTDBException(
+ String.format("Column '%s' cannot be resolved", name),
+ TSStatusCode.COLUMN_NOT_EXISTS.getStatusCode())));
}
public Optional<ResolvedField> tryResolveField(Expression expression) {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
index fc7e3330397..93ec5bef3a5 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
@@ -36,6 +36,7 @@ import
org.apache.iotdb.db.queryengine.plan.analyze.schema.SchemaValidator;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.ColumnSchema;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.Metadata;
import
org.apache.iotdb.db.queryengine.plan.relational.metadata.QualifiedObjectName;
+import
org.apache.iotdb.db.queryengine.plan.relational.metadata.TableMetadataImpl;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.TableSchema;
import org.apache.iotdb.db.queryengine.plan.relational.planner.PlannerContext;
import org.apache.iotdb.db.queryengine.plan.relational.planner.ScopeAware;
@@ -462,9 +463,7 @@ public class StatementAnalyzer {
final TsTable table =
DataNodeTableCache.getInstance().getTable(node.getDatabase(),
node.getTableName());
if (Objects.isNull(table)) {
- throw new SemanticException(
- String.format(
- "Table '%s.%s' does not exist.", node.getDatabase(),
node.getTableName()));
+ TableMetadataImpl.throwTableNotExistsException(node.getDatabase(),
node.getTableName());
}
node.parseModEntries(table);
analyzeTraverseDevice(node, context, node.getWhere().isPresent());
@@ -1765,7 +1764,8 @@ public class StatementAnalyzer {
Optional<TableSchema> tableSchema =
metadata.getTableSchema(sessionContext, name);
// This can only be a table
if (!tableSchema.isPresent()) {
- throw new SemanticException(String.format("Table '%s' does not exist",
name));
+ TableMetadataImpl.throwTableNotExistsException(
+ name.getDatabaseName(), name.getObjectName());
}
analysis.addEmptyColumnReferencesForTable(accessControl,
sessionContext.getIdentity(), name);
@@ -2961,8 +2961,7 @@ public class StatementAnalyzer {
}
if (!metadata.tableExists(new QualifiedObjectName(database, tableName)))
{
- throw new SemanticException(
- String.format("Table '%s.%s' does not exist.", database,
tableName));
+ TableMetadataImpl.throwTableNotExistsException(database, tableName);
}
node.setColumnHeaderList();
@@ -2972,7 +2971,7 @@ public class StatementAnalyzer {
final Optional<TableSchema> tableSchema =
metadata.getTableSchema(sessionContext, name);
// This can only be a table
if (!tableSchema.isPresent()) {
- throw new SemanticException(String.format("Table '%s' does not
exist", name));
+ TableMetadataImpl.throwTableNotExistsException(database, tableName);
}
final TableSchema originalSchema = tableSchema.get();
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableMetadataImpl.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableMetadataImpl.java
index ab2ba5b9f33..fb437d3d596 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableMetadataImpl.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableMetadataImpl.java
@@ -19,6 +19,8 @@
package org.apache.iotdb.db.queryengine.plan.relational.metadata;
+import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.table.TableNotExistsException;
import org.apache.iotdb.commons.partition.DataPartition;
import org.apache.iotdb.commons.partition.DataPartitionQueryParam;
import org.apache.iotdb.commons.partition.SchemaPartition;
@@ -50,6 +52,7 @@ import
org.apache.iotdb.db.queryengine.plan.relational.type.TypeNotFoundExceptio
import org.apache.iotdb.db.queryengine.plan.relational.type.TypeSignature;
import org.apache.iotdb.db.schemaengine.table.DataNodeTableCache;
import org.apache.iotdb.db.utils.constant.SqlConstant;
+import org.apache.iotdb.rpc.TSStatusCode;
import org.apache.iotdb.udf.api.customizer.analysis.AggregateFunctionAnalysis;
import org.apache.iotdb.udf.api.customizer.analysis.ScalarFunctionAnalysis;
import org.apache.iotdb.udf.api.customizer.parameter.FunctionArguments;
@@ -900,4 +903,15 @@ public class TableMetadataImpl implements Metadata {
}
return isArithmeticType(left) && isArithmeticType(right);
}
+
+ public static void throwTableNotExistsException(final String database, final
String tableName) {
+ throw new SemanticException(new TableNotExistsException(database,
tableName));
+ }
+
+ public static void throwColumnNotExistsException(final Object columnName) {
+ throw new SemanticException(
+ new IoTDBException(
+ String.format("Column '%s' cannot be resolved.", columnName),
+ TSStatusCode.COLUMN_NOT_EXISTS.getStatusCode()));
+ }
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
index ae5362cd08f..b26563c521b 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java
@@ -27,7 +27,6 @@ import
org.apache.iotdb.commons.schema.filter.impl.values.PreciseFilter;
import org.apache.iotdb.commons.schema.table.TsTable;
import org.apache.iotdb.commons.schema.table.column.TsTableColumnCategory;
import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema;
-import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.protocol.session.SessionManager;
import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
import org.apache.iotdb.db.queryengine.plan.Coordinator;
@@ -36,6 +35,7 @@ import
org.apache.iotdb.db.queryengine.plan.planner.LocalExecutionPlanner;
import
org.apache.iotdb.db.queryengine.plan.relational.analyzer.predicate.schema.ConvertSchemaPredicateToFilterVisitor;
import
org.apache.iotdb.db.queryengine.plan.relational.metadata.AlignedDeviceEntry;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
+import
org.apache.iotdb.db.queryengine.plan.relational.metadata.TableMetadataImpl;
import
org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.cache.TableDeviceSchemaCache;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.AbstractTraverseDevice;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
@@ -172,7 +172,7 @@ public class TableDeviceSchemaFetcher {
final ShowDevice statement = new ShowDevice(database, table);
final TsTable tableInstance =
DataNodeTableCache.getInstance().getTable(database, table);
if (tableInstance == null) {
- throw new SemanticException(String.format("Table '%s.%s' does not
exist", database, table));
+ TableMetadataImpl.throwTableNotExistsException(database, table);
}
if (parseFilter4TraverseDevice(
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableHeaderSchemaValidator.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableHeaderSchemaValidator.java
index 3e0e00541f3..41932c8944d 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableHeaderSchemaValidator.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableHeaderSchemaValidator.java
@@ -38,6 +38,7 @@ import
org.apache.iotdb.db.queryengine.plan.execution.config.executor.ClusterCon
import
org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.AlterTableAddColumnTask;
import
org.apache.iotdb.db.queryengine.plan.execution.config.metadata.relational.CreateTableTask;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.ColumnSchema;
+import
org.apache.iotdb.db.queryengine.plan.relational.metadata.TableMetadataImpl;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.TableSchema;
import
org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager;
import org.apache.iotdb.db.schemaengine.table.DataNodeTableCache;
@@ -123,7 +124,7 @@ public class TableHeaderSchemaValidator {
"auto create table succeed, but cannot get table schema in
current node's DataNodeTableCache, may be caused by concurrently auto creating
table");
}
} else {
- throw new SemanticException("Table " + tableSchema.getTableName() + "
does not exist");
+ TableMetadataImpl.throwTableNotExistsException(database,
tableSchema.getTableName());
}
} else {
// If table with this name already exists and isStrictIdColumn is true,
make sure the existing
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/table/InformationSchemaUtils.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/table/InformationSchemaUtils.java
index 2b3875114bd..54f5769aead 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/table/InformationSchemaUtils.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/table/InformationSchemaUtils.java
@@ -21,11 +21,11 @@ package org.apache.iotdb.db.schemaengine.table;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.IoTDBException;
+import org.apache.iotdb.commons.exception.table.TableNotExistsException;
import org.apache.iotdb.commons.schema.column.ColumnHeader;
import org.apache.iotdb.commons.schema.column.ColumnHeaderConstant;
import org.apache.iotdb.commons.schema.table.TsTable;
import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema;
-import org.apache.iotdb.db.exception.metadata.table.TableNotExistsException;
import org.apache.iotdb.db.exception.sql.SemanticException;
import org.apache.iotdb.db.protocol.session.IClientSession;
import org.apache.iotdb.db.queryengine.common.header.DatasetHeaderFactory;
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/ColumnNotExistsException.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/ColumnNotExistsException.java
similarity index 95%
rename from
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/ColumnNotExistsException.java
rename to
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/ColumnNotExistsException.java
index 9fcda36998e..0a9fa784e9f 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/ColumnNotExistsException.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/ColumnNotExistsException.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.exception.metadata.table;
+package org.apache.iotdb.commons.exception.table;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.rpc.TSStatusCode;
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/TableAlreadyExistsException.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/TableAlreadyExistsException.java
similarity index 95%
rename from
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/TableAlreadyExistsException.java
rename to
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/TableAlreadyExistsException.java
index d28c04e9e7e..d0baa216b84 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/TableAlreadyExistsException.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/TableAlreadyExistsException.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.exception.metadata.table;
+package org.apache.iotdb.commons.exception.table;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.rpc.TSStatusCode;
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/TableNotExistsException.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/TableNotExistsException.java
similarity index 95%
rename from
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/TableNotExistsException.java
rename to
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/TableNotExistsException.java
index 616a20d49bc..c0caabe711a 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/metadata/table/TableNotExistsException.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/exception/table/TableNotExistsException.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.iotdb.db.exception.metadata.table;
+package org.apache.iotdb.commons.exception.table;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.rpc.TSStatusCode;