Skip to content

Commit f2fbc50

Browse files
committed
fix up aggregate-index-tests-count-empty.yamsql to work better in mixed-mode tests
1 parent 11494c3 commit f2fbc50

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

yaml-tests/src/main/java/com/apple/foundationdb/relational/yamltests/command/QueryExecutor.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
import com.apple.foundationdb.relational.api.RelationalResultSetMetaData;
2727
import com.apple.foundationdb.relational.api.exceptions.RelationalException;
2828
import com.apple.foundationdb.relational.api.metrics.RelationalMetric;
29+
import com.apple.foundationdb.relational.recordlayer.ContinuationImpl;
2930
import com.apple.foundationdb.relational.yamltests.AggregateResultSet;
3031
import com.apple.foundationdb.relational.yamltests.YamlConnection;
3132
import com.apple.foundationdb.relational.yamltests.command.parameterinjection.Parameter;
33+
import com.apple.foundationdb.relational.yamltests.server.SemanticVersion;
3234
import org.apache.logging.log4j.LogManager;
3335
import org.apache.logging.log4j.Logger;
3436
import org.junit.jupiter.api.Assertions;
@@ -52,6 +54,7 @@ public class QueryExecutor {
5254
private static final Logger logger = LogManager.getLogger(QueryExecutor.class);
5355
private static final int FORCED_MAX_ROWS = 1; // The maxRows number to use when we are forcing it on the test
5456
private static final int MAX_CONTINUATIONS_ALLOWED = 100;
57+
private static final SemanticVersion STRICT_ASSERTIONS_CUTOFF = SemanticVersion.parse("4.1.4.0");
5558

5659
@Nonnull
5760
private final String query;
@@ -106,8 +109,10 @@ public Continuation execute(@Nonnull YamlConnection connection, @Nullable Contin
106109
return executeQuery(connection, config, currentQuery, checkCache, maxRows);
107110
} else if (continuation.atBeginning()) {
108111
// Continuation cannot be at beginning if it was returned from a query
109-
reportTestFailure("Received continuation shouldn't be at beginning");
110-
return null;
112+
if (STRICT_ASSERTIONS_CUTOFF.lesserVersions(connection.getVersions()).isEmpty()) {
113+
reportTestFailure("Received continuation shouldn't be at beginning");
114+
}
115+
return ContinuationImpl.END;
111116
} else {
112117
// Have a continuation - continue
113118
return executeContinuation(connection, continuation, config, maxRows);
@@ -246,7 +251,11 @@ private Object executeStatementWithForcedContinuations(final @Nonnull Statement
246251
int count = 0;
247252
while (!continuation.atEnd()) {
248253
if (continuation.atBeginning()) {
249-
reportTestFailure("Received continuation shouldn't be at beginning");
254+
if (STRICT_ASSERTIONS_CUTOFF.lesserVersions(connection.getVersions()).isEmpty()) {
255+
reportTestFailure("Received continuation shouldn't be at beginning");
256+
}
257+
continuation = ContinuationImpl.END;
258+
break;
250259
}
251260
try (var s2 = prepareContinuationStatement(connection, continuation, FORCED_MAX_ROWS)) {
252261
resultSet = (RelationalResultSet)executeStatement(s2, null);
@@ -256,7 +265,9 @@ private Object executeStatementWithForcedContinuations(final @Nonnull Statement
256265
results.add(resultSet);
257266
} else {
258267
// We assume that the last result is empty because of the maxRows:1
259-
Assertions.assertFalse(hasNext);
268+
if (STRICT_ASSERTIONS_CUTOFF.lesserVersions(connection.getVersions()).isEmpty()) {
269+
Assertions.assertFalse(hasNext, "End result should not have any associated value when maxRows is 1");
270+
}
260271
}
261272
}
262273
count += 1; // PMD failure for ++

yaml-tests/src/test/resources/aggregate-index-tests-count-empty.yamsql

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ test_block:
3131
name: agg-index-tests-count-empty
3232
tests:
3333
-
34-
# DONE: 4.1 Triage: [No Fix Necessary] failing when running against 4.0.559.6 (result mismatch)
3534
- query: select count(*) from t1
3635
- explain: "AISCAN(MV1 <,> BY_GROUP -> [_0: VALUE:[0]]) | MAP (_ AS _0) | ON EMPTY NULL | MAP (coalesce_long(_._0._0, promote(0l AS LONG)) AS _0)"
3736
- initialVersionLessThan: 4.0.561.0
@@ -43,8 +42,9 @@ test_block:
4342
- explain: "AISCAN(MV2 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) | MAP (_._1 AS _0)"
4443
- result: []
4544
-
46-
# DONE: 4.1 Triage: failing when running against 4.0.559.6 (result mismatch)
4745
- query: select count(col1) from t1
46+
# FORCE_CONTINUATIONS does not work with versions before 4.1.4.0 due to limits not enforced "ON EMPTY" prior to https://github.com/FoundationDB/fdb-record-layer/pull/3092
47+
# Can remove once we no longer want to test versions prior to 4.1.4.0
4848
- explain: "AISCAN(MV3 <,> BY_GROUP -> [_0: VALUE:[0]]) | MAP (_ AS _0) | ON EMPTY NULL | MAP (coalesce_long(_._0._0, promote(0l AS LONG)) AS _0)"
4949
- initialVersionLessThan: 4.0.561.0
5050
- result: []
@@ -60,17 +60,15 @@ test_block:
6060
-
6161
- query: select count(*) from t2
6262
- explain: "ISCAN(MV5 <,>) | MAP (_ AS _0) | AGG (count_star(*) AS _0) | ON EMPTY NULL | MAP (coalesce_long(_._0._0, promote(0l AS LONG)) AS _0)"
63-
# 4.1 Triage: failing when running against 4.0.559.6 (Received continuation shouldn't be at beginning)
64-
# - result: [{0}]
63+
- result: [{0}]
6564
-
6665
- query: select count(*) from t2 group by col2
6766
- explain: "ISCAN(MV5 <,>) | MAP (_ AS _0) | AGG (count_star(*) AS _0) GROUP BY (_._0.COL2 AS _0) | MAP (_._1._0 AS _0)"
6867
- result: []
6968
-
7069
- query: select count(col1) from t2
7170
- explain: "ISCAN(MV5 <,>) | MAP (_ AS _0) | AGG (count(_._0.COL1) AS _0) | ON EMPTY NULL | MAP (coalesce_long(_._0._0, promote(0l AS LONG)) AS _0)"
72-
# 4.1 Triage: failing when running against 4.0.559.6 (Received continuation shouldn't be at beginning)
73-
# - result: [{0}]
71+
- result: [{0}]
7472
-
7573
- query: select count(col1) from t2 group by col2
7674
- explain: "ISCAN(MV5 <,>) | MAP (_ AS _0) | AGG (count(_._0.COL1) AS _0) GROUP BY (_._0.COL2 AS _0) | MAP (_._1._0 AS _0)"

0 commit comments

Comments
 (0)