[
https://issues.apache.org/jira/browse/PHOENIX-3437?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Lomore updated PHOENIX-3437:
---------------------------------
Description:
1. The use of negative values in CREATE SEQUENCE statements is not currently
supported.
{{CREATE SEQUENCE seq START WITH 2 INCREMENT BY -2}}
2. Exception throwing - resolving sequences is now handled in PhoenixSchema. We
don't distinguish between a sequence and a table at this level. Hence we throw
a TableNotFoundException rather than a SequenceNotFoundException when sequences
cannot be found. This would be difficult to fix, so adjusting test cases seems
like the best course.
3. Another issue that overhangs many of the cases is with the SYSTEM keyword -
this is being handled in PHOENIX-3468
was:
Calcite currently returns 0 for a sequence that has CURRENT VALUE called on it
before NEXT VALUE is ever called.
To demonstrate, this sample integration test passes.
{code}
connection.createStatement().execute("CREATE SEQUENCE IF NOT EXISTS
seq0 START WITH 1 INCREMENT BY 1");
start(false, 1000f).sql("select CURRENT VALUE FOR seq0, c0 from (values
(1), (1)) as t(c0)")
.explainIs("PhoenixToEnumerableConverter\n" +
"
PhoenixClientProject(EXPR$0=[CURRENT_VALUE('\"SEQ0\"')], C0=[$0])\n" +
" PhoenixValues(tuples=[[{ 1 }, { 1 }]])\n")
.resultIs(0, new Object[][]{
{0L, 1},
{0L, 1}})
.close();
{code}
But Phoenix's intended behaviour is for this to throw an exception.
{{SequenceIT.java}}
{code}
@Test
public void testCurrentValueFor() throws Exception {
ResultSet rs;
nextConnection();
conn.createStatement().execute("CREATE SEQUENCE used.nowhere START WITH
2 INCREMENT BY 4");
nextConnection();
try {
rs = conn.createStatement().executeQuery("SELECT CURRENT VALUE FOR
used.nowhere FROM SYSTEM.\"SEQUENCE\"");
rs.next();
fail();
} catch (SQLException e) {
assertEquals(SQLExceptionCode.CANNOT_CALL_CURRENT_BEFORE_NEXT_VALUE.getErrorCode(),
e.getErrorCode());
assertTrue(e.getNextException()==null);
}
rs = conn.createStatement().executeQuery("SELECT NEXT VALUE FOR
used.nowhere FROM SYSTEM.\"SEQUENCE\"");
assertTrue(rs.next());
assertEquals(2, rs.getInt(1));
rs = conn.createStatement().executeQuery("SELECT CURRENT VALUE FOR
used.nowhere FROM SYSTEM.\"SEQUENCE\"");
assertTrue(rs.next());
assertEquals(2, rs.getInt(1));
}
{code}
Summary: Resolve sequence incompatibilities in phoenix-calcite (was:
Calcite allows CURRENT VALUE to be called on a sequence which has not yet been
used)
> Resolve sequence incompatibilities in phoenix-calcite
> -----------------------------------------------------
>
> Key: PHOENIX-3437
> URL: https://issues.apache.org/jira/browse/PHOENIX-3437
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: Eric Lomore
> Assignee: Eric Lomore
>
> 1. The use of negative values in CREATE SEQUENCE statements is not currently
> supported.
> {{CREATE SEQUENCE seq START WITH 2 INCREMENT BY -2}}
> 2. Exception throwing - resolving sequences is now handled in PhoenixSchema.
> We don't distinguish between a sequence and a table at this level. Hence we
> throw a TableNotFoundException rather than a SequenceNotFoundException when
> sequences cannot be found. This would be difficult to fix, so adjusting test
> cases seems like the best course.
> 3. Another issue that overhangs many of the cases is with the SYSTEM keyword
> - this is being handled in PHOENIX-3468
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)