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

             Summary: format_time() rejects the documented time unit µs
                 Key: CASSANDRA-21758
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21758
             Project: Apache Cassandra
          Issue Type: Bug
            Reporter: Nadav Har'El


The documentation of the {{format_time()}} function (added in CASSANDRA-19546) 
says, in doc/modules/cassandra/pages/developing/cql/functions.adoc:

{quote}
Supported units are: {{d}}, {{h}}, {{m}}, {{s}}, {{ms}}, {{us}}, {{µs}}, {{ns}}.
{quote}

The javadoc of {{FormatFcts.FormatTimeFct}} says the same ("Supported units 
are: d, h, m, s, ms, us, µs, ns"), and {{DurationSpec.fromSymbol()}}, which 
{{format_time()}} uses to parse the unit, does accept "µs". But in practice the 
unit {{µs}} can't be used, because {{format_time()}}'s unit parameters are 
declared {{ascii}} ({{optional(fixed(ASCII))}} in {{FormatTimeFct.factory()}}), 
and "µs" is not an ASCII string.

Tested on Cassandra 6.0-alpha2 ({{format_time()}} doesn't exist in 5.0):

{code:sql}
SELECT format_time(5, 'ms', 'us') FROM system.local;
-- returns '5000 us'
SELECT format_time(5, 'ms', 'µs') FROM system.local;
-- InvalidRequest: Function system.format_time requires an argument of type 
ascii, but found argument 'µs' of type text
SELECT format_time(5, 'µs', 'ns') FROM system.local;
-- InvalidRequest: Function system.format_time requires an argument of type 
ascii, but found argument 'µs' of type text
{code}

Passing 'µs' as a bound value doesn't work either: the bind marker's type is 
{{ascii}}, so a client can't send "µs" for it (the Python driver fails with 
UnicodeEncodeError).

The same text is still in the documentation on trunk (as of commit 
4ab8bac4a51f).

Either the documentation (and javadoc) should stop listing {{µs}}, or the unit 
parameters should also accept {{text}}, so that {{µs}} works as documented.




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