JiajunBernoulli commented on code in PR #3274:
URL: https://github.com/apache/calcite/pull/3274#discussion_r1249134097


##########
server/src/main/java/org/apache/calcite/server/ServerDdlExecutor.java:
##########
@@ -182,6 +183,22 @@ static SqlNode renameColumns(@Nullable SqlNodeList 
columnList,
         null, null, null, null, null);
   }
 
+  static void erase(SqlIdentifier name, CalcitePrepare.Context context) {
+    // Directly clearing data is more efficient than executing SQL
+    final Pair<CalciteSchema, String> pair = schema(context, true, name);
+    final CalciteSchema calciteSchema = pair.left;
+    final String tblName = pair.right;
+    final Table table = calciteSchema
+        .getTable(tblName, context.config().caseSensitive())
+        .getTable();
+    if (table instanceof MutableArrayTable) {
+      MutableArrayTable mutableArrayTable = (MutableArrayTable) table;
+      mutableArrayTable.rows.clear();
+    } else {
+      throw new UnsupportedOperationException("Only MutableArrayTable support 
truncate");

Review Comment:
   - The DELETE statement cannot delete data in the server module.
      I initially thought it was a 
[bug](https://issues.apache.org/jira/browse/CALCITE-5796). But after analysis, 
it  is limitation of the server module.
   - `MutableArrayTable` is enough, because `CREATE` table all are 
`MutableArrayTable`. Here is code link: 
https://github.com/apache/calcite/blob/301f770a66ef3d26c9d4e8d274eae0f92a819e00/server/src/main/java/org/apache/calcite/server/ServerDdlExecutor.java#L515



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