[ https://issues.apache.org/jira/browse/PHOENIX-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14056217#comment-14056217 ]
James Taylor commented on PHOENIX-1016: --------------------------------------- Thanks for the patch, [~tdsilva]. It's looking very good. We need to maintain backward compatibility, though. Here are some ideas: How about making the following two changes to maintain backward compatibility for startWith? 1. Store minValue and maxValue as null in CreateSequenceStatement if they're not specified. {code} + protected CreateSequenceStatement(TableName sequenceName, + ParseNode startsWith, ParseNode incrementBy, ParseNode cacheSize, + ParseNode minValue, ParseNode maxValue, boolean cycle, + boolean ifNotExists, int bindCount) { + this.sequenceName = sequenceName; + this.minValue = minValue == null ? new LiteralParseNode(Long.MIN_VALUE) : minValue; + this.maxValue = maxValue == null ? new LiteralParseNode(Long.MAX_VALUE) : maxValue; {code} 2. Initialize startsWithValue in CreateSequenceCompiler to 1 if minValueNode is null and incrementBy is positive or maxValueNode is null and incrementBy is negative? {code} + if (startsWithNode == null) { + startsWithValue = incrementBy > 0 ? minValue : maxValue; + } else { {code} Can you tell me more about the other change (i.e. why you need to store the current value instead of the next value)? This one may be ok, as wouldn't existing sequences just skip a sequence value (which is fine)? Or what would happen? If they'd return the same value again, that'd be a problem. If we had to, we could have a conversion script to increment all sequences, but that'd be a bit of a pain so I'd like to avoid it if possible. > Support MINVALUE, MAXVALUE, and CYCLE options in CREATE SEQUENCE > ---------------------------------------------------------------- > > Key: PHOENIX-1016 > URL: https://issues.apache.org/jira/browse/PHOENIX-1016 > Project: Phoenix > Issue Type: Bug > Reporter: James Taylor > Assignee: Thomas D'Silva > Attachments: PHOENIX-1016.3.0.patch, PHOENIX-1016.patch > > > We currently don't support MINVALUE, MAXVALUE, and CYCLE options in CREATE > SEQUENCE, but we should. See > http://msdn.microsoft.com/en-us/library/ff878091.aspx for the syntax. > I believe MINVALUE applies if the INCREMENT is negative while MAXVALUE > applies otherwise. If the value of a sequence goes beyond MINVALUE/MAXVALUE, > then: > - if CYCLE is true, then the sequence value should start again at the START > WITH value (or the MINVALUE if specified too? Not sure about this). > - if CYCLE is false, then an exception should be thrown. > To implement this: > - make the grammar changes in PhoenixSQL.g > - add member variables for MINVALUE, MAXVALUE, and CYCLE to > CreateSequenceStatement > - add the appropriate error checking and handle bind variables for these new > options in CreateSequenceCompiler > - modify the MetaDataClient.createSequence() call by passing along these new > parameters. > - same for ConnectionQueryServices.createSequence() call > - same for Sequence.createSequence(). > - pass along these parameters as new KeyValues in the Append that constitutes > the RPC call > - act on these in the SequenceRegionObserver coprocessor as indicated above. -- This message was sent by Atlassian JIRA (v6.2#6252)