This is an automated email from the ASF dual-hosted git repository.

jiangtian pushed a commit to branch TableModelIngestion
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/TableModelIngestion by this 
push:
     new baaa3dfc6d2 fix rewriter
baaa3dfc6d2 is described below

commit baaa3dfc6d2399272ae00f817c518a2bc67ec539
Author: DESKTOP-L0L5GPJ\jt <[email protected]>
AuthorDate: Fri Jun 28 12:23:26 2024 +0800

    fix rewriter
---
 .../db/queryengine/plan/analyze/AnalyzeUtils.java  |  12 +-
 .../distribution/WriteFragmentParallelPlanner.java |   3 +-
 .../plan/planner/plan/node/write/InsertNode.java   |   2 +-
 .../planner/plan/node/write/InsertTabletNode.java  |  68 +++-----
 .../node/write/RelationalInsertTabletNode.java     |   4 -
 .../plan/relational/metadata/TableSchema.java      |   5 +-
 .../optimizations/PushPredicateIntoTableScan.java  |  13 ++
 .../plan/relational/analyzer/AnalyzerTest.java     | 172 ++++++++++-----------
 .../plan/statement/StatementTestUtils.java         |  21 ++-
 9 files changed, 141 insertions(+), 159 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeUtils.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeUtils.java
index 3656dd68e89..00852f1d728 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeUtils.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeUtils.java
@@ -93,7 +93,8 @@ public class AnalyzeUtils {
             .computeIfAbsent(insertTabletStatement.getTableDeviceID(i), id -> 
new HashSet<>())
             .add(insertTabletStatement.getTimePartitionSlot(i));
       }
-      return computeDataPartitionParams(timePartitionSlotMap, 
context.getSession().getDatabaseName().get());
+      return computeDataPartitionParams(
+          timePartitionSlotMap, context.getSession().getDatabaseName().get());
     } else if (statement instanceof InsertMultiTabletsStatement) {
       InsertMultiTabletsStatement insertMultiTabletsStatement =
           (InsertMultiTabletsStatement) statement;
@@ -106,7 +107,8 @@ public class AnalyzeUtils {
               .add(insertTabletStatement.getTimePartitionSlot(i));
         }
       }
-      return computeDataPartitionParams(timePartitionSlotMap, 
context.getSession().getDatabaseName().get());
+      return computeDataPartitionParams(
+          timePartitionSlotMap, context.getSession().getDatabaseName().get());
     }
     throw new UnsupportedOperationException("computeDataPartitionParams for " 
+ statement);
   }
@@ -134,7 +136,8 @@ public class AnalyzeUtils {
                 k -> new HashSet<>());
         
timePartitionSlotSet.addAll(insertTabletStatement.getTimePartitionSlots());
       }
-      return computeDataPartitionParams(dataPartitionQueryParamMap, 
context.getSession().getDatabaseName().get());
+      return computeDataPartitionParams(
+          dataPartitionQueryParamMap, 
context.getSession().getDatabaseName().get());
     } else if (statement instanceof InsertRowsStatement) {
       final InsertRowsStatement insertRowsStatement = (InsertRowsStatement) 
statement;
       Map<IDeviceID, Set<TTimePartitionSlot>> dataPartitionQueryParamMap = new 
HashMap<>();
@@ -146,7 +149,8 @@ public class AnalyzeUtils {
                 k -> new HashSet<>());
         timePartitionSlotSet.add(insertRowStatement.getTimePartitionSlot());
       }
-      return computeDataPartitionParams(dataPartitionQueryParamMap, 
context.getSession().getDatabaseName().get());
+      return computeDataPartitionParams(
+          dataPartitionQueryParamMap, 
context.getSession().getDatabaseName().get());
     }
     throw new UnsupportedOperationException("computeDataPartitionParams for " 
+ statement);
   }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/WriteFragmentParallelPlanner.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/WriteFragmentParallelPlanner.java
index 3f44175f404..d43b18c3241 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/WriteFragmentParallelPlanner.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/distribution/WriteFragmentParallelPlanner.java
@@ -64,7 +64,8 @@ public class WriteFragmentParallelPlanner implements 
IFragmentParallelPlaner {
     PlanFragment fragment = subPlan.getPlanFragment();
     PlanNode node = fragment.getPlanNodeTree();
     if (!(node instanceof WritePlanNode)) {
-      throw new IllegalArgumentException("PlanNode should be IWritePlanNode in 
WRITE operation:" + node.getClass());
+      throw new IllegalArgumentException(
+          "PlanNode should be IWritePlanNode in WRITE operation:" + 
node.getClass());
     }
     List<WritePlanNode> splits = nodeSplitter.apply(((WritePlanNode) node), 
analysis);
     List<FragmentInstance> ret = new ArrayList<>();
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertNode.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertNode.java
index a48340c52fe..5cc0d9b1f7d 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertNode.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertNode.java
@@ -19,7 +19,6 @@
 
 package org.apache.iotdb.db.queryengine.plan.planner.plan.node.write;
 
-import java.util.Collections;
 import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
 import org.apache.iotdb.commons.consensus.index.ComparableConsensusRequest;
 import org.apache.iotdb.commons.consensus.index.ProgressIndex;
@@ -45,6 +44,7 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertTabletNode.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertTabletNode.java
index 46289ce6d0d..d73c07e9dcd 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertTabletNode.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/InsertTabletNode.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.schema.table.column.TsTableColumnCategory;
 import org.apache.iotdb.commons.utils.CommonDateTimeUtils;
 import org.apache.iotdb.commons.utils.TestOnly;
 import org.apache.iotdb.commons.utils.TimePartitionUtils;
@@ -177,8 +176,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
   }
 
   @Override
-  public void addChild(PlanNode child) {
-  }
+  public void addChild(PlanNode child) {}
 
   @Override
   public PlanNodeType getType() {
@@ -260,8 +258,8 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
       final List<TRegionReplicaSet> replicaSets =
           analysis
               .getDataPartitionInfo()
-              .getDataRegionReplicaSetForWriting(deviceID, 
splitInfo.timePartitionSlots,
-                  analysis.getDatabaseName());
+              .getDataRegionReplicaSetForWriting(
+                  deviceID, splitInfo.timePartitionSlots, 
analysis.getDatabaseName());
       splitInfo.replicaSets = replicaSets;
       // collect redirectInfo
       analysis.addEndPointToRedirectNodeList(
@@ -459,9 +457,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     ReadWriteIOUtils.write((byte) (isAligned ? 1 : 0), stream);
   }
 
-  /**
-   * Serialize measurements or measurement schemas, ignoring failed time series
-   */
+  /** Serialize measurements or measurement schemas, ignoring failed time 
series */
   private void writeMeasurementsOrSchemas(ByteBuffer buffer) {
     ReadWriteIOUtils.write(measurements.length - getFailedMeasurementNumber(), 
buffer);
     ReadWriteIOUtils.write((byte) (measurementSchemas != null ? 1 : 0), 
buffer);
@@ -480,9 +476,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize measurements or measurement schemas, ignoring failed time series
-   */
+  /** Serialize measurements or measurement schemas, ignoring failed time 
series */
   private void writeMeasurementsOrSchemas(DataOutputStream stream) throws 
IOException {
     ReadWriteIOUtils.write(measurements.length - getFailedMeasurementNumber(), 
stream);
     ReadWriteIOUtils.write((byte) (measurementSchemas != null ? 1 : 0), 
stream);
@@ -501,9 +495,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize data types, ignoring failed time series
-   */
+  /** Serialize data types, ignoring failed time series */
   private void writeDataTypes(ByteBuffer buffer) {
     for (int i = 0; i < dataTypes.length; i++) {
       // ignore failed partial insert
@@ -514,9 +506,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize data types, ignoring failed time series
-   */
+  /** Serialize data types, ignoring failed time series */
   private void writeDataTypes(DataOutputStream stream) throws IOException {
     for (int i = 0; i < dataTypes.length; i++) {
       // ignore failed partial insert
@@ -541,9 +531,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize bitmaps, ignoring failed time series
-   */
+  /** Serialize bitmaps, ignoring failed time series */
   private void writeBitMaps(ByteBuffer buffer) {
     ReadWriteIOUtils.write(BytesUtils.boolToByte(bitMaps != null), buffer);
     if (bitMaps != null) {
@@ -563,9 +551,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize bitmaps, ignoring failed time series
-   */
+  /** Serialize bitmaps, ignoring failed time series */
   private void writeBitMaps(DataOutputStream stream) throws IOException {
     ReadWriteIOUtils.write(BytesUtils.boolToByte(bitMaps != null), stream);
     if (bitMaps != null) {
@@ -585,9 +571,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize values, ignoring failed time series
-   */
+  /** Serialize values, ignoring failed time series */
   private void writeValues(ByteBuffer buffer) {
     for (int i = 0; i < columns.length; i++) {
       // ignore failed partial insert
@@ -598,9 +582,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize values, ignoring failed time series
-   */
+  /** Serialize values, ignoring failed time series */
   private void writeValues(DataOutputStream stream) throws IOException {
     for (int i = 0; i < columns.length; i++) {
       // ignore failed partial insert
@@ -759,17 +741,13 @@ public class InsertTabletNode extends InsertNode 
implements WALEntryValue {
 
   // region serialize & deserialize methods for WAL
 
-  /**
-   * Serialized size for wal
-   */
+  /** Serialized size for wal */
   @Override
   public int serializedSize() {
     return serializedSize(0, rowCount);
   }
 
-  /**
-   * Serialized size for wal
-   */
+  /** Serialized size for wal */
   public int serializedSize(int start, int end) {
     return Short.BYTES + subSerializeSize(start, end);
   }
@@ -872,9 +850,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     buffer.put((byte) (isAligned ? 1 : 0));
   }
 
-  /**
-   * Serialize measurement schemas, ignoring failed time series
-   */
+  /** Serialize measurement schemas, ignoring failed time series */
   private void writeMeasurementSchemas(IWALByteBufferView buffer) {
     buffer.putInt(measurements.length - getFailedMeasurementNumber());
     serializeMeasurementSchemasToWAL(buffer);
@@ -887,9 +863,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize bitmaps, ignoring failed time series
-   */
+  /** Serialize bitmaps, ignoring failed time series */
   private void writeBitMaps(IWALByteBufferView buffer, int start, int end) {
     buffer.put(BytesUtils.boolToByte(bitMaps != null));
     if (bitMaps != null) {
@@ -912,9 +886,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Serialize values, ignoring failed time series
-   */
+  /** Serialize values, ignoring failed time series */
   private void writeValues(IWALByteBufferView buffer, int start, int end) {
     for (int i = 0; i < columns.length; i++) {
       // ignore failed partial insert
@@ -974,9 +946,7 @@ public class InsertTabletNode extends InsertNode implements 
WALEntryValue {
     }
   }
 
-  /**
-   * Deserialize from wal
-   */
+  /** Deserialize from wal */
   public static InsertTabletNode deserializeFromWAL(DataInputStream stream) 
throws IOException {
     // we do not store plan node id in wal entry
     InsertTabletNode insertNode = new InsertTabletNode(new PlanNodeId(""));
@@ -1221,7 +1191,7 @@ public class InsertTabletNode extends InsertNode 
implements WALEntryValue {
    * Split the tablet of the given range according to Table deviceID.
    *
    * @param start inclusive
-   * @param end   exclusive
+   * @param end exclusive
    * @return each the number in the pair is the end offset of a device
    */
   public List<Pair<IDeviceID, Integer>> splitByDevice(int start, int end) {
@@ -1229,7 +1199,7 @@ public class InsertTabletNode extends InsertNode 
implements WALEntryValue {
   }
 
   /**
-   * @param results      insertion result of each row
+   * @param results insertion result of each row
    * @param rowTTLGetter the ttl associated with each row
    * @return the position of the first alive row
    * @throws OutOfTTLException if all rows have expired the TTL
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java
index e1ec01d96e4..31e000934c8 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/write/RelationalInsertTabletNode.java
@@ -23,7 +23,6 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.schema.table.column.TsTableColumnCategory;
 import org.apache.iotdb.db.exception.query.OutOfTTLException;
-import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNode;
 import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeId;
 import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNodeType;
 import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanVisitor;
@@ -31,7 +30,6 @@ import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanVisitor;
 import org.apache.tsfile.enums.TSDataType;
 import org.apache.tsfile.file.metadata.IDeviceID;
 import org.apache.tsfile.file.metadata.IDeviceID.Factory;
-import org.apache.tsfile.utils.Binary;
 import org.apache.tsfile.utils.BitMap;
 import org.apache.tsfile.utils.Pair;
 import org.apache.tsfile.write.schema.MeasurementSchema;
@@ -184,6 +182,4 @@ public class RelationalInsertTabletNode extends 
InsertTabletNode {
   public String getTableName() {
     return devicePath.getFullPath();
   }
-
-
 }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableSchema.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableSchema.java
index 8fbf1416d06..2abed5a8a18 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableSchema.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/TableSchema.java
@@ -19,7 +19,6 @@
 
 package org.apache.iotdb.db.queryengine.plan.relational.metadata;
 
-import java.util.Objects;
 import org.apache.iotdb.commons.schema.table.TsTable;
 import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema;
 import 
org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager;
@@ -30,6 +29,7 @@ import org.apache.tsfile.write.schema.MeasurementSchema;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 public class TableSchema {
 
@@ -83,8 +83,7 @@ public class TableSchema {
       return false;
     }
     TableSchema that = (TableSchema) o;
-    return Objects.equals(tableName, that.tableName) && Objects.equals(columns,
-        that.columns);
+    return Objects.equals(tableName, that.tableName) && 
Objects.equals(columns, that.columns);
   }
 
   @Override
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushPredicateIntoTableScan.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushPredicateIntoTableScan.java
index e9fb6ead873..d3300cc359e 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushPredicateIntoTableScan.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/PushPredicateIntoTableScan.java
@@ -25,6 +25,8 @@ import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNode;
 import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanVisitor;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.MultiChildProcessNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.process.SingleChildProcessNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.InsertTabletNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.RelationalInsertTabletNode;
 import org.apache.iotdb.db.queryengine.plan.relational.analyzer.Analysis;
 import 
org.apache.iotdb.db.queryengine.plan.relational.analyzer.predicate.ConvertPredicateToTimeFilterVisitor;
 import 
org.apache.iotdb.db.queryengine.plan.relational.analyzer.predicate.PredicateCombineIntoTableScanChecker;
@@ -246,6 +248,17 @@ public class PushPredicateIntoTableScan implements 
RelationalPlanOptimizer {
       return node;
     }
 
+    @Override
+    public PlanNode visitInsertTablet(InsertTabletNode node, RewriterContext 
context) {
+      return node;
+    }
+
+    @Override
+    public PlanNode visitRelationalInsertTablet(RelationalInsertTabletNode 
node,
+        RewriterContext context) {
+      return node;
+    }
+
     /** Get deviceEntries and DataPartition used in TableScan. */
     private void tableMetadataIndexScan(TableScanNode node, List<Expression> 
metadataExpressions) {
       List<String> attributeColumns =
diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/AnalyzerTest.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/AnalyzerTest.java
index 407efb213e7..ed02e45b014 100644
--- 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/AnalyzerTest.java
+++ 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/AnalyzerTest.java
@@ -19,8 +19,6 @@
 
 package org.apache.iotdb.db.queryengine.plan.relational.analyzer;
 
-import java.util.ArrayList;
-import java.util.concurrent.atomic.AtomicReference;
 import org.apache.iotdb.common.rpc.thrift.TConsensusGroupId;
 import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
 import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
@@ -28,13 +26,9 @@ import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
 import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
 import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
 import org.apache.iotdb.commons.conf.IoTDBConstant;
-import org.apache.iotdb.commons.exception.IoTDBException;
 import org.apache.iotdb.commons.partition.DataPartition;
 import org.apache.iotdb.commons.partition.DataPartitionQueryParam;
-import org.apache.iotdb.commons.partition.SchemaNodeManagementPartition;
-import org.apache.iotdb.commons.partition.SchemaPartition;
 import org.apache.iotdb.commons.partition.executor.SeriesPartitionExecutor;
-import org.apache.iotdb.commons.path.PathPatternTree;
 import org.apache.iotdb.db.protocol.session.IClientSession;
 import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
 import org.apache.iotdb.db.queryengine.common.QueryId;
@@ -43,12 +37,10 @@ import 
org.apache.iotdb.db.queryengine.execution.warnings.WarningCollector;
 import org.apache.iotdb.db.queryengine.plan.planner.plan.DistributedQueryPlan;
 import org.apache.iotdb.db.queryengine.plan.planner.plan.LogicalQueryPlan;
 import org.apache.iotdb.db.queryengine.plan.planner.plan.node.PlanNode;
-import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.InsertTabletNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.RelationalInsertTabletNode;
 import org.apache.iotdb.db.queryengine.plan.relational.function.OperatorType;
 import org.apache.iotdb.db.queryengine.plan.relational.metadata.ColumnHandle;
 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;
@@ -64,26 +56,19 @@ import 
org.apache.iotdb.db.queryengine.plan.relational.planner.node.OutputNode;
 import 
org.apache.iotdb.db.queryengine.plan.relational.planner.node.ProjectNode;
 import 
org.apache.iotdb.db.queryengine.plan.relational.planner.node.TableScanNode;
 import org.apache.iotdb.db.queryengine.plan.relational.security.AccessControl;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.InsertTablet;
 import 
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.LogicalExpression;
 import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Statement;
 import org.apache.iotdb.db.queryengine.plan.relational.sql.parser.SqlParser;
-import 
org.apache.iotdb.db.queryengine.plan.relational.type.TypeNotFoundException;
-import org.apache.iotdb.db.queryengine.plan.relational.type.TypeSignature;
 import org.apache.iotdb.db.queryengine.plan.statement.StatementTestUtils;
 import 
org.apache.iotdb.db.queryengine.plan.statement.crud.InsertTabletStatement;
-import org.apache.iotdb.mpp.rpc.thrift.TRegionRouteReq;
 
-import org.junit.Ignore;
-import org.apache.tsfile.file.metadata.IDeviceID;
 import org.apache.tsfile.file.metadata.IDeviceID.Factory;
-import org.apache.tsfile.read.common.type.Type;
+import org.junit.Ignore;
 import org.junit.Test;
-import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 
 import java.time.ZoneId;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -677,82 +662,99 @@ public class AnalyzerTest {
   public void analyzeTablet() {
 
     TableSchema tableSchema = StatementTestUtils.genTableSchema();
-    Metadata mockMetadata = new TestMatadata() {
-      @Override
-      public TableSchema validateTableHeaderSchema(String database, 
TableSchema schema,
-          MPPQueryContext context) {
-        assertEquals(tableSchema, schema);
-        return tableSchema;
-      }
-
-      @Override
-      public void validateDeviceSchema(ITableDeviceSchemaValidation 
schemaValidation,
-          MPPQueryContext context) {
-        assertEquals(sessionInfo.getDatabaseName().get(), 
schemaValidation.getDatabase());
-        assertEquals(StatementTestUtils.tableName(), 
schemaValidation.getTableName());
-        Object[] columns = StatementTestUtils.genColumns();
-        for (int i = 0; i < schemaValidation.getDeviceIdList().size(); i++) {
-          Object[] objects = schemaValidation.getDeviceIdList().get(i);
-          assertEquals(objects[0].toString(), StatementTestUtils.tableName());
-          assertEquals(objects[1].toString(), ((String[]) columns[0])[i]);
-        }
-        List<String> attributeColumnNameList = 
schemaValidation.getAttributeColumnNameList();
-        assertEquals(Collections.singletonList("attr1"), 
attributeColumnNameList);
-        assertEquals(1, schemaValidation.getAttributeValueList().size());
-        assertArrayEquals((Object[]) columns[1], 
schemaValidation.getAttributeValueList().get(0));
-      }
-
-      @Override
-      public DataPartition getOrCreateDataPartition(
-          List<DataPartitionQueryParam> dataPartitionQueryParams, String 
userName) {
-        int seriesSlotNum = 1000;
-        String partitionExecutorName = 
"org.apache.iotdb.commons.partition.executor.hash.BKDRHashExecutor";
-        SeriesPartitionExecutor seriesPartitionExecutor = 
SeriesPartitionExecutor.getSeriesPartitionExecutor(
-            partitionExecutorName, seriesSlotNum);
-
-        Map<String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, 
List<TRegionReplicaSet>>>>
-            dataPartitionMap = new HashMap<>();
-        assertEquals(3, dataPartitionQueryParams.size());
-
-        for (DataPartitionQueryParam dataPartitionQueryParam : 
dataPartitionQueryParams) {
-          String databaseName = dataPartitionQueryParam.getDatabaseName();
-          assertEquals(sessionInfo.getDatabaseName().get(), databaseName);
-
-          String tableName = 
dataPartitionQueryParam.getDeviceID().getTableName();
-          assertEquals(StatementTestUtils.tableName(), tableName);
-
-          TSeriesPartitionSlot partitionSlot = 
seriesPartitionExecutor.getSeriesPartitionSlot(
-              dataPartitionQueryParam.getDeviceID());
-          for (TTimePartitionSlot tTimePartitionSlot : 
dataPartitionQueryParam.getTimePartitionSlotList()) {
-            dataPartitionMap.computeIfAbsent(databaseName, d -> new 
HashMap<>())
-                .computeIfAbsent(partitionSlot, slot -> new HashMap<>())
-                .computeIfAbsent(tTimePartitionSlot, slot -> new ArrayList<>())
-                .add(new TRegionReplicaSet(new TConsensusGroupId(
-                    TConsensusGroupType.DataRegion, partitionSlot.slotId), 
Collections.singletonList(
-                    new TDataNodeLocation(partitionSlot.slotId, null, null, 
null, null, null))));
+    Metadata mockMetadata =
+        new TestMatadata() {
+          @Override
+          public TableSchema validateTableHeaderSchema(
+              String database, TableSchema schema, MPPQueryContext context) {
+            assertEquals(tableSchema, schema);
+            return tableSchema;
+          }
+
+          @Override
+          public void validateDeviceSchema(
+              ITableDeviceSchemaValidation schemaValidation, MPPQueryContext 
context) {
+            assertEquals(sessionInfo.getDatabaseName().get(), 
schemaValidation.getDatabase());
+            assertEquals(StatementTestUtils.tableName(), 
schemaValidation.getTableName());
+            Object[] columns = StatementTestUtils.genColumns();
+            for (int i = 0; i < schemaValidation.getDeviceIdList().size(); 
i++) {
+              Object[] objects = schemaValidation.getDeviceIdList().get(i);
+              assertEquals(objects[0].toString(), 
StatementTestUtils.tableName());
+              assertEquals(objects[1].toString(), ((String[]) columns[0])[i]);
+            }
+            List<String> attributeColumnNameList = 
schemaValidation.getAttributeColumnNameList();
+            assertEquals(Collections.singletonList("attr1"), 
attributeColumnNameList);
+            assertEquals(1, schemaValidation.getAttributeValueList().size());
+            assertArrayEquals(
+                (Object[]) columns[1], 
schemaValidation.getAttributeValueList().get(0));
+          }
+
+          @Override
+          public DataPartition getOrCreateDataPartition(
+              List<DataPartitionQueryParam> dataPartitionQueryParams, String 
userName) {
+            int seriesSlotNum = 1000;
+            String partitionExecutorName =
+                
"org.apache.iotdb.commons.partition.executor.hash.BKDRHashExecutor";
+            SeriesPartitionExecutor seriesPartitionExecutor =
+                SeriesPartitionExecutor.getSeriesPartitionExecutor(
+                    partitionExecutorName, seriesSlotNum);
+
+            Map<String, Map<TSeriesPartitionSlot, Map<TTimePartitionSlot, 
List<TRegionReplicaSet>>>>
+                dataPartitionMap = new HashMap<>();
+            assertEquals(3, dataPartitionQueryParams.size());
+
+            for (DataPartitionQueryParam dataPartitionQueryParam : 
dataPartitionQueryParams) {
+              String databaseName = dataPartitionQueryParam.getDatabaseName();
+              assertEquals(sessionInfo.getDatabaseName().get(), databaseName);
+
+              String tableName = 
dataPartitionQueryParam.getDeviceID().getTableName();
+              assertEquals(StatementTestUtils.tableName(), tableName);
+
+              TSeriesPartitionSlot partitionSlot =
+                  seriesPartitionExecutor.getSeriesPartitionSlot(
+                      dataPartitionQueryParam.getDeviceID());
+              for (TTimePartitionSlot tTimePartitionSlot :
+                  dataPartitionQueryParam.getTimePartitionSlotList()) {
+                dataPartitionMap
+                    .computeIfAbsent(databaseName, d -> new HashMap<>())
+                    .computeIfAbsent(partitionSlot, slot -> new HashMap<>())
+                    .computeIfAbsent(tTimePartitionSlot, slot -> new 
ArrayList<>())
+                    .add(
+                        new TRegionReplicaSet(
+                            new TConsensusGroupId(
+                                TConsensusGroupType.DataRegion, 
partitionSlot.slotId),
+                            Collections.singletonList(
+                                new TDataNodeLocation(
+                                    partitionSlot.slotId, null, null, null, 
null, null))));
+              }
+            }
+            return new DataPartition(dataPartitionMap, partitionExecutorName, 
seriesSlotNum);
           }
-        }
-        return new DataPartition(dataPartitionMap, partitionExecutorName, 
seriesSlotNum);
-      }
-    };
+        };
 
     InsertTabletStatement insertTabletStatement = 
StatementTestUtils.genInsertTabletStatement(true);
     context = new MPPQueryContext("", queryId, sessionInfo, null, null);
-    actualAnalysis = 
analyzeStatement(insertTabletStatement.toRelationalStatement(context),
-        mockMetadata, new SqlParser(), sessionInfo);
+    actualAnalysis =
+        analyzeStatement(
+            insertTabletStatement.toRelationalStatement(context),
+            mockMetadata,
+            new SqlParser(),
+            sessionInfo);
     logicalQueryPlan =
-        new LogicalPlanner(
-            context, mockMetadata, sessionInfo, getFakePartitionFetcher(), 
WarningCollector.NOOP)
+        new LogicalPlanner(context, mockMetadata, sessionInfo, 
WarningCollector.NOOP)
             .plan(actualAnalysis);
 
-    RelationalInsertTabletNode insertTabletNode = (RelationalInsertTabletNode) 
logicalQueryPlan.getRootNode();
+    RelationalInsertTabletNode insertTabletNode =
+        (RelationalInsertTabletNode) logicalQueryPlan.getRootNode();
 
     assertEquals(insertTabletNode.getTableName(), 
StatementTestUtils.tableName());
     assertEquals(3, insertTabletNode.getRowCount());
     Object[] columns = StatementTestUtils.genColumns();
     for (int i = 0; i < insertTabletNode.getRowCount(); i++) {
-      assertEquals(Factory.DEFAULT_FACTORY.create(new 
String[]{StatementTestUtils.tableName(),
-          ((String[]) columns[0])[i]}), insertTabletNode.getDeviceID(i));
+      assertEquals(
+          Factory.DEFAULT_FACTORY.create(
+              new String[] {StatementTestUtils.tableName(), ((String[]) 
columns[0])[i]}),
+          insertTabletNode.getDeviceID(i));
     }
     assertEquals(columns, insertTabletNode.getColumns());
     assertArrayEquals(StatementTestUtils.genTimestamps(), 
insertTabletNode.getTimes());
@@ -771,8 +773,8 @@ public class AnalyzerTest {
     return analyzeStatement(statement, metadata, sqlParser, session);
   }
 
-  public static Analysis analyzeStatement(Statement statement, Metadata 
metadata,
-      SqlParser sqlParser, SessionInfo session) {
+  public static Analysis analyzeStatement(
+      Statement statement, Metadata metadata, SqlParser sqlParser, SessionInfo 
session) {
     try {
       StatementAnalyzerFactory statementAnalyzerFactory =
           new StatementAnalyzerFactory(metadata, sqlParser, nopAccessControl);
@@ -793,7 +795,5 @@ public class AnalyzerTest {
     return null;
   }
 
-  private static class NopAccessControl implements AccessControl {
-
-  }
+  private static class NopAccessControl implements AccessControl {}
 }
diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/statement/StatementTestUtils.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/statement/StatementTestUtils.java
index 008144db4d9..3cdbf8657db 100644
--- 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/statement/StatementTestUtils.java
+++ 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/statement/StatementTestUtils.java
@@ -30,7 +30,6 @@ import org.apache.tsfile.read.common.type.TypeFactory;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.apache.tsfile.utils.Binary;
 
 public class StatementTestUtils {
 
@@ -43,16 +42,16 @@ public class StatementTestUtils {
   }
 
   public static String[] genColumnNames() {
-    return new String[]{"id1", "attr1", "m1"};
+    return new String[] {"id1", "attr1", "m1"};
   }
 
   public static TSDataType[] genDataTypes() {
-    return new TSDataType[]{TSDataType.STRING, TSDataType.STRING, 
TSDataType.DOUBLE};
+    return new TSDataType[] {TSDataType.STRING, TSDataType.STRING, 
TSDataType.DOUBLE};
   }
 
   public static TsTableColumnCategory[] genColumnCategories() {
-    return new TsTableColumnCategory[]{
-        TsTableColumnCategory.ID, TsTableColumnCategory.ATTRIBUTE, 
TsTableColumnCategory.MEASUREMENT
+    return new TsTableColumnCategory[] {
+      TsTableColumnCategory.ID, TsTableColumnCategory.ATTRIBUTE, 
TsTableColumnCategory.MEASUREMENT
     };
   }
 
@@ -75,15 +74,15 @@ public class StatementTestUtils {
   }
 
   public static Object[] genColumns() {
-    return new Object[]{
-        new String[]{"a", "b", "c"},
-        new String[]{"x", "y", "z"},
-        new double[]{1.0, 2.0, 3.0}
+    return new Object[] {
+      new String[] {"a", "b", "c"},
+      new String[] {"x", "y", "z"},
+      new double[] {1.0, 2.0, 3.0}
     };
   }
 
   public static long[] genTimestamps() {
-    return new long[]{1L, 2L, 3L};
+    return new long[] {1L, 2L, 3L};
   }
 
   public static InsertTabletStatement genInsertTabletStatement(boolean 
writeToTable) {
@@ -95,7 +94,7 @@ public class StatementTestUtils {
     long[] timestamps = genTimestamps();
 
     InsertTabletStatement insertTabletStatement = new InsertTabletStatement();
-    insertTabletStatement.setDevicePath(new PartialPath(new 
String[]{tableName()}));
+    insertTabletStatement.setDevicePath(new PartialPath(new String[] 
{tableName()}));
     insertTabletStatement.setMeasurements(measurements);
     insertTabletStatement.setDataTypes(dataTypes);
     insertTabletStatement.setColumnCategories(columnCategories);


Reply via email to