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


##########
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:
   OK, got it. Maybe some java doc is better for other developers, WDYT?



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