Scylla: Support Datetime functions

Created on 9 Nov 2017  路  3Comments  路  Source: scylladb/scylla

Installation details
Scylla version (or git commit hash): 2.0

Add support for Datetime conversion functions

  • currentTimestamp
  • currentDate
  • currentTime
  • currentTimeUUID

Example:

SELECT * FROM myTable WHERE date >= currentDate() - 2d

Source:
http://cassandra.apache.org/doc/latest/cql/functions.html#datetime-functions

CQL cassandra 2.2 compatibility enhancement

Most helpful comment

FYI: We just had an user in the users slack looking for that today

All 3 comments

need to validate / impl the following as well

Function name | Input type | Description
-- | -- | --
toDate | timeuuid | Converts the聽timeuuid聽argument into a聽date聽type
toDate | timestamp | Converts the聽timestamp聽argument into a聽date聽type
toTimestamp | timeuuid | Converts the聽timeuuid聽argument into a聽timestamp聽type
toTimestamp | date | Converts the聽date聽argument into a聽timestamp聽type
toUnixTimestamp | timeuuid | Converts the聽timeuuid聽argument into a聽bigInt聽raw value
toUnixTimestamp | timestamp | Converts the聽timestamp聽argument into a聽bigInt聽raw value
toUnixTimestamp | date | Converts the聽date聽argument into a聽bigInt聽raw value
dateOf | timeuuid | Similar to聽toTimestamp(timeuuid)聽(DEPRECATED)
unixTimestampOf | timeuuid | Similar to聽toUnixTimestamp(timeuuid)聽(DEPRECATED)

FYI: We just had an user in the users slack looking for that today

What version of C* do they use? I tried the example with -2d and it didn't work in Cassandra-3.11.2:

cqlsh:xyz> select * from dt where dt >= currentDate() - 2d;
SyntaxException: line 1:43 mismatched input '-' expecting EOF (...where dt >= currentData() [-]...)

C* documentation isn't clear whether only d is supported, probably ms, s, M, h, d, w, m, y would make sense.

It seems that toDate(.), titimestamp(.), toUnixTimestamp aren't supported by Scylla.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eyalgutkind picture eyalgutkind  路  3Comments

amoskong picture amoskong  路  6Comments

Ritaja picture Ritaja  路  3Comments

gnumoreno picture gnumoreno  路  5Comments

hellowaywewe picture hellowaywewe  路  3Comments