Nadav Har'El created CASSANDRA-21786:
----------------------------------------

             Summary: An aggregate keeps using its old state function after 
CREATE OR REPLACE FUNCTION
                 Key: CASSANDRA-21786
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21786
             Project: Apache Cassandra
          Issue Type: Bug
            Reporter: Nadav Har'El


When CREATE OR REPLACE FUNCTION replaces a function which is the state function 
(SFUNC) of a user-defined aggregate, the aggregate keeps calling the old 
version of the function - in unprepared statements, in previously prepared 
statements, and in newly prepared statements. Only the function itself, called 
directly, uses the new version.

Reproducer, tested on Cassandra 5.0.9 and 6.0-alpha2:
{code:java}
CREATE TABLE ks.t (p int PRIMARY KEY, v int);
INSERT INTO ks.t (p, v) VALUES (1, 3);
CREATE FUNCTION ks.sf(s int, a int) CALLED ON NULL INPUT RETURNS int LANGUAGE 
java AS 'return s + 1 * a;';
CREATE AGGREGATE ks.agg(int) SFUNC sf STYPE int INITCOND 0;
SELECT ks.agg(v) FROM ks.t;   -- 3, as expected
CREATE OR REPLACE FUNCTION ks.sf(s int, a int) CALLED ON NULL INPUT RETURNS int 
LANGUAGE java AS 'return s + 2 * a;';
SELECT ks.agg(v) FROM ks.t;   -- still 3, expected 6
{code}
The aggregate only picks up the new state function after it is itself 
re-created (or, maybe (I didn't test), after a restart).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to