JackieTien97 commented on code in PR #12707:
URL: https://github.com/apache/iotdb/pull/12707#discussion_r1634514022


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/Metadata.java:
##########
@@ -67,4 +68,29 @@ List<DeviceEntry> indexScan(
       QualifiedObjectName tableName,
       List<Expression> expressionList,
       List<String> attributeColumns);
+
+  /**
+   * This method is used for table column validation and should be invoked 
before device validation.
+   *
+   * <p>This method return all the existing column schemas in the target table.
+   *
+   * <p>When table or column is missing, this method will execute auto 
creation.
+   *
+   * <p>When using SQL, the columnSchemaList could be null and there won't be 
any validation.
+   *
+   * <p>When the input dataType or category of one column is null, the column 
cannot be auto
+   * created.
+   */
+  TableSchema validateTableHeaderSchema(
+      String database, TableSchema tableSchema, MPPQueryContext context);
+
+  /**
+   * This method is used for table device validation and should be invoked 
after column validation.
+   *
+   * <p>When device id is missing, this method will execute auto creation.
+   *
+   * <p>When device attribute is missing or different from that stored in 
IoTDB, the attribute will
+   * be auto upsert.
+   */
+  void validateDeviceSchema(ITableDeviceSchemaValidation schemaValidation, 
MPPQueryContext context);

Review Comment:
   think about partial insert, how to return info to caller about:
   1. auto create failed(because auto_create is false or other reasons like 
exceed device limit)
   2. auto create succeed or this device already exists before.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/Metadata.java:
##########
@@ -67,4 +68,29 @@ List<DeviceEntry> indexScan(
       QualifiedObjectName tableName,
       List<Expression> expressionList,
       List<String> attributeColumns);
+
+  /**
+   * This method is used for table column validation and should be invoked 
before device validation.
+   *
+   * <p>This method return all the existing column schemas in the target table.
+   *
+   * <p>When table or column is missing, this method will execute auto 
creation.
+   *
+   * <p>When using SQL, the columnSchemaList could be null and there won't be 
any validation.
+   *
+   * <p>When the input dataType or category of one column is null, the column 
cannot be auto
+   * created.
+   */
+  TableSchema validateTableHeaderSchema(

Review Comment:
   what if schema validation failed? dataType miss match? throw what kind of 
exception?



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/Metadata.java:
##########
@@ -67,4 +68,29 @@ List<DeviceEntry> indexScan(
       QualifiedObjectName tableName,
       List<Expression> expressionList,
       List<String> attributeColumns);
+
+  /**
+   * This method is used for table column validation and should be invoked 
before device validation.
+   *
+   * <p>This method return all the existing column schemas in the target table.
+   *
+   * <p>When table or column is missing, this method will execute auto 
creation.
+   *
+   * <p>When using SQL, the columnSchemaList could be null and there won't be 
any validation.
+   *
+   * <p>When the input dataType or category of one column is null, the column 
cannot be auto
+   * created.
+   */
+  TableSchema validateTableHeaderSchema(

Review Comment:
   What if auto create is false? So I think should return 
Optional<TableSchema>, if we cannot auto craete this table we just return 
Optinal.empty()



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to