MarcosZyk commented on code in PR #9826:
URL: https://github.com/apache/iotdb/pull/9826#discussion_r1190715955


##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertRowNode.java:
##########
@@ -836,14 +836,21 @@ public void updateAfterSchemaValidation() throws 
QueryProcessException {
   }
 
   @Override
-  public void validateMeasurementSchema(int index, IMeasurementSchemaInfo 
measurementSchemaInfo) {
+  public void validateMeasurementSchema(int index, IMeasurementSchemaInfo 
iMeasurementSchemaInfo) {
     if (measurementSchemas == null) {
       measurementSchemas = new MeasurementSchema[measurements.length];
     }
-    if (measurementSchemaInfo == null) {
+    if (iMeasurementSchemaInfo == null) {
       measurementSchemas[index] = null;
     } else {
-      measurementSchemas[index] = measurementSchemaInfo.getSchema();
+      if (iMeasurementSchemaInfo.isLogicalView()) {
+        throw new RuntimeException(
+            new UnsupportedOperationException(
+                "This iMeasurementSchemaInfo is logical view schema info,"
+                    + " can not convert it into MeasurementSchema. 
InsertRowNode should use a measurementSchemaInfo."));
+      } else {
+        measurementSchemas[index] = (MeasurementSchema) 
iMeasurementSchemaInfo.getSchema();
+      }
     }

Review Comment:
   The insertNode will only rely on MeasurementSchema. If we meet a 
LogicalViewSchema in schema fetcher, we do fetch again to take the 
MeasurementSchema of raw timeseries, and then use the re-fetched 
MeasurementSchema to validate data insertion. Thus there's no need to modify 
this. Rollback this modification.



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java:
##########
@@ -1151,14 +1151,21 @@ public ISchemaValidation getSchemaValidation() {
   }
 
   @Override
-  public void validateMeasurementSchema(int index, IMeasurementSchemaInfo 
measurementSchemaInfo) {
+  public void validateMeasurementSchema(int index, IMeasurementSchemaInfo 
iMeasurementSchemaInfo) {
     if (measurementSchemas == null) {
       measurementSchemas = new MeasurementSchema[measurements.length];
     }
-    if (measurementSchemaInfo == null) {
+    if (iMeasurementSchemaInfo == null) {
       measurementSchemas[index] = null;
     } else {
-      measurementSchemas[index] = measurementSchemaInfo.getSchema();
+      if (iMeasurementSchemaInfo.isLogicalView()) {
+        throw new RuntimeException(
+            new UnsupportedOperationException(
+                "This iMeasurementSchemaInfo is logical view schema info,"
+                    + " can not convert it into MeasurementSchema. 
InsertTabletNode should use a measurementSchemaInfo."));
+      } else {
+        measurementSchemas[index] = (MeasurementSchema) 
iMeasurementSchemaInfo.getSchema();
+      }
     }

Review Comment:
   Same as above.



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -2412,11 +2417,11 @@ private void verifySchema(
             device2IsAligned.get(device).right.getPath(),
             String.valueOf(schemaInfo.isAligned()));
       }
-      List<MeasurementSchema> originSchemaList = 
schemaInfo.getMeasurementSchemaList();
+      List<IMeasurementSchema> originSchemaList = 
schemaInfo.getMeasurementSchemaList();
       int measurementSize = originSchemaList.size();
       for (int j = 0; j < measurementSize; j++) {
-        MeasurementSchema originSchema = originSchemaList.get(j);
-        MeasurementSchema tsFileSchema = tsFileSchemas[j];
+        IMeasurementSchema originSchema = originSchemaList.get(j);
+        IMeasurementSchema tsFileSchema = tsFileSchemas[j];

Review Comment:
   This logical only relies on MeasurementSchema. Rollback this modification.



##########
node-commons/src/main/java/org/apache/iotdb/commons/path/MeasurementPath.java:
##########
@@ -249,10 +246,14 @@ public static MeasurementPath deserialize(ByteBuffer 
byteBuffer) {
     byte isNull = ReadWriteIOUtils.readByte(byteBuffer);
     if (isNull == 1) {
       byte type = ReadWriteIOUtils.readByte(byteBuffer);
-      if (type == 0) {
+      if (type == 
MeasurementSchemaType.MEASUREMENT_SCHEMA.getMeasurementSchemaTypeInByteEnum()) {
         measurementPath.measurementSchema = 
MeasurementSchema.deserializeFrom(byteBuffer);
-      } else if (type == 1) {
+      } else if (type
+          == 
MeasurementSchemaType.VECTOR_MEASUREMENT_SCHEMA.getMeasurementSchemaTypeInByteEnum())
 {
         measurementPath.measurementSchema = 
VectorMeasurementSchema.deserializeFrom(byteBuffer);
+      } else {
+        throw new RuntimeException(
+            new UnexpectedException("Type (" + type + ") of measurementSchema 
is unknown."));
       }

Review Comment:
   Seems miss deserialization of LogicalViewSchema.



##########
server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/AnalyzeVisitor.java:
##########
@@ -2396,13 +2401,13 @@ private void verifySchema(
       throws VerifyMetadataException, IllegalPathException {
     for (Map.Entry<String, Map<MeasurementSchema, File>> entry : 
device2Schemas.entrySet()) {
       String device = entry.getKey();
-      MeasurementSchema[] tsFileSchemas =
+      IMeasurementSchema[] tsFileSchemas =
           entry.getValue().keySet().toArray(new MeasurementSchema[0]);
       DeviceSchemaInfo schemaInfo =
           schemaTree.searchDeviceSchemaInfo(
               new PartialPath(device),
               Arrays.stream(tsFileSchemas)
-                  .map(MeasurementSchema::getMeasurementId)
+                  .map(IMeasurementSchema::getMeasurementId)

Review Comment:
   This logical only relies on MeasurementSchema. Rollback this modification.



##########
node-commons/src/main/java/org/apache/iotdb/commons/path/MeasurementPath.java:
##########
@@ -249,10 +246,14 @@ public static MeasurementPath deserialize(ByteBuffer 
byteBuffer) {
     byte isNull = ReadWriteIOUtils.readByte(byteBuffer);
     if (isNull == 1) {
       byte type = ReadWriteIOUtils.readByte(byteBuffer);
-      if (type == 0) {
+      if (type == 
MeasurementSchemaType.MEASUREMENT_SCHEMA.getMeasurementSchemaTypeInByteEnum()) {
         measurementPath.measurementSchema = 
MeasurementSchema.deserializeFrom(byteBuffer);
-      } else if (type == 1) {
+      } else if (type
+          == 
MeasurementSchemaType.VECTOR_MEASUREMENT_SCHEMA.getMeasurementSchemaTypeInByteEnum())
 {
         measurementPath.measurementSchema = 
VectorMeasurementSchema.deserializeFrom(byteBuffer);
+      } else {
+        throw new RuntimeException(
+            new UnexpectedException("Type (" + type + ") of measurementSchema 
is unknown."));
       }

Review Comment:
   Move LogicalViewSchema to node-commons package if necessary.



-- 
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