You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "ILuffZhe (via GitHub)" <gi...@apache.org> on 2023/07/02 02:12:04 UTC
[GitHub] [calcite] ILuffZhe commented on a diff in pull request #3274: [CALCITE-5688] Support TRUNCATE TABLE DDL statement in server module
ILuffZhe commented on code in PR #3274:
URL: https://github.com/apache/calcite/pull/3274#discussion_r1249095446
##########
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:
May I ask why only MutableArrayTable is supported? ^_^
##########
core/src/main/codegen/templates/Parser.jj:
##########
@@ -4353,6 +4357,30 @@ SqlDrop SqlDrop() :
}
</#if>
+<#if (parser.truncateStatementParserMethods!default.parser.truncateStatementParserMethods)?size != 0>
+/**
+ * Parses a TRUNCATE TABLE statement.
Review Comment:
I think `Parses a TRUNCATE statement` is more suitable, according to your explanation [below](https://github.com/apache/calcite/pull/3274/files#r1237971294)
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org