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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]