[
https://issues.apache.org/jira/browse/PHOENIX-1756?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14372401#comment-14372401
]
James Taylor commented on PHOENIX-1756:
---------------------------------------
YOu'll need to encode as int instead of long and cast the % you're doing to an
int, like this:
{code}
+ @Override
+ 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());
+ int sec = (int)((dateTime/1000) % 60);
+ PDataType returnType = getDataType();
+ byte[] byteValue = new byte[returnType.getByteSize()];
+ returnType.getCodec().encodeInt(sec, byteValue, 0);
+ ptr.set(byteValue);
+ return true;
+ }
{code}
> Add Month() and Second() buildin functions
> ------------------------------------------
>
> Key: PHOENIX-1756
> URL: https://issues.apache.org/jira/browse/PHOENIX-1756
> Project: Phoenix
> Issue Type: Improvement
> Reporter: Alicia Ying Shu
> Assignee: Alicia Ying Shu
> Attachments: Phoenix-1756-v1.patch, Phoenix-1756.patch
>
>
> From Oracle doc: Month(date) and Second(date). Very similar to Year(date)
> buildin.
> MONTH(date) An integer from 1 to 12 representing the month
> component of date
> SECOND(time) An integer from 0 to 59 representing the second
> component of time
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)