You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "maghamravikiran (JIRA)" <ji...@apache.org> on 2016/01/06 06:22:39 UTC
[jira] [Updated] (PHOENIX-2433) support additional time units (like
week/month/year) in Trunc() round() and Ceil()
[ https://issues.apache.org/jira/browse/PHOENIX-2433?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
maghamravikiran updated PHOENIX-2433:
-------------------------------------
Attachment: PHOENIX-2433-firstdrop.patch
[~James Taylor] ,
Two approaches come to my mind.
1. Joda Time: I have patch that uses this library providing us with the necessary functionality . Its simple and just works like a charm.
2. Write the logic ourselves. I initially started off with this approach and to find out the result for FLOOR('date','WEEK') , the following code needs to be applied . Definitely this will change with CEIL and ROUND .
{code}
Date dateUpserted = new Date();
long divBy = 24 * 60 * 60 * 1000;
long millis = dateUpserted.getTime();
millis = millis + 3 * divBy;
millis = millis / (7 * divBy);
millis = millis * 7 * divBy;
millis = millis - (3 * divBy);
Date flooredDate = new Date(millis);
{code}
Is it ok with the first approach or should we stick with the second ? I prefer the former as its simpler and handles all corner cases well.
All the tests in RoundFloorCeilFunctionsEnd2EndIT pass with the patch attached.
> support additional time units (like week/month/year) in Trunc() round() and Ceil()
> -----------------------------------------------------------------------------------
>
> Key: PHOENIX-2433
> URL: https://issues.apache.org/jira/browse/PHOENIX-2433
> Project: Phoenix
> Issue Type: Improvement
> Reporter: noam bulvik
> Assignee: maghamravikiran
> Labels: newbie
> Attachments: PHOENIX-2433-firstdrop.patch
>
>
> currently the time units that are supported in trunk(), round(), ceil are day/hour/minute/seconds/milliseconds.
> It should support also other values like week, month, year
> You can see how it is documented for Oracle in http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions201.htm and different supported level in http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions230.htm#i1002084
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)