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

Serhiy Bilousov commented on PHOENIX-1704:
------------------------------------------

I have a question (mostly for my education) regarding 

{code:title=YearFunction.java|borderStyle=solid}
// Some comments here
    public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
        Expression expression = getChildExpression();
        if (!expression.evaluate(tuple, ptr)) {
            return false;
        }
        if ( ptr.getLength() == 0) {
            return true; //means null
        }
        long dateTime = expression.getDataType().getCodec().decodeLong(ptr, 
expression.getSortOrder());
        DateTime dt = new DateTime(dateTime);
        int year = dt.getYear();
        PDataType returnType = getDataType();
        byte[] byteValue = new byte[returnType.getByteSize()];
        returnType.getCodec().encodeInt(year, byteValue, 0);
        ptr.set(byteValue);
        return true;
    }
{code}

Long is 8 bytes but [UNSIGNED_TIMESTAMP 
Type|http://phoenix.apache.org/language/datatypes.html#unsigned_timestamp_type] 
is 12 bytes.
Will it possibly can cause some issues with [UNSIGNED_TIMESTAMP 
Type|http://phoenix.apache.org/language/datatypes.html#unsigned_timestamp_type]?
 Do we actually need to test real [UNSIGNED_TIMESTAMP 
Type|http://phoenix.apache.org/language/datatypes.html#unsigned_timestamp_type] 
(with nanos) ?



> Add year() built-in function
> ----------------------------
>
>                 Key: PHOENIX-1704
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1704
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Alicia Ying Shu
>            Assignee: Alicia Ying Shu
>             Fix For: 4.4
>
>         Attachments: Phoenix-1704-v1.patch, Phoenix-1704-v2.patch, 
> Phoenix-1704-v3.patch, Phoenix-1704-v4.patch, Phoenix-1704-v5.patch
>
>
> Support Year() with date and timestamp.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to