diff --git a/examples/cassandra.md b/examples/cassandra.md index d0136d7..4480e18 100644 --- a/examples/cassandra.md +++ b/examples/cassandra.md @@ -26,25 +26,8 @@ Once created, execute queryda with the following commandline using the *cqlexamp ``` bin/queryda --configfile="../jobs/cqlexample.json" ``` -### Custom Time-Range Function -To allow simple time-range queries in Cassandra 3.x, the following custom Function can be used: -``` -CREATE FUNCTION IF NOT EXISTS toTimestampLast(minutes int) - CALLED ON NULL INPUT - RETURNS timestamp - LANGUAGE java AS ' - long now = System.currentTimeMillis(); - if (minutes == null) - return new Date(now); - return new Date(now - (minutes.intValue() * 60 * 1000)); - '; -``` -Usage: -``` -SELECT value FROM test.TEST WHERE LAST_MODIFIED_DATE >= toTimestampLast(60) AND LAST_MODIFIED_DATE <= toTimestamp(now()) LIMIT 100 ALLOW FILTERING; -``` -#### Configuration +#### Example Configuration The following examples illustrates a time-bound ``` { @@ -66,3 +49,21 @@ The following examples illustrates a time-bound } } ``` + +### Custom Time-Range Function +To allow simple time-range queries in Cassandra 3.x, the following custom Function can be used. Note custom functions requires ```enable_user_defined_functions=true``` in cassandra.yaml ahead of usage. +``` +CREATE FUNCTION IF NOT EXISTS toTimestampLast(minutes int) + CALLED ON NULL INPUT + RETURNS timestamp + LANGUAGE java AS ' + long now = System.currentTimeMillis(); + if (minutes == null) + return new Date(now); + return new Date(now - (minutes.intValue() * 60 * 1000)); + '; +``` +Usage: +``` +SELECT value FROM test.TEST WHERE LAST_MODIFIED_DATE >= toTimestampLast(60) AND LAST_MODIFIED_DATE <= toTimestamp(now()) LIMIT 100 ALLOW FILTERING; +```