Skip to content

Commit 256dda7

Browse files
committed
Temparary revert old behaviour
1 parent 59e1a83 commit 256dda7

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

query/src/main/java/tech/ydb/query/tools/QueryReader.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,14 @@ public int getRowCount() {
176176

177177
@Override
178178
public void setRowIndex(int index) {
179-
if (index < 0 || index >= rowsCount) {
180-
throw new IndexOutOfBoundsException(String.format("Index %s out of bounds for length %s",
181-
index, rowsCount));
182-
}
179+
// TODO: Enable after JDBC fixing
180+
// if (index < 0 || index >= rowsCount) {
181+
// throw new IndexOutOfBoundsException(String.format("Index %s out of bounds for length %s",
182+
// index, rowsCount));
183+
// }
184+
// int currentIdx = index;
185+
int currentIdx = Math.max(0, index);
183186
partIndex = 0;
184-
int currentIdx = index;
185187
while (partIndex < parts.length) {
186188
int readerRows = parts[partIndex].getRowCount();
187189
if (currentIdx < readerRows) {
@@ -193,6 +195,11 @@ public void setRowIndex(int index) {
193195
partIndex++;
194196
}
195197

198+
// TODO: remove after JDBC fixing
199+
if (partIndex >= parts.length) {
200+
partIndex = parts.length - 1;
201+
}
202+
196203
for (int partStep = partIndex + 1; partStep < parts.length; partStep++) {
197204
parts[partStep].setRowIndex(0);
198205
}

query/src/test/java/tech/ydb/query/tools/QueryReaderTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,16 @@ public void compositeResultSetTest() {
142142
rsr.setRowIndex(5);
143143
Assert.assertEquals(1, readAll(rsr, 5));
144144

145-
IndexOutOfBoundsException ex1 = Assert.assertThrows(IndexOutOfBoundsException.class, () -> rsr.setRowIndex(6));
146-
Assert.assertEquals("Index 6 out of bounds for length 6", ex1.getMessage());
145+
rsr.setRowIndex(-1);
146+
Assert.assertEquals(6, readAll(rsr, 0));
147147

148-
IndexOutOfBoundsException ex2 = Assert.assertThrows(IndexOutOfBoundsException.class, () -> rsr.setRowIndex(-1));
149-
Assert.assertEquals("Index -1 out of bounds for length 6", ex2.getMessage());
148+
rsr.setRowIndex(6);
149+
Assert.assertEquals(0, readAll(rsr, 0));
150+
// IndexOutOfBoundsException ex1 = Assert.assertThrows(IndexOutOfBoundsException.class, () -> rsr.setRowIndex(6));
151+
// Assert.assertEquals("Index 6 out of bounds for length 6", ex1.getMessage());
152+
//
153+
// IndexOutOfBoundsException ex2 = Assert.assertThrows(IndexOutOfBoundsException.class, () -> rsr.setRowIndex(-1));
154+
// Assert.assertEquals("Index -1 out of bounds for length 6", ex2.getMessage());
150155
}
151156

152157
private int readAll(ResultSetReader rsr, int startKey) {

0 commit comments

Comments
 (0)