Skip to content

Commit 969a7ef

Browse files
committed
Add test with nested IN filters with CSI.
1 parent b454a52 commit 969a7ef

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteQueryEngineTest.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,21 @@ public void queryWithMultipleInsOnTheSameField() throws Exception {
327327

328328
DocumentSet result3 =
329329
expectOptimizedCollectionScan(() -> runQuery(query3, SnapshotVersion.NONE));
330-
assertEquals(docSet(query2.comparator(), doc3, doc6), result3);
330+
assertEquals(docSet(query3.comparator(), doc3, doc6), result3);
331+
332+
// Nested composite filter: (a IN [0,1,2,3] && (a IN [0,2] || (b>1 && a IN [1,3]))
333+
Query query4 =
334+
query("coll")
335+
.filter(
336+
andFilters(
337+
filter("a", "in", Arrays.asList(0, 1, 2, 3)),
338+
orFilters(
339+
filter("a", "in", Arrays.asList(0, 2)),
340+
andFilters(filter("b", ">=", 1), filter("a", "in", Arrays.asList(1, 3))))));
341+
342+
DocumentSet result4 =
343+
expectOptimizedCollectionScan(() -> runQuery(query4, SnapshotVersion.NONE));
344+
assertEquals(docSet(query4.comparator(), doc3, doc4), result4);
331345
}
332346

333347
@Test
@@ -366,5 +380,21 @@ public void queryWithMultipleInsOnDifferentFields() throws Exception {
366380
DocumentSet result2 =
367381
expectOptimizedCollectionScan(() -> runQuery(query2, SnapshotVersion.NONE));
368382
assertEquals(docSet(query2.comparator(), doc3), result2);
383+
384+
// Nested composite filter: (b in [0,3] && (b IN [1] || (b in [2,3] && a IN [1,3]))
385+
Query query3 =
386+
query("coll")
387+
.filter(
388+
andFilters(
389+
filter("b", "in", Arrays.asList(0, 3)),
390+
orFilters(
391+
filter("b", "in", Arrays.asList(1)),
392+
andFilters(
393+
filter("b", "in", Arrays.asList(2, 3)),
394+
filter("a", "in", Arrays.asList(1, 3))))));
395+
396+
DocumentSet result3 =
397+
expectOptimizedCollectionScan(() -> runQuery(query3, SnapshotVersion.NONE));
398+
assertEquals(docSet(query3.comparator(), doc4), result3);
369399
}
370400
}

0 commit comments

Comments
 (0)