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 2022/08/11 22:22:50 UTC
[GitHub] [cassandra] adelapena commented on a diff in pull request #1739: CASSANDRA-8877 trunk: Ability to read the TTL and WRITE TIME of an element in a collection
adelapena commented on code in PR #1739:
URL: https://github.com/apache/cassandra/pull/1739#discussion_r943985744
##########
test/unit/org/apache/cassandra/cql3/validation/entities/WritetimeOrTTLTest.java:
##########
@@ -1050,6 +1052,47 @@ public void testFrozenNestedUDTs() throws Throwable
assertWritetimeAndTTL("t.f2.f2", "k=12", TIMESTAMP_1, TTL_1);
}
+ @Test
+ public void testFunctions() throws Throwable
+ {
+ createTable("CREATE TABLE %s (k int PRIMARY KEY, v int, s set<int>, fs frozen<set<int>>)");
+ execute("INSERT INTO %s (k, v, s, fs) VALUES (0, 0, {1, 2, 3}, {1, 2, 3}) USING TIMESTAMP 1 AND TTL 1000");
+ execute("INSERT INTO %s (k, v, s, fs) VALUES (1, 1, {10, 20, 30}, {10, 20, 30}) USING TIMESTAMP 10 AND TTL 1000");
+ execute("UPDATE %s USING TIMESTAMP 2 AND TTL 2000 SET s = s + {2, 3} WHERE k = 0");
+ execute("UPDATE %s USING TIMESTAMP 20 AND TTL 2000 SET s = s + {20, 30} WHERE k = 1");
+
+ // Regular column
+ assertRows("SELECT min(v) FROM %s", row(0));
+ assertRows("SELECT max(v) FROM %s", row(1));
+ assertRows("SELECT writetime(v) FROM %s", row(10L), row(1L));
+ assertRows("SELECT min(writetime(v)) FROM %s", row(1L));
+ assertRows("SELECT max(writetime(v)) FROM %s", row(10L));
+ assertRows("SELECT min(maxwritetime(v)) FROM %s", row(1L));
+ assertRows("SELECT max(maxwritetime(v)) FROM %s", row(10L));
Review Comment:
This is indeed confusing. The `max` function is not what perhaps we would like in this context, but an aggregation function that selects the row with the maximum column value. If it's applied to a collection column it doesn't select the max item within the collection, but the max collection among the selected rows. There is some followup on this in CASSANDRA-17811.
--
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