[ 
https://issues.apache.org/jira/browse/PHOENIX-2433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15094329#comment-15094329
 ] 

James Taylor commented on PHOENIX-2433:
---------------------------------------

Thanks - patch looks good, [~maghamravikiran], with the exception of the 
serialization change in RoundDateExpression:
{code}
@@ -139,7 +155,6 @@ public class RoundDateExpression extends ScalarFunction {
             PDataType dataType = getDataType();
             long time = dataType.getCodec().decodeLong(ptr, 
children.get(0).getSortOrder());
             long value = roundTime(time);
-            
             Date d = new Date(value);
             byte[] byteValue = dataType.toBytes(d);
             ptr.set(byteValue);
@@ -173,12 +188,15 @@ public class RoundDateExpression extends ScalarFunction {
     @Override
     public void readFields(DataInput input) throws IOException {
         super.readFields(input);
+        String tunit = WritableUtils.readString(input);
+        timeUnit = TimeUnit.valueOf(tunit);
         divBy = WritableUtils.readVLong(input);
     }
 
     @Override
     public void write(DataOutput output) throws IOException {
         super.write(output);
+        WritableUtils.writeString(output, timeUnit.name());
         WritableUtils.writeVLong(output, divBy);
     }
{code}
You have to be careful about serialization changes, as it breaks our b/w 
compatibility. Looks to me like perhaps this change isn't even necessary? If it 
is, then you'll need to play tricks such as writing the divBy as a negative 
number and then only conditionally reading the timeUnit in that case. You'd 
test by running an old pre 4.7 client against a new 4.7 server and using ROUND 
in the WHERE clause.

> 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, PHOENIX-2433.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)

Reply via email to