Skip to content

Commit c34d6dc

Browse files
author
julien
committed
Added limit pushdown tests
1 parent eec8035 commit c34d6dc

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

subprojects/trino-redisearch/src/main/java/com/redis/trino/RediSearchPageSource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public RediSearchPageSource(RediSearchSession rediSearchSession, RediSearchTable
6363
List<RediSearchColumnHandle> columns) {
6464
this.columnNames = columns.stream().map(RediSearchColumnHandle::getName).collect(toList());
6565
this.columnTypes = columns.stream().map(RediSearchColumnHandle::getType).collect(toList());
66-
this.cursor = rediSearchSession.execute(tableHandle, columns).iterator();
66+
this.cursor = rediSearchSession.execute(tableHandle).iterator();
6767
this.currentDoc = null;
6868
this.pageBuilder = new PageBuilder(columnTypes);
6969
}
@@ -117,7 +117,6 @@ private void appendTo(Type type, String value, BlockBuilder output) {
117117
output.appendNull();
118118
return;
119119
}
120-
121120
Class<?> javaType = type.getJavaType();
122121
if (javaType == boolean.class) {
123122
type.writeBoolean(output, Boolean.parseBoolean(value));

subprojects/trino-redisearch/src/main/java/com/redis/trino/RediSearchSession.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ private Type columnType(TypeSignature typeSignature) {
189189
return typeManager.fromSqlType(typeSignature.toString());
190190
}
191191

192-
public SearchResults<String, String> execute(RediSearchTableHandle tableHandle,
193-
List<RediSearchColumnHandle> columns) {
192+
public SearchResults<String, String> execute(RediSearchTableHandle tableHandle) {
194193
String index = tableHandle.getSchemaTableName().getTableName();
195194
String query = RediSearchQueryBuilder.buildQuery(tableHandle.getConstraint());
196195
Builder<String, String> options = SearchOptions.<String, String>builder();

subprojects/trino-redisearch/src/main/java/com/redis/trino/RediSearchTableHandle.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package com.redis.trino;
22

3+
import static java.util.Objects.requireNonNull;
4+
5+
import java.util.Objects;
6+
import java.util.OptionalInt;
7+
38
import com.fasterxml.jackson.annotation.JsonCreator;
49
import com.fasterxml.jackson.annotation.JsonProperty;
10+
511
import io.trino.spi.connector.ColumnHandle;
612
import io.trino.spi.connector.ConnectorTableHandle;
713
import io.trino.spi.connector.SchemaTableName;
814
import io.trino.spi.predicate.TupleDomain;
915

10-
import java.util.Objects;
11-
import java.util.OptionalInt;
12-
13-
import static java.util.Objects.requireNonNull;
14-
1516
public class RediSearchTableHandle implements ConnectorTableHandle {
17+
1618
private final SchemaTableName schemaTableName;
1719
private final TupleDomain<ColumnHandle> constraint;
1820
private final OptionalInt limit;

subprojects/trino-redisearch/src/test/java/com/redis/trino/TestRediSearchConnectorTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior) {
8181
return true;
8282

8383
case SUPPORTS_LIMIT_PUSHDOWN:
84-
return false;
84+
return true;
8585

8686
case SUPPORTS_PREDICATE_PUSHDOWN_WITH_VARCHAR_INEQUALITY:
8787
return false;
@@ -102,14 +102,20 @@ protected TestTable createTableWithDefaultColumns() {
102102
throw new SkipException("test disabled for RediSearch");
103103
}
104104

105-
@Override
106-
public void testLimit() {
107-
// ignore
108-
}
109-
110-
@Override
105+
@Test
111106
public void testLimitMax() {
112-
// ignore
107+
int maxLimit = 1000000;
108+
// max int
109+
assertQuery("SELECT orderkey FROM orders LIMIT " + maxLimit);
110+
assertQuery("SELECT orderkey FROM orders ORDER BY orderkey LIMIT " + maxLimit);
111+
112+
// max long; a connector may attempt a pushdown while remote system may not
113+
// accept such high limit values
114+
assertQuery("SELECT nationkey FROM nation LIMIT " + maxLimit, "SELECT nationkey FROM nation");
115+
// Currently this is not supported but once it's supported, it should be tested
116+
// with connectors as well
117+
assertQueryFails("SELECT nationkey FROM nation ORDER BY nationkey LIMIT " + Long.MAX_VALUE,
118+
"ORDER BY LIMIT > 2147483647 is not supported");
113119
}
114120

115121
@Override

0 commit comments

Comments
 (0)