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

             Summary: Result metadata reports timeuuid results of functions as 
custom type LegacyTimeUUIDType, so drivers can't decode them
                 Key: CASSANDRA-21735
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21735
             Project: Apache Cassandra
          Issue Type: Bug
            Reporter: Nadav Har'El


Since the TimeUUID refactoring in CASSANDRA-17176 (4.1.0), several functions on 
{{timeuuid}} values describe their result in the result metadata as the custom 
type {{org.apache.cassandra.db.marshal.LegacyTimeUUIDType}} instead of the 
native {{timeuuid}} type. Drivers don't know this custom type, so they return 
the raw bytes instead of a UUID:

{{CREATE TABLE ks.t (pk int PRIMARY KEY, v timeuuid);
INSERT INTO ks.t (pk, v) VALUES (1, 2deb23e0-96b5-11e5-b26d-a939dd1405a3);
SELECT max(v) FROM ks.t;                          -- type: 
'org.apache.cassandra.db.marshal.LegacyTimeUUIDType'
SELECT blobAsTimeuuid(timeuuidAsBlob(v)) FROM ks.t;  -- same
CREATE FUNCTION ks.f (a timeuuid, b timeuuid) CALLED ON NULL INPUT RETURNS 
timeuuid LANGUAGE java AS 'return b;';
SELECT ks.f(v, v) FROM ks.t;                      -- same}}
The Python driver returns {{b'-\xeb#\xe0...'}} instead of 
{{UUID('2deb23e0-…')}} for all three. A plain {{SELECT v}} and a {{(timeuuid)}} 
literal are correctly described as {{{}timeuuid{}}}.

 

The cause appears to be {{{}TimeUUIDType.udfType(){}}}, which returns 
{{{}LegacyTimeUUIDType.instance{}}}. That type is used for function signatures 
(UDFs, {{{}BytesConversionFcts{}}}, aggregates), and only {{TimeUUIDType}} is 
mapped to the protocol's native {{timeuuid}} type code. Reproduced on 5.0 and 
trunk (6.0). TermSelectionTest.testConstantFunctionArgs checks a UDF returning 
a {{{}timeuuid{}}}, but it reads the result inside Cassandra 
(CQLTester.execute()), without serializing the result metadata, so it doesn't 
notice.



--
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