Skip to content

Commit

Permalink
Add test method for empty pages
Browse files Browse the repository at this point in the history
Adds a test method to SimpleStatementCcmIT that checks
if SimpleStatement with page size 1 correctly fetches all rows.
Covers issue #254.
  • Loading branch information
Bouncheck authored and Piotr Grabowski committed Jan 15, 2024
1 parent b97a4de commit a04fadf
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,31 @@ public void should_use_page_size() {
// Should have only fetched 10 (page size) rows.
assertThat(result.remaining()).isEqualTo(10);
}

@Test
public void should_not_fail_on_empty_pages() {
SESSION_RULE
.session()
.execute(
"CREATE KEYSPACE IF NOT EXISTS ks WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1}");

SESSION_RULE
.session()
.execute("CREATE TABLE IF NOT EXISTS ks.t (pk int, ck int, v int, PRIMARY KEY(pk, ck))");

for (int i = 0; i < 50; i++) {
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 15);
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", i, i, 32);
}

SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 8, 8, 14);
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 11, 11, 14);
SESSION_RULE.session().execute("INSERT INTO ks.t(pk, ck, v) VALUES (?, ?, ?)", 14, 14, 14);

SimpleStatement st =
SimpleStatement.newInstance("SELECT * FROM ks.t WHERE v = 14 ALLOW FILTERING");
st = st.setPageSize(1);
List<Row> allRows = SESSION_RULE.session().execute(st).all();
assertThat(allRows.size()).isEqualTo(3);
}
}

0 comments on commit a04fadf

Please sign in to comment.