[ https://issues.apache.org/jira/browse/PHOENIX-1002?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14056247#comment-14056247 ]
James Taylor commented on PHOENIX-1002: --------------------------------------- Nice work, [~kbuzsaki]. Thanks for the patch. The type checking for multiply and divide are more than you need, as those operators need to handle differing types and type coercian depending on the types that are used. For modulus, we can just require both the lhs and rhs to be coercible to PDataType.LONG. You can do this type checking inside the create method you have for your ModulusFunction throwing a TypeMismatchException.newException(PDataType.LONG, child.getDataType(), node.toString()) if !PDataType.LONG.isCoercibleTo(child.getDataType() {code} + @Override + public Expression visitLeave(ModulusParseNode node, List<Expression> children) throws SQLException { + return visitLeave(node, children, null, new ArithmeticExpressionFactory() { + @Override + public Expression create(ArithmeticParseNode node, List<Expression> children) throws SQLException { + return new ModulusFunction(children); + } + }); + } + {code} > 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, PHOENIX-1002_2.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)