Installation details
Scylla version (or git commit hash): 2.1-rc2
Hello. I noticed that aggregation functions doesn't work on counters. I don't see any reason this shouldn't be possible.
How to reproduce:
CREATE TABLE test (
key INT,
ctr COUNTER,
PRIMARY KEY (
key
)
);
UPDATE test SET ctr = ctr + 1 WHERE key = 1;
SELECT SUM(ctr) FROM test;
Result
InvalidRequest: Error from server: code=2200 [Invalid query] message="Invalid call to function sum, none of its type signatures match (known type signatures: system.sum : (org.apache.cassandra.db.marshal.DecimalType) -> org.apache.cassandra.db.marshal.DecimalType, system.sum : (org.apache.cassandra.db.marshal.IntegerType) -> org.apache.cassandra.db.marshal.IntegerType, system.sum : (org.apache.cassandra.db.marshal.DoubleType) -> org.apache.cassandra.db.marshal.DoubleType, system.sum : (org.apache.cassandra.db.marshal.FloatType) -> org.apache.cassandra.db.marshal.FloatType, system.sum : (org.apache.cassandra.db.marshal.LongType) -> org.apache.cassandra.db.marshal.LongType, system.sum : (org.apache.cassandra.db.marshal.Int32Type) -> org.apache.cassandra.db.marshal.Int32Type, system.sum : (org.apache.cassandra.db.marshal.ShortType) -> org.apache.cassandra.db.marshal.ShortType, system.sum : (org.apache.cassandra.db.marshal.ByteType) -> org.apache.cassandra.db.marshal.ByteType)"
I also tried casting
SELECT SUM(CAST(ctr as bigint)) FROM test
but it's not working either
Error from server: code=2200 [Invalid query] message="org.apache.cassandra.db.marshal.CounterColumnType cannot be cast to org.apache.cassandra.db.marshal.LongType"
@pdziepak ?
@penberg / @pdziepak ?
check it works on cassandra 2.2.9
Looks like it was added in [1]. No reason not to implement this in Scylla as well. If I remember correctly at this stage counters are already treated as bigint values (and not sets of counter shards) so supporting aggregating them shouldn't be very difficult.
Was issue fixed in the latest release (2.3.rc1)? I'm using 2.2.0 and still facing this issue.
@antsmc2 issue is not fixed yet. Once it does, you should see a commit link in the comments
Any news regarding sum on counter fields?
Any updates on this ? 馃檹
@jimmykuo no news yet. Waiting for a brave volunteer to send a PR
Need this one as well
@haaawk / @jul-stas - its a feature related to counters - so queue this up for you guys.
Reproducer:
CREATE KEYSPACE test WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
CREATE TABLE test.wsgcounter ( countername text PRIMARY KEY, counterval counter );
UPDATE wsgcounter SET counterval = counterval + 1 WHERE countername = 'bla';
UPDATE wsgcounter SET counterval = counterval + 10 WHERE countername = 'ble';
UPDATE wsgcounter SET counterval = counterval + 100 WHERE countername = 'bli';
select cast(counterval as varchar) from wsgcounter where countername='bla';
@gnumoreno its casting not a sum function, why do you need to cast the value (in this case it was an attempt to make the value an int that can be summed.
@slivne the original poster also mentioned casting, please check the first post on the thread.
Aggregation is already solved and merged to master: https://github.com/scylladb/scylla/pull/5632 . (GH somehow didn't close this issue...)
Rearding casts: currently only implicit cast to long is supported. If we need other casts let's open a new issue and talk about it.
Most helpful comment
@haaawk / @jul-stas - its a feature related to counters - so queue this up for you guys.