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

James Taylor commented on PHOENIX-1002:
---------------------------------------

Thanks for the patch, [~kbuzsaki]. Same comment as with PHOENIX-1055 wrt going 
through codec. Also, would you mind filing a separate JIRA for this (i.e. 
support for a MOD built-in)? I think this is a good short term solution for 
[~tdsilva]. 

Would you also be up for tackling support the mod operator? You start with 
modifying the grammar (PhoenixSQL.g), adding the % operator based on the 
precedence (I think it's the same precedence as * and /)? Then you'd add a new 
ParseNode class followed by new visitor methods in ParseNodeVisitor. Then you 
implement them following the pattern of the others - the important one to 
implement is in ExpressionCompiler. You can likely reuse/copy/paste from the 
other implementations. It's a bit simpler than the other ones, b/c you don't 
have to support all the various types (i.e. double, float, decimal), but can 
just use a long. Might be able to just create a new ModulusFunction from 
ExpressionCompiler to reuse your built-in.

> Add support for % operator
> --------------------------
>
>                 Key: PHOENIX-1002
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1002
>             Project: Phoenix
>          Issue Type: New Feature
>            Reporter: Thomas D'Silva
>         Attachments: PHOENIX-1002.patch
>
>
> Supporting the % operator would allow using sequences to generate IDs that 
> are less than a maximum number. 
> CREATE SEQUENCE foo.bar
> SELECT ((NEXT VALUE FOR foo.bar)%1000)



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to