[
https://issues.apache.org/jira/browse/CASSANDRA-11873?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15333706#comment-15333706
]
Benjamin Lerer commented on CASSANDRA-11873:
--------------------------------------------
bq. What about leap year?
I think that point worth some discussion.
The current patch store the duration in a number of nanoseconds. Which means
that some information will be lost. If a user provide {{3y}} or {{3 year}} it
will be converted in nanoseconds and the {{now() - 3y}} will not result in the
correct date. We can try to guess what the user intended but it is a risky
business.
If we want to handle properly things like that it means that we have to use a
more complex serialization format. Basically we need to store at least {{year}}
and {{month}} separately from the remaining time in nanosecond (which is I
guess the main reason why Influxdb is not supporting the month and year units).
Even if it allow a better handling of some use cases, I think that this
solution will bring some problems. {{Java}} for example do not have a type that
can be directly mapped to that (if I am not mistaken). It has 2 different
classes: {{Period}} for the date part and {{Duration}} for the time part. By
consequence, it can be difficult for the driver to handle such a type.
I also believe (even if I do not have some concret proof right now) that it
will make some computations, like the one needed for CASSANDRA-11871, more
expensives.
Overall, I am in favor of keeping the thing as simple as possible. Which is for
me: storing the duration has nanoseconds, supporting as litterals only a number
followed by a symbol (in this first version at least) and not supporting
{{month}} or {{year}} units (the current patch does not support {{week}} but it
can easily be added).
Having said that, I am fully open to discussion.
> Add duration type
> -----------------
>
> Key: CASSANDRA-11873
> URL: https://issues.apache.org/jira/browse/CASSANDRA-11873
> Project: Cassandra
> Issue Type: Improvement
> Components: CQL
> Reporter: Benjamin Lerer
> Assignee: Benjamin Lerer
> Labels: client-impacting, doc-impacting
> Fix For: 3.x
>
>
> For CASSANDRA-11871 or to allow queries with {{WHERE}} clause like:
> {{... WHERE reading_time < now() - 2h}}, we need to support some duration
> type.
> In my opinion, it should be represented internally as a number of
> microseconds.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)