attributeColumns);
+
+ /**
+ * This method is used for table column validation and should be invoked before device validation.
+ *
+ * This method return all the existing column schemas in the target table.
+ *
+ *
When table or column is missing, this method will execute auto creation.
+ *
+ *
When using SQL, the columnSchemaList could be null and there won't be any validation.
+ *
+ *
When the input dataType or category of one column is null, the column cannot be auto
+ * created.
+ *
+ *
If validation failed, a SemanticException will be thrown.
+ */
+ TableSchema validateTableHeaderSchema(
+ String database, TableSchema tableSchema, MPPQueryContext context);
+
+ /**
+ * This method is used for table device validation and should be invoked after column validation.
+ *
+ *
When device id is missing, this method will execute auto creation.
+ *
+ *
When device attribute is missing or different from that stored in IoTDB, the attribute will
+ * be auto upsert.
+ *
+ *
If validation failed, a SemanticException will be thrown.
+ */
+ void validateDeviceSchema(ITableDeviceSchemaValidation schemaValidation, MPPQueryContext context);
}
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 1c897c9646ef1..67f030ede35f6 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
@@ -22,6 +22,7 @@
import org.apache.iotdb.commons.udf.builtin.BuiltinAggregationFunction;
import org.apache.iotdb.commons.udf.builtin.BuiltinScalarFunction;
import org.apache.iotdb.db.exception.sql.SemanticException;
+import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
import org.apache.iotdb.db.queryengine.common.SessionInfo;
import org.apache.iotdb.db.queryengine.plan.relational.function.OperatorType;
import org.apache.iotdb.db.queryengine.plan.relational.security.AccessControl;
@@ -275,6 +276,18 @@ public List indexScan(
return result;
}
+ @Override
+ public TableSchema validateTableHeaderSchema(
+ String database, TableSchema tableSchema, MPPQueryContext context) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void validateDeviceSchema(
+ ITableDeviceSchemaValidation schemaValidation, MPPQueryContext context) {
+ throw new UnsupportedOperationException();
+ }
+
public static boolean isTwoNumericType(List extends Type> argumentTypes) {
return argumentTypes.size() == 2
&& isNumericType(argumentTypes.get(0))
diff --git a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/TestMatadata.java b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/TestMatadata.java
index c8eec5486c045..585898e2b089e 100644
--- a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/TestMatadata.java
+++ b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/TestMatadata.java
@@ -16,11 +16,13 @@
import org.apache.iotdb.commons.schema.table.column.TsTableColumnCategory;
import org.apache.iotdb.commons.udf.builtin.BuiltinAggregationFunction;
+import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
import org.apache.iotdb.db.queryengine.common.SessionInfo;
import org.apache.iotdb.db.queryengine.plan.relational.function.OperatorType;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.ColumnMetadata;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.ColumnSchema;
import org.apache.iotdb.db.queryengine.plan.relational.metadata.DeviceEntry;
+import org.apache.iotdb.db.queryengine.plan.relational.metadata.ITableDeviceSchemaValidation;
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;
@@ -184,6 +186,18 @@ public List indexScan(
Arrays.asList("a1", "a2")));
}
+ @Override
+ public TableSchema validateTableHeaderSchema(
+ String database, TableSchema tableSchema, MPPQueryContext context) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void validateDeviceSchema(
+ ITableDeviceSchemaValidation schemaValidation, MPPQueryContext context) {
+ throw new UnsupportedOperationException();
+ }
+
public static boolean isTwoNumericType(List extends Type> argumentTypes) {
return argumentTypes.size() == 2
&& isNumericType(argumentTypes.get(0))