Github user JamesRTaylor commented on a diff in the pull request:
https://github.com/apache/incubator-phoenix/pull/34#discussion_r13060084
--- Diff:
phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixHBaseLoaderIT.java ---
@@ -423,6 +423,91 @@ public void testLoadAndStore() throws Exception {
assertEquals(270, rs.getInt("MAX_SAL"));
}
+ /**
+ * Test for sequences.
+ * @throws Exception
+ */
+ @Test
+ public void testDataForSQLQueryWithSequences() throws Exception {
+
+ //create the table
+ String ddl = "CREATE TABLE " + TABLE_FULL_NAME
+ + " (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR, AGE
INTEGER) ";
+
+ conn.createStatement().execute(ddl);
+
+ String sequenceDdl = "CREATE SEQUENCE my_sequence";
+
+ conn.createStatement().execute(sequenceDdl);
+
+ //prepare data with 10 rows having age 25 and the other 30.
+ final String dml = "UPSERT INTO " + TABLE_FULL_NAME + "
VALUES(?,?,?)";
+ PreparedStatement stmt = conn.prepareStatement(dml);
+ int rows = 20;
+ for(int i = 0 ; i < rows; i++) {
+ stmt.setInt(1, i);
+ stmt.setString(2, "a"+i);
+ stmt.setInt(3, (i % 2 == 0) ? 25 : 30);
+ stmt.execute();
+ }
+ conn.commit();
+
+ //sql query
+ final String sqlQuery = " SELECT NEXT VALUE FOR my_sequence AS
my_seq,ID,NAME,AGE FROM " + TABLE_FULL_NAME + " WHERE AGE > 25";
--- End diff --
Nice! Does this pass now? I see your code below seems to be doing the right
thing wrt creating a SequeunceResultIterator when necessary.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---