Skip to content

Commit ee1c647

Browse files
author
Julien Ruaux
committed
test: Increased RediSearch aggregate max results config
1 parent ba86876 commit ee1c647

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

pom.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<github.owner>redis-field-engineering</github.owner>
2727
<github.repo>redis-sql-trino</github.repo>
2828

29-
<lettucemod.version>3.2.0</lettucemod.version>
29+
<lettucemod.version>3.2.1</lettucemod.version>
3030
<lettuce.version>6.2.2.RELEASE</lettuce.version>
31-
<testcontainers-redis.version>1.6.2</testcontainers-redis.version>
31+
<testcontainers-redis.version>1.6.3</testcontainers-redis.version>
3232
<ulid.version>5.1.0</ulid.version>
3333

3434
<air.check.skip-license>true</air.check.skip-license>
@@ -364,12 +364,6 @@
364364
</exclusions>
365365
</dependency>
366366

367-
<dependency>
368-
<groupId>javax.servlet</groupId>
369-
<artifactId>javax.servlet-api</artifactId>
370-
<scope>test</scope>
371-
</dependency>
372-
373367
<dependency>
374368
<groupId>org.assertj</groupId>
375369
<artifactId>assertj-core</artifactId>

src/main/java/com/redis/trino/RediSearchMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session,
246246
Collection<ComputedStatistics> computedStatistics) {
247247
return Optional.empty();
248248
}
249-
249+
250250
@Override
251251
public RediSearchColumnHandle getDeleteRowIdColumnHandle(ConnectorSession session,
252252
ConnectorTableHandle tableHandle) {

src/main/java/com/redis/trino/RediSearchSession.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@
5151
import com.google.common.util.concurrent.UncheckedExecutionException;
5252
import com.redis.lettucemod.api.StatefulRedisModulesConnection;
5353
import com.redis.lettucemod.search.AggregateOperation;
54+
import com.redis.lettucemod.search.AggregateOptions;
5455
import com.redis.lettucemod.search.AggregateWithCursorResults;
5556
import com.redis.lettucemod.search.CreateOptions;
57+
import com.redis.lettucemod.search.CursorOptions;
5658
import com.redis.lettucemod.search.Document;
5759
import com.redis.lettucemod.search.Field;
5860
import com.redis.lettucemod.search.Group;
@@ -309,10 +311,13 @@ public SearchResults<String, String> search(RediSearchTableHandle tableHandle, S
309311
public AggregateWithCursorResults<String> aggregate(RediSearchTableHandle table) {
310312
Aggregation aggregation = translator.aggregate(table);
311313
log.info("Running %s", aggregation);
312-
AggregateWithCursorResults<String> results = connection.sync().ftAggregate(aggregation.getIndex(),
313-
aggregation.getQuery(), aggregation.getCursorOptions(), aggregation.getOptions());
314-
List<AggregateOperation<?, ?>> groupBys = aggregation.getOptions().getOperations().stream()
315-
.filter(o -> o.getType() == AggregateOperation.Type.GROUP).collect(Collectors.toList());
314+
String index = aggregation.getIndex();
315+
String query = aggregation.getQuery();
316+
CursorOptions cursor = aggregation.getCursorOptions();
317+
AggregateOptions<String, String> options = aggregation.getOptions();
318+
AggregateWithCursorResults<String> results = connection.sync().ftAggregate(index, query, cursor, options);
319+
List<AggregateOperation<String, String>> groupBys = aggregation.getOptions().getOperations().stream()
320+
.filter(this::isGroupOperation).collect(Collectors.toList());
316321
if (results.isEmpty() && !groupBys.isEmpty()) {
317322
Group groupBy = (Group) groupBys.get(0);
318323
Optional<String> as = groupBy.getReducers()[0].getAs();
@@ -325,6 +330,10 @@ public AggregateWithCursorResults<String> aggregate(RediSearchTableHandle table)
325330
return results;
326331
}
327332

333+
private boolean isGroupOperation(AggregateOperation<String, String> operation) {
334+
return operation.getType() == AggregateOperation.Type.GROUP;
335+
}
336+
328337
public AggregateWithCursorResults<String> cursorRead(RediSearchTableHandle tableHandle, long cursor) {
329338
String index = index(tableHandle.getSchemaTableName());
330339
if (config.getCursorCount() > 0) {

src/main/java/com/redis/trino/RediSearchTranslator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,12 @@ public Search build() {
222222

223223
}
224224

225-
public Search search(RediSearchTableHandle tableHandle, String[] columnNames) {
226-
String index = index(tableHandle);
227-
String query = queryBuilder.buildQuery(tableHandle.getConstraint(), tableHandle.getWildcards());
225+
public Search search(RediSearchTableHandle table, String[] columnNames) {
226+
String index = index(table);
227+
String query = queryBuilder.buildQuery(table.getConstraint(), table.getWildcards());
228228
Builder<String, String> options = SearchOptions.builder();
229229
options.withScores(true);
230-
options.limit(Limit.offset(0).num(limit(tableHandle)));
230+
options.limit(Limit.offset(0).num(limit(table)));
231231
options.returnFields(columnNames);
232232
return Search.builder().index(index).query(query).options(options.build()).build();
233233
}

src/test/java/com/redis/trino/RediSearchServer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public class RediSearchServer implements Closeable {
1212

1313
public RediSearchServer() {
1414
this.dockerContainer = new RedisStackContainer(
15-
RedisStackContainer.DEFAULT_IMAGE_NAME.withTag(RedisStackContainer.DEFAULT_TAG));
15+
RedisStackContainer.DEFAULT_IMAGE_NAME.withTag(RedisStackContainer.DEFAULT_TAG))
16+
.withEnv("REDISEARCH_ARGS", "MAXAGGREGATERESULTS 1000000");
1617
this.dockerContainer.start();
1718
this.context = new RedisTestContext(dockerContainer);
1819
}

src/test/java/com/redis/trino/TestRediSearchConnectorSmokeTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public class TestRediSearchConnectorSmokeTest extends BaseConnectorSmokeTest {
3939

4040
private RediSearchServer redisearch;
4141

42+
@Override
43+
protected QueryRunner createQueryRunner() throws Exception {
44+
redisearch = new RediSearchServer();
45+
return RediSearchQueryRunner.createRediSearchQueryRunner(redisearch, CUSTOMER, NATION, ORDERS, REGION);
46+
}
47+
4248
private void populateBeers() throws IOException, InterruptedException {
4349
Beers.populateIndex(redisearch.getTestContext().getConnection());
4450
}
@@ -103,12 +109,6 @@ protected void assertQuery(String sql) {
103109
super.assertQuery(sql);
104110
}
105111

106-
@Override
107-
protected QueryRunner createQueryRunner() throws Exception {
108-
redisearch = new RediSearchServer();
109-
return RediSearchQueryRunner.createRediSearchQueryRunner(redisearch, CUSTOMER, NATION, ORDERS, REGION);
110-
}
111-
112112
@Test
113113
public void testRediSearchFields() throws IOException, InterruptedException {
114114
populateBeers();

0 commit comments

Comments
 (0)