use of org.apache.calcite.test.CalciteAssert in project calcite by apache.
the class GeodeZipsTest method testWhereWithOrForLargeValueList.
@Test
void testWhereWithOrForLargeValueList() throws Exception {
Cache cache = POLICY.cache();
QueryService queryService = cache.getQueryService();
Query query = queryService.newQuery("select state as state from /zips");
SelectResults results = (SelectResults) query.execute();
Set<String> stateList = (Set<String>) results.stream().map(s -> {
StructImpl struct = (StructImpl) s;
return struct.get("state");
}).collect(Collectors.toCollection(TreeSet::new));
String stateListPredicate = stateList.stream().map(s -> String.format(Locale.ROOT, "state = '%s'", s)).collect(Collectors.joining(" OR "));
String stateListStr = "'" + String.join("', '", stateList) + "'";
String queryToBeExecuted = "SELECT state as state FROM view WHERE " + stateListPredicate;
String expectedQuery = "SELECT state AS state FROM /zips WHERE state " + "IN SET(" + stateListStr + ")";
calciteAssert().query(queryToBeExecuted).returnsCount(149).queryContains(GeodeAssertions.query(expectedQuery));
}
Aggregations