You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/07/26 09:06:45 UTC
[GitHub] [cassandra] blerer commented on a change in pull request #1117: CASSANDRA-16806. Allow TRUNCATE to work on Virtual Tables if the implementation allows it.
blerer commented on a change in pull request #1117:
URL: https://github.com/apache/cassandra/pull/1117#discussion_r676420495
##########
File path: test/unit/org/apache/cassandra/cql3/validation/entities/VirtualTableTest.java
##########
@@ -88,17 +89,45 @@ public void apply(PartitionUpdate update)
}
}
+ private abstract static class TruncatableVirtualTable extends AbstractVirtualTable
+ {
+ private boolean isTruncated = false;
+
+ TruncatableVirtualTable(TableMetadata metadata)
+ {
+ super(metadata);
+ }
+
+ @Override
+ public DataSet data()
+ {
+ if (isTruncated)
Review comment:
Checking that perfoming a TRUNCATE call the `truncate` method is probably enough as the rest is dependent on the VT implementation. I would simply check that if we perform multiple TRUNCATE all the calls are transmitted to the VT and not only the first one.
##########
File path: test/unit/org/apache/cassandra/cql3/validation/entities/VirtualTableTest.java
##########
@@ -88,17 +89,45 @@ public void apply(PartitionUpdate update)
}
}
+ private abstract static class TruncatableVirtualTable extends AbstractVirtualTable
+ {
+ private boolean isTruncated = false;
Review comment:
Virtual table can be called by multiple threads and that the tread reading the VT might be different from the one performing the truncation.
##########
File path: src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java
##########
@@ -66,7 +68,10 @@ public ResultMessage execute(QueryState state, QueryOptions options, long queryS
throw new InvalidRequestException("Cannot TRUNCATE materialized view directly; must truncate base table instead");
if (metaData.isVirtual())
- throw new InvalidRequestException("Cannot truncate virtual tables");
+ {
+ executeForVirtualTable(metaData.id);
+ return null;
Review comment:
nit: In this case I would have use a `if-else` to keep a single return.
I did not remember what we normally return for TRUNCATE statements and I had to check that it was matching the other one.
--
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: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org