diff --git a/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/AstNormalizer.java b/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/AstNormalizer.java
index 4a190f9808..d883cd1d99 100644
--- a/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/AstNormalizer.java
+++ b/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/AstNormalizer.java
@@ -578,7 +578,6 @@ public static NormalizationResult normalizeQuery(@Nonnull final PlanContext cont
() -> normalizeAst(
context.getSchemaTemplate(), parseTreeInfo,
PreparedParams.copyOf(context.getPreparedStatementParameters()),
- context.getUserVersion(),
context.getPlannerConfiguration(),
isCaseSensitive,
currentPlanHashMode,
@@ -591,7 +590,6 @@ public static NormalizationResult normalizeQuery(@Nonnull final PlanContext cont
public static NormalizationResult normalizeAst(@Nonnull final SchemaTemplate schemaTemplate,
@Nonnull final ParseTreeInfoImpl parseTreeInfo,
@Nonnull final PreparedParams preparedStatementParameters,
- int userVersion,
@Nonnull final PlannerConfiguration plannerConfiguration,
boolean caseSensitive,
@Nonnull final PlanHashable.PlanHashMode currentPlanHashMode,
@@ -621,7 +619,6 @@ public static NormalizationResult normalizeAst(@Nonnull final SchemaTemplate sch
final var functionAstResult = normalizeAst(schemaTemplate,
QueryParser.parse(recordLayerRoutine.getDescription()),
recordLayerRoutine.getPreparedParams(),
- userVersion,
plannerConfiguration,
caseSensitive,
currentPlanHashMode,
@@ -633,7 +630,7 @@ public static NormalizationResult normalizeAst(@Nonnull final SchemaTemplate sch
recordLayerSchemaTemplate.getName(),
QueryCacheKey.of(astNormalizer.getCanonicalSqlString(), getQuerySpecificPlannerConfig(plannerConfiguration, astNormalizer.getQueryOptions()),
recordLayerSchemaTemplate.getTransactionBoundMetadataAsString(),
- recordLayerSchemaTemplate.getVersion(), userVersion),
+ recordLayerSchemaTemplate.getVersion()),
astNormalizer.getQueryExecutionParameters(),
parseTreeInfo.getRootContext(),
astNormalizer.getQueryCachingFlags(),
diff --git a/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/PlanContext.java b/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/PlanContext.java
index 0e81b916dc..dcb988298f 100644
--- a/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/PlanContext.java
+++ b/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/PlanContext.java
@@ -62,8 +62,6 @@ public final class PlanContext {
@Nonnull
private final SchemaTemplate schemaTemplate;
- private final int userVersion;
-
private final boolean isCaseSensitive;
/**
@@ -77,7 +75,6 @@ public final class PlanContext {
* @param dbUri The URI of the database.
* @param ddlQueryFactory The DDL factory.
* @param preparedStatementParameters A list of prepared statement parameters.
- * @param userVersion The user version bound to the opened record store.
* @param isCaseSensitive {@code True} if SQL identifiers should be treated as case-sensitive, otherwise
* {@code false}.
**/
@@ -89,7 +86,6 @@ private PlanContext(@Nonnull RecordMetaData metaData,
@Nonnull DdlQueryFactory ddlQueryFactory,
@Nonnull URI dbUri,
@Nonnull PreparedParams preparedStatementParameters,
- final int userVersion,
boolean isCaseSensitive) {
this.metaData = metaData;
this.metricCollector = metricCollector;
@@ -99,7 +95,6 @@ private PlanContext(@Nonnull RecordMetaData metaData,
this.ddlQueryFactory = ddlQueryFactory;
this.dbUri = dbUri;
this.preparedStatementParameters = preparedStatementParameters;
- this.userVersion = userVersion;
this.isCaseSensitive = isCaseSensitive;
}
@@ -153,10 +148,6 @@ public SchemaTemplate getSchemaTemplate() {
return schemaTemplate;
}
- public int getUserVersion() {
- return userVersion;
- }
-
@Nonnull
public static Builder builder() {
return new Builder();
@@ -170,8 +161,6 @@ public static final class Builder {
private PlannerConfiguration plannerConfiguration;
- private int userVersion;
-
private SchemaTemplate schemaTemplate;
private MetadataOperationsFactory metadataOperationsFactory;
@@ -213,13 +202,6 @@ public Builder withPlannerConfiguration(@Nonnull PlannerConfiguration plannerCon
return this;
}
- @Nonnull
- @VisibleForTesting
- public Builder withUserVersion(int userVersion) {
- this.userVersion = userVersion;
- return this;
- }
-
@Nonnull
private Builder isCaseSensitive(boolean isCaseSensitive) {
this.isCaseSensitive = isCaseSensitive;
@@ -271,7 +253,6 @@ public Builder fromRecordStore(@Nonnull FDBRecordStoreBase> recordStore, @Nonn
PlannerConfiguration.of(getReadableIndexes(recordStore.getRecordMetaData(), recordStore.getRecordStoreState()), options);
return withPlannerConfiguration(plannerConfig)
.withMetadata(recordStore.getRecordMetaData())
- .withUserVersion(recordStore.getRecordStoreState().getStoreHeader().getUserVersion())
.isCaseSensitive(options.getOption(Options.Name.CASE_SENSITIVE_IDENTIFIERS));
}
@@ -298,7 +279,7 @@ private void verify() throws RelationalException {
public PlanContext build() throws RelationalException {
verify();
return new PlanContext(metaData, metricCollector, schemaTemplate, plannerConfiguration, metadataOperationsFactory,
- ddlQueryFactory, dbUri, preparedStatementParameters, userVersion, isCaseSensitive);
+ ddlQueryFactory, dbUri, preparedStatementParameters, isCaseSensitive);
}
@Nonnull
@@ -316,7 +297,6 @@ public static Builder unapply(@Nonnull PlanContext planContext) {
.withSchemaTemplate(planContext.schemaTemplate)
.withDdlQueryFactory(planContext.ddlQueryFactory)
.withPlannerConfiguration(planContext.plannerConfiguration)
- .withUserVersion(planContext.userVersion)
.withPreparedParameters(planContext.preparedStatementParameters)
.isCaseSensitive(planContext.isCaseSensitive);
}
diff --git a/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/cache/QueryCacheKey.java b/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/cache/QueryCacheKey.java
index fb2a8a9112..d42b8a174a 100644
--- a/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/cache/QueryCacheKey.java
+++ b/fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/cache/QueryCacheKey.java
@@ -34,7 +34,7 @@
*
* - The schema template name to which the query is bound. It is necessary to use it so we can segregate
* the otherwise identical plans but coming from different schemas (see Example 1 below)
- * - The schema template version, user version, and a bit-set of all readable indexes
+ * - The schema template version and a bit-set of all readable indexes
* - The canonical query string where all literals are removed and white spaces are normalised (see example 2)
* - The hash of the query, see {@link AstNormalizer} for more information on how is this generated.
*
@@ -110,25 +110,21 @@ public final class QueryCacheKey {
private final int schemaTemplateVersion;
- private final int userVersion;
-
private final int memoizedHashCode;
private QueryCacheKey(@Nonnull final String canonicalQueryString,
@Nonnull final PlannerConfiguration plannerConfiguration,
@Nonnull final String auxiliaryMetadata,
- int schemaTemplateVersion,
- int userVersion) {
+ int schemaTemplateVersion) {
this.canonicalQueryString = canonicalQueryString;
this.schemaTemplateVersion = schemaTemplateVersion;
- this.userVersion = userVersion;
this.auxiliaryMetadata = auxiliaryMetadata;
this.plannerConfiguration = plannerConfiguration;
// Memoize the hash code. Because this object is used as a key in a hash map, it is important that
// hashCode() be quick. Note that this includes information about the query (canonicalQueryString is like the query hash),
// the schema template version, and the schema (like the set of readable indexes)
- this.memoizedHashCode = Objects.hash(canonicalQueryString, schemaTemplateVersion, plannerConfiguration, userVersion, auxiliaryMetadata);
+ this.memoizedHashCode = Objects.hash(canonicalQueryString, schemaTemplateVersion, plannerConfiguration, auxiliaryMetadata);
}
@Override
@@ -141,7 +137,6 @@ public boolean equals(Object other) {
}
final var that = (QueryCacheKey) other;
return schemaTemplateVersion == that.schemaTemplateVersion &&
- userVersion == that.userVersion &&
Objects.equals(canonicalQueryString, that.canonicalQueryString) &&
Objects.equals(auxiliaryMetadata, that.auxiliaryMetadata) &&
Objects.equals(plannerConfiguration, that.plannerConfiguration);
@@ -166,10 +161,6 @@ public PlannerConfiguration getPlannerConfiguration() {
return plannerConfiguration;
}
- public int getUserVersion() {
- return userVersion;
- }
-
@Nonnull
public String getAuxiliaryMetadata() {
return auxiliaryMetadata;
@@ -184,9 +175,7 @@ public String toString() {
public static QueryCacheKey of(@Nonnull final String query,
@Nonnull final PlannerConfiguration plannerConfiguration,
@Nonnull final String auxiliaryMetadata,
- int schemaTemplateVersion,
- int userVersion) {
- return new QueryCacheKey(query, plannerConfiguration, auxiliaryMetadata, schemaTemplateVersion,
- userVersion);
+ int schemaTemplateVersion) {
+ return new QueryCacheKey(query, plannerConfiguration, auxiliaryMetadata, schemaTemplateVersion);
}
}
diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/api/ddl/DdlTestUtil.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/api/ddl/DdlTestUtil.java
index 0e450d511a..7a6d7ae456 100644
--- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/api/ddl/DdlTestUtil.java
+++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/api/ddl/DdlTestUtil.java
@@ -71,7 +71,6 @@ static PlanContext createVanillaPlanContext(@Nonnull final EmbeddedRelationalCon
.withMetadata(RecordMetaData.build(md))
.withMetricsCollector(Assert.notNullUnchecked(connection.getMetricCollector()))
.withPlannerConfiguration(PlannerConfiguration.ofAllAvailableIndexes())
- .withUserVersion(0)
.withDbUri(URI.create(databaseUri))
.withDdlQueryFactory(NoOpQueryFactory.INSTANCE)
.withConstantActionFactory(NoOpMetadataOperationsFactory.INSTANCE)
diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/memory/InMemoryRelationalStatement.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/memory/InMemoryRelationalStatement.java
index 75c6e55354..f14cd3910c 100644
--- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/memory/InMemoryRelationalStatement.java
+++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/memory/InMemoryRelationalStatement.java
@@ -102,7 +102,6 @@ public boolean execute(String sql) throws SQLException {
.withMetadata(relationalConn.getSchemaTemplate().unwrap(RecordLayerSchemaTemplate.class).toRecordMetadata())
.withSchemaTemplate(relationalConn.getSchemaTemplate())
.withPlannerConfiguration(PlannerConfiguration.ofAllAvailableIndexes())
- .withUserVersion(0)
.build();
final var planGenerator = PlanGenerator.create(Optional.empty(), ctx, ctx.getMetaData(), new RecordStoreState(null, Map.of()), IndexMaintainerFactoryRegistryImpl.instance(), Options.NONE);
diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/metadata/SchemaTemplateSerDeTests.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/metadata/SchemaTemplateSerDeTests.java
index d8b29f75b6..ff5efbf31c 100644
--- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/metadata/SchemaTemplateSerDeTests.java
+++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/metadata/SchemaTemplateSerDeTests.java
@@ -1066,7 +1066,6 @@ public PlanGenerator getPlanGenerator() throws RelationalException, SQLException
.withMetadata(getRecordMetaData())
.withSchemaTemplate(getSchemaTemplate("testSchema", 42))
.withPlannerConfiguration(PlannerConfiguration.ofAllAvailableIndexes())
- .withUserVersion(0)
.build();
return PlanGenerator.create(Optional.empty(), ctx, ctx.getMetaData(), new RecordStoreState(null, Map.of()),
IndexMaintainerFactoryRegistryImpl.instance(), Options.builder().withOption(Options.Name.CASE_SENSITIVE_IDENTIFIERS, true).build());
diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/AstNormalizerTests.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/AstNormalizerTests.java
index ba95364cf3..81dd872f89 100644
--- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/AstNormalizerTests.java
+++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/AstNormalizerTests.java
@@ -260,7 +260,7 @@ private static void validate(@Nonnull final List queries,
final var query = queries.get(i);
final var expectedParameters = expectedParametersList.get(i);
final var hashResults = AstNormalizer.normalizeAst(schemaTemplates.get(i), QueryParser.parse(query),
- PreparedParams.copyOf(preparedParameters), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query);
+ PreparedParams.copyOf(preparedParameters), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query);
Assertions.assertThat(hashResults.getQueryCacheKey().getCanonicalQueryString()).isEqualTo(expectedCanonicalRepresentation);
Assertions.assertThat(hashResults.getQueryCacheKey().getAuxiliaryMetadata()).isEqualTo(auxiliaryMetadata);
final var execParams = hashResults.getQueryExecutionContext();
@@ -310,7 +310,7 @@ private static void validate(@Nonnull final List queries,
private static void shouldFail(@Nonnull final String query, @Nonnull final String errorMessage) {
try {
AstNormalizer.normalizeAst(fakeSchemaTemplate, QueryParser.parse(query),
- PreparedParams.empty(), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query);
+ PreparedParams.empty(), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query);
Assertions.fail(String.format(Locale.ROOT, "expected %s to fail with %s, but it succeeded!", query, errorMessage));
} catch (RelationalException | UncheckedRelationalException e) {
Assertions.assertThat(e.getMessage()).contains(errorMessage);
@@ -334,9 +334,9 @@ private static void validateNotSameHash(@Nonnull final String query1,
@Nonnull PreparedParams preparedParams2) throws RelationalException {
final var result1 = AstNormalizer.normalizeAst(fakeSchemaTemplate, QueryParser.parse(query1),
- PreparedParams.copyOf(preparedParams1), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query1);
+ PreparedParams.copyOf(preparedParams1), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query1);
final var result2 = AstNormalizer.normalizeAst(fakeSchemaTemplate, QueryParser.parse(query2),
- PreparedParams.copyOf(preparedParams2), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query2);
+ PreparedParams.copyOf(preparedParams2), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query2);
Assertions.assertThat(result1.getQueryCacheKey().hashCode()).isNotEqualTo(result2.getQueryCacheKey().hashCode());
}
@@ -349,9 +349,9 @@ private static void validateNotEqual(@Nonnull final String query1,
@Nonnull final String query2,
@Nonnull PreparedParams preparedParams) throws RelationalException {
final var result1 = AstNormalizer.normalizeAst(fakeSchemaTemplate, QueryParser.parse(query1),
- PreparedParams.copyOf(preparedParams), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query1);
+ PreparedParams.copyOf(preparedParams), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query1);
final var result2 = AstNormalizer.normalizeAst(fakeSchemaTemplate, QueryParser.parse(query2),
- PreparedParams.copyOf(preparedParams), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query2);
+ PreparedParams.copyOf(preparedParams), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query2);
Assertions.assertThat(result1.getQueryCacheKey()).isNotEqualTo(result2.getQueryCacheKey());
}
@@ -361,9 +361,9 @@ private static void validateNotEqual(@Nonnull final String query1,
@Nonnull final RecordLayerSchemaTemplate schemaTemplate2,
@Nonnull PreparedParams preparedParams) throws RelationalException {
final var result1 = AstNormalizer.normalizeAst(schemaTemplate1, QueryParser.parse(query1),
- PreparedParams.copyOf(preparedParams), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query1);
+ PreparedParams.copyOf(preparedParams), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query1);
final var result2 = AstNormalizer.normalizeAst(schemaTemplate2, QueryParser.parse(query2),
- PreparedParams.copyOf(preparedParams), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query2);
+ PreparedParams.copyOf(preparedParams), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, query2);
Assertions.assertThat(result1.getQueryCacheKey()).isNotEqualTo(result2.getQueryCacheKey());
}
@@ -395,7 +395,7 @@ private static RecordLayerSchemaTemplate schemaTemplateWithFunction(@Nonnull fin
final String canonicalFunctionDdl;
if (isTemporary) {
final var normalizer = AstNormalizer.normalizeAst(schemaTemplate, QueryParser.parse(functionDdl), PreparedParams.empty(),
- 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, functionDdl);
+ plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, functionDdl);
canonicalFunctionDdl = normalizer.getQueryCacheKey().getCanonicalQueryString();
} else {
canonicalFunctionDdl = functionDdl;
@@ -1449,7 +1449,7 @@ void windowFunctionOptionsAreNotStripped() throws Exception {
private String normalizeQuery(@Nonnull final String functionDdl) throws RelationalException {
final var normalizer = AstNormalizer.normalizeAst(fakeSchemaTemplate,
QueryParser.parse(functionDdl), PreparedParams.empty(),
- 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, functionDdl);
+ plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, functionDdl);
return normalizer.getQueryCacheKey().getCanonicalQueryString();
}
@@ -1467,8 +1467,8 @@ void explainAndNonExplainProduceSameCanonicalQueryString() throws RelationalExce
final var selPT = QueryParser.parse(selQ);
final var expPT = QueryParser.parse(expQ);
- final var selRes = AstNormalizer.normalizeAst(fakeSchemaTemplate, selPT, PreparedParams.empty(), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, selQ);
- final var expRes = AstNormalizer.normalizeAst(fakeSchemaTemplate, expPT, PreparedParams.empty(), 0, plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, expQ);
+ final var selRes = AstNormalizer.normalizeAst(fakeSchemaTemplate, selPT, PreparedParams.empty(), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, selQ);
+ final var expRes = AstNormalizer.normalizeAst(fakeSchemaTemplate, expPT, PreparedParams.empty(), plannerConfiguration, false, PlanHashable.PlanHashMode.VC0, expQ);
// compare NormalizationResult
Assertions.assertThat(expRes.getQueryCacheKey().getCanonicalQueryString())
@@ -1496,7 +1496,7 @@ void visitFullDescribeStatementThrows() throws ReflectiveOperationException {
@Test
void queryCacheKeyToString() {
- final var key = QueryCacheKey.of("select ? from testTable", plannerConfiguration, "someAuxiliaryMetadata", 3, 7);
+ final var key = QueryCacheKey.of("select ? from testTable", plannerConfiguration, "someAuxiliaryMetadata", 3);
final var expected = "(3 || someAuxiliaryMetadata)||select ? from testTable||" + key.hashCode();
Assertions.assertThat(key).hasToString(expected);
}
diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/cache/ConstraintValidityTests.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/cache/ConstraintValidityTests.java
index 16d468e08c..983db41099 100644
--- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/cache/ConstraintValidityTests.java
+++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/cache/ConstraintValidityTests.java
@@ -120,7 +120,6 @@ private PlanGenerator getPlanGenerator(@Nonnull final RelationalPlanCache cache)
.fromRecordStore(store, Options.none())
.withSchemaTemplate(schemaTemplate)
.withMetricsCollector(embeddedConnection.getMetricCollector())
- .withUserVersion(44)
.build();
return PlanGenerator.create(Optional.of(cache), planContext, store.getRecordMetaData(), storeState, store.getIndexMaintainerRegistry(), Options.builder().build());
}
diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/cache/RelationalPlanCacheTests.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/cache/RelationalPlanCacheTests.java
index 027f3d1dbe..cb843ca8a2 100644
--- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/cache/RelationalPlanCacheTests.java
+++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/cache/RelationalPlanCacheTests.java
@@ -354,7 +354,6 @@ private PlannerConfiguration configOf(@Nonnull final Set readableIndexes
private PlanGenerator getPlanGenerator(@Nonnull final RelationalPlanCache cache,
@Nonnull final String schemaTemplateName,
int schemaTemplateVersion,
- int userVersion,
@Nonnull final Set readableIndexes,
@Nonnull final Options options) throws Exception {
final var schemaName = connection.getSchema();
@@ -370,7 +369,6 @@ private PlanGenerator getPlanGenerator(@Nonnull final RelationalPlanCache cache,
.withSchemaTemplate(embeddedConnection.getTransaction().getBoundSchemaTemplateMaybe().orElse(schemaTemplate))
.withMetricsCollector(Assert.notNullUnchecked(embeddedConnection.getMetricCollector()))
.withPlannerConfiguration(PlannerConfiguration.of(Optional.of(readableIndexes), options))
- .withUserVersion(userVersion)
.build();
return PlanGenerator.create(Optional.of(cache), planContext, store.getRecordMetaData(), storeState, store.getIndexMaintainerRegistry(), options);
}
@@ -413,7 +411,6 @@ private static void shouldBe(@Nonnull final RelationalPlanCache cache, @Nonnull
new Tuple(secondaryKey.getCanonicalQueryString(),
key,
secondaryKey.getSchemaTemplateVersion(),
- secondaryKey.getUserVersion(),
secondaryKey.getPlannerConfiguration(),
secondaryKey.getAuxiliaryMetadata()),
k -> new HashMap<>());
@@ -455,10 +452,9 @@ private void planQuery(@Nonnull final RelationalPlanCache cache,
@Nonnull final String query,
@Nonnull final String schemaTemplateName,
int schemaTemplateVersion,
- int userVersion,
@Nonnull final Set readableIndexes,
@Nonnull final String expectedPhysicalPlan) throws Exception {
- planQuery(cache, query, schemaTemplateName, schemaTemplateVersion, userVersion, readableIndexes,
+ planQuery(cache, query, schemaTemplateName, schemaTemplateVersion, readableIndexes,
Options.none(), expectedPhysicalPlan);
}
@@ -466,11 +462,10 @@ private void planQuery(@Nonnull final RelationalPlanCache cache,
@Nonnull final String query,
@Nonnull final String schemaTemplateName,
int schemaTemplateVersion,
- int userVersion,
@Nonnull final Set readableIndexes,
@Nonnull final Options options, @Nonnull final String expectedPhysicalPlan) throws Exception {
planQueryWithTemporaryFunctionsPreamble(cache, ImmutableList.of(), query, schemaTemplateName, schemaTemplateVersion,
- userVersion, readableIndexes, options, expectedPhysicalPlan);
+ readableIndexes, options, expectedPhysicalPlan);
}
private void planQueryWithTemporaryFunctionsPreamble(@Nonnull final RelationalPlanCache cache,
@@ -478,11 +473,10 @@ private void planQueryWithTemporaryFunctionsPreamble(@Nonnull final RelationalPl
@Nonnull final String query,
@Nonnull final String schemaTemplateName,
int schemaTemplateVersion,
- int userVersion,
@Nonnull final Set readableIndexes,
@Nonnull final String expectedPhysicalPlan) throws Exception {
planQueryWithTemporaryFunctionsPreamble(cache, temporaryFunctionsDefinitions, query, schemaTemplateName,
- schemaTemplateVersion, userVersion, readableIndexes, Options.none(), expectedPhysicalPlan);
+ schemaTemplateVersion, readableIndexes, Options.none(), expectedPhysicalPlan);
}
private void planQueryWithTemporaryFunctionsPreamble(@Nonnull final RelationalPlanCache cache,
@@ -490,17 +484,16 @@ private void planQueryWithTemporaryFunctionsPreamble(@Nonnull final RelationalPl
@Nonnull final String query,
@Nonnull final String schemaTemplateName,
int schemaTemplateVersion,
- int userVersion,
@Nonnull final Set readableIndexes,
@Nonnull final Options options,
@Nonnull final String expectedPhysicalPlan) throws Exception {
connection.setAutoCommit(false);
connection.getUnderlyingEmbeddedConnection().createNewTransaction();
- var planGenerator = getPlanGenerator(cache, schemaTemplateName, schemaTemplateVersion, userVersion, readableIndexes, options);
+ var planGenerator = getPlanGenerator(cache, schemaTemplateName, schemaTemplateVersion, readableIndexes, options);
for (var temporaryFunctionsDefinition : temporaryFunctionsDefinitions) {
final var plan = planGenerator.getPlan(temporaryFunctionsDefinition);
plan.execute(getExecutionContext());
- planGenerator = getPlanGenerator(cache, schemaTemplateName, schemaTemplateVersion, userVersion, readableIndexes, options);
+ planGenerator = getPlanGenerator(cache, schemaTemplateName, schemaTemplateVersion, readableIndexes, options);
}
final var physicalPlan = planGenerator.getPlan(query);
connection.rollback();
@@ -514,26 +507,26 @@ void testCachingDifferentQueries() throws Exception {
final var cache = getCache(ticker);
// adding an entry to the cache to warm it up.
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// let's add an identical query with different boundaries, so we can use a different index (i1980).
// however, we end up with in the same primary cache bucket because the primary key is identical.
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 AND YEAR < 1985", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1980);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 AND YEAR < 1985", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1980);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(
ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970,
ppe(cons(c1980Cp0(7), c1980Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1980)));
// let's try another query, now the query itself is different -> must be a different entry in the _primary_ cache.
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 OR YEAR < 1985", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), Scan);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 OR YEAR < 1985", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), Scan);
shouldBe(cache, Map.of(
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(
ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970,
ppe(cons(c1980Cp0(7), c1980Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1980),
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? OR \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? OR \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
// tautology is expected since a primary scan accepts everything.
Map.of(ppe(tautology, cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), Scan)
));
@@ -545,17 +538,17 @@ void testCachingDifferentSchemaTemplateNames() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// customer 2 issues exactly the same query, the environment is identical to first query, but the schema template is different ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_2", 10, 100, Set.of(i1970, i1980), i1970);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_2", 10, Set.of(i1970, i1980), i1970);
shouldBe(cache, Map.of(
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970),
// so it is added as a separate entry in the main cache
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_2", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_2", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
}
@@ -565,37 +558,17 @@ void testCachingDifferentSchemaTemplateVersions() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// customer 2 issues exactly the same query, the environment is identical to first query, but the schema template version is different ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 11, 100, Set.of(i1970, i1980), i1970);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 11, Set.of(i1970, i1980), i1970);
shouldBe(cache, Map.of(
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970),
// so it is added as a separate entry in the main cache
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 11, 100, configOf(Set.of(i1970, i1980)), ""),
- Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
- }
-
- @Test
- void testCachingDifferentUserVersion() throws Exception {
- final var ticker = new FakeTicker();
- final var cache = getCache(ticker);
-
- // customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
- Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
-
- // customer 2 issues exactly the same query, the environment is identical to first query, but the user version is different ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 101, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
- Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970),
- // so it is added as a separate entry in the main cache
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 101, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 11, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
}
@@ -605,19 +578,19 @@ void testCachingDifferentReadableIndexes() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// customer 2 issues exactly the same query, the environment is identical to first query, but the readable indexes set is different ...
// this simulates situations of e.g. two users who upgraded to the _same_ schema template, however the groomer hasn't (yet) made more indexes (i1990) available for one of them
// in that case, we want to make sure that we re-plan the query giving the optimizer a chance to consider the newly created index for producing a better plan.
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1970);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1970);
shouldBe(cache, Map.of(
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970),
// so it is added as a separate entry in the main cache
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
}
@@ -627,13 +600,13 @@ void testCachingDifferentConstraints() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// customer 2 issues exactly the same query, the environment is identical to first query, but which predicates that fall outside the ranges of the chosen index of the first query
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 AND YEAR < 1983", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1980);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 AND YEAR < 1983", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1980);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(
ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970,
ppe(cons(c1980Cp0(7), c1980Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1980)));
@@ -645,8 +618,8 @@ void testEvictionFromPrimaryCache() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// 10 MS TTL for primary cache, if we pass 11 -> item must be evicted from primary cache.
@@ -660,25 +633,25 @@ void testEvictionFromPrimaryCacheWithLru() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// customer 2 issues a different query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 OR YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), Scan);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 OR YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), Scan);
shouldBe(cache, Map.of(
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970),
// ... which is added as a separate entry in the main cache
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? OR \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? OR \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(tautology, cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), Scan)));
// customer 3 issues yet a different query, cache size is two, evicts an item ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), Scan);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), Scan);
shouldBe(cache, Map.of(
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(tautology, cons(ofTypeIntCp0(7), isNotNullInt(7))), Scan),
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
}
@@ -688,8 +661,8 @@ void testEvictionFromSecondaryCacheRemovesPrimaryKeyWhenEmpty() throws Exception
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// 10 MS TTL for primary cache, 5 MS TTL for secondary cache, if we pass 7 -> item must be evicted from secondary cache
@@ -709,16 +682,16 @@ void testEvictionFromTertiaryCache() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// pass some time, so we have some jitter between secondary cache items necessary for producing deterministic test results.
ticker.advance(Duration.of(2, ChronoUnit.MILLIS));
// customer 2 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 AND YEAR < 1985", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1980);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 AND YEAR < 1985", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1980);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(
ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970,
ppe(cons(c1980Cp0(7), c1980Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1980)));
@@ -726,7 +699,7 @@ void testEvictionFromTertiaryCache() throws Exception {
// 10 MS TTL for primary cache, 5 MS TTL for secondary cache, we already passed 2, now if pass 3 more we'll
// evict the first cached item in the secondary cache, but _not_ the more recent one.
ticker.advance(Duration.of(3, ChronoUnit.MILLIS));
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1980Cp0(7), c1980Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1980)));
}
@@ -736,21 +709,21 @@ void testEvictionFromSecondaryCacheWithLru() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// customer 2 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 AND YEAR < 1985", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1980);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1980 AND YEAR < 1985", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1980);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), ""),
Map.of(
ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970,
ppe(cons(c1980Cp0(7), c1980Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1980)));
// secondary cache has capacity of two, attempting to add a third item causes an eviction (LRU).
// customer 3 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1990 AND YEAR < 1992", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1990);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1990 AND YEAR < 1992", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1990);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), ""),
Map.of(
ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970,
ppe(cons(c1990Cp0(7), c1990Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1990)));
@@ -762,8 +735,8 @@ void testEvictionFromTertiaryCacheRemovesSecondaryKeyWhenEmpty() throws Exceptio
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11),
isNotNullInt(7), isNotNullInt(11))), i1970)));
@@ -771,14 +744,14 @@ void testEvictionFromTertiaryCacheRemovesSecondaryKeyWhenEmpty() throws Exceptio
// and the removal listener will make sure to clean up the secondary cache key as it becomes empty.
// As to not remove the primary cache entry, we issue another query on that schema template
ticker.advance(Duration.of(7, ChronoUnit.MILLIS));
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), Scan);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), Scan);
// this is needed because expiration is done passively for better performance.
// cleanup causes expiration handling to kick in immediately resulting in deterministic behavior which is necessary for testing.
cache.cleanUp();
// Only one secondary key, the first one was removed
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(tautology, cons(ofTypeIntCp0(7), isNotNullInt(7))), Scan)));
}
@@ -788,23 +761,23 @@ void testPlanReductionViaCosting() throws Exception {
final var cache = getCache(ticker);
// customer 1 issues a query ...
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11),
isNotNullInt(7), isNotNullInt(11))), i1970)));
// customer 2 issues a query that forces a "bad" plan within the same secondary cache entry of the plan above
// because of scan boundaries that fall outside the range of the filtered index
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 2005 AND YEAR < 2010", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), Scan);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 2005 AND YEAR < 2010", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), Scan);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11),
isNotNullInt(7), isNotNullInt(11))), i1970,
ppe(tautology, cons(ofTypeIntCp0(7), ofTypeIntCp1(11),
isNotNullInt(7), isNotNullInt(11))), Scan)));
// we should still get back the "good" plan (scanning i1970)
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11),
isNotNullInt(7), isNotNullInt(11))), i1970,
ppe(tautology, cons(ofTypeIntCp0(7), ofTypeIntCp1(11),
@@ -819,9 +792,9 @@ void testConstraintsWithTemporaryFunction() throws Exception {
planQueryWithTemporaryFunctionsPreamble(cache, ImmutableList.of(
"CREATE TEMPORARY FUNCTION SCI_FI_BOOKS() ON COMMIT DROP FUNCTION AS SELECT * FROM BOOKS WHERE TITLE LIKE 'SCIFI'",
"CREATE TEMPORARY FUNCTION SCI_FI_BOOKS_OF_80S() ON COMMIT DROP FUNCTION AS SELECT * FROM SCI_FI_BOOKS() WHERE YEAR > 1980 AND YEAR < 1989"),
- "SELECT * FROM SCI_FI_BOOKS_OF_80S()", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1980);
+ "SELECT * FROM SCI_FI_BOOKS_OF_80S()", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1980);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"SCI_FI_BOOKS_OF_80S\" ( ) ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), "CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS\" ( ) " +
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"SCI_FI_BOOKS_OF_80S\" ( ) ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), "CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"BOOKS\" WHERE \"TITLE\" LIKE ? ||CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS_OF_80S\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"SCI_FI_BOOKS\" ( ) WHERE \"YEAR\" > ? AND \"YEAR\" < ? "),
Map.of(ppe(cons(
@@ -846,9 +819,9 @@ void testConstraintsWithTemporaryFunctionsIncludingUnusedOnes() throws Exception
"CREATE TEMPORARY FUNCTION OTHER_BOOKS() ON COMMIT DROP FUNCTION AS SELECT * FROM BOOKS WHERE TITLE LIKE 'OTHER'",
"CREATE TEMPORARY FUNCTION SCI_FI_BOOKS() ON COMMIT DROP FUNCTION AS SELECT * FROM BOOKS WHERE TITLE LIKE 'SCIFI'",
"CREATE TEMPORARY FUNCTION SCI_FI_BOOKS_OF_80S() ON COMMIT DROP FUNCTION AS SELECT * FROM SCI_FI_BOOKS() WHERE YEAR > 1980 AND YEAR < 1989"),
- "SELECT * FROM SCI_FI_BOOKS_OF_80S()", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1980);
+ "SELECT * FROM SCI_FI_BOOKS_OF_80S()", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1980);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"SCI_FI_BOOKS_OF_80S\" ( ) ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), "CREATE TEMPORARY FUNCTION \"OTHER_BOOKS\" ( ) " +
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"SCI_FI_BOOKS_OF_80S\" ( ) ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), "CREATE TEMPORARY FUNCTION \"OTHER_BOOKS\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"BOOKS\" WHERE \"TITLE\" LIKE ? ||CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"BOOKS\" WHERE \"TITLE\" LIKE ? ||CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS_OF_80S\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"SCI_FI_BOOKS\" ( ) WHERE \"YEAR\" > ? AND \"YEAR\" < ? "),
@@ -871,9 +844,9 @@ void testConstraintsWithTemporaryFunctionsMultipleReferences() throws Exception
planQueryWithTemporaryFunctionsPreamble(cache, ImmutableList.of(
"CREATE TEMPORARY FUNCTION SCI_FI_BOOKS() ON COMMIT DROP FUNCTION AS SELECT * FROM BOOKS WHERE TITLE LIKE 'SCIFI'",
"CREATE TEMPORARY FUNCTION SCI_FI_BOOKS_OF_80S() ON COMMIT DROP FUNCTION AS SELECT * FROM SCI_FI_BOOKS() WHERE YEAR > 1980 AND YEAR < 1989"),
- "SELECT * FROM SCI_FI_BOOKS_OF_80S(), SCI_FI_BOOKS_OF_80S()", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1980);
+ "SELECT * FROM SCI_FI_BOOKS_OF_80S(), SCI_FI_BOOKS_OF_80S()", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1980);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"SCI_FI_BOOKS_OF_80S\" ( ) , \"SCI_FI_BOOKS_OF_80S\" ( ) ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)),
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"SCI_FI_BOOKS_OF_80S\" ( ) , \"SCI_FI_BOOKS_OF_80S\" ( ) ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)),
"CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"BOOKS\" WHERE \"TITLE\" LIKE ? ||CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS_OF_80S\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"SCI_FI_BOOKS\" ( ) WHERE \"YEAR\" > ? AND \"YEAR\" < ? "),
@@ -897,10 +870,10 @@ void testConstraintsWithTemporaryFunctionsMultipleLiterals() throws Exception {
"CREATE TEMPORARY FUNCTION OTHER_BOOKS() ON COMMIT DROP FUNCTION AS SELECT * FROM BOOKS WHERE TITLE LIKE 'OTHER'",
"CREATE TEMPORARY FUNCTION SCI_FI_BOOKS() ON COMMIT DROP FUNCTION AS SELECT * FROM BOOKS WHERE TITLE LIKE 'SCIFI'",
"CREATE TEMPORARY FUNCTION SCI_FI_BOOKS_OF_80S() ON COMMIT DROP FUNCTION AS SELECT * FROM SCI_FI_BOOKS() WHERE YEAR > 1980 AND YEAR < 1989"),
- "SELECT * FROM SCI_FI_BOOKS_OF_80S() AS A, OTHER_BOOKS() AS B WHERE A.YEAR > 1985 AND A.TITLE = 'OTHER'", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980, i1990), i1980);
+ "SELECT * FROM SCI_FI_BOOKS_OF_80S() AS A, OTHER_BOOKS() AS B WHERE A.YEAR > 1985 AND A.TITLE = 'OTHER'", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980, i1990), i1980);
shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"SCI_FI_BOOKS_OF_80S\" ( ) AS \"A\" , \"OTHER_BOOKS\" ( ) AS \"B\" WHERE \"A\" . \"YEAR\" > ? AND \"A\" . \"TITLE\" = ? ",
- "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980, i1990)), "CREATE TEMPORARY FUNCTION \"OTHER_BOOKS\" ( ) " +
+ "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980, i1990)), "CREATE TEMPORARY FUNCTION \"OTHER_BOOKS\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"BOOKS\" WHERE \"TITLE\" LIKE ? ||CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"BOOKS\" WHERE \"TITLE\" LIKE ? ||CREATE TEMPORARY FUNCTION \"SCI_FI_BOOKS_OF_80S\" ( ) " +
"ON COMMIT DROP FUNCTION AS SELECT * FROM \"SCI_FI_BOOKS\" ( ) WHERE \"YEAR\" > ? AND \"YEAR\" < ? "),
@@ -927,21 +900,21 @@ void testPlanningQueryWithAndWithoutDisabledPlannerRewriteRules() throws Excepti
final var disabledRulesOption = Options.builder().withOption(Options.Name.DISABLE_PLANNER_REWRITING, true).build();
// customer 1 issues a query with disabled planner rules
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), disabledRulesOption, i1970);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), disabledRulesOption, i1970);
shouldBe(cache, Map.of(
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980), disabledRulesOption), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980), disabledRulesOption), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// customer 2 issues the same query, with enabled planner rules.
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
// cache should contain two entries
shouldBe(cache, Map.of(
// ... one with disabled planner rules.
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980), disabledRulesOption), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980), disabledRulesOption), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970),
// ... another one with enabled planner rules.
- new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// this is needed because expiration is done passively for better performance.
@@ -964,17 +937,17 @@ void testPlanningQueryWithAndWithoutPlanRightDeepOption(boolean specifyInQuery)
final Options optionsWithOption = specifyInQuery ? Options.none() : rightDeepOption;
final String expectedCononicalString = "SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ";
- planQuery(cache, queryWithOption, "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), optionsWithOption, i1970);
+ planQuery(cache, queryWithOption, "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), optionsWithOption, i1970);
shouldBe(cache, Map.of(
- new Tuple(expectedCononicalString, "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980), rightDeepOption), ""),
+ new Tuple(expectedCononicalString, "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980), rightDeepOption), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
// now run the plain query (no option either way)
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), Options.none(), i1970);
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), Options.none(), i1970);
shouldBe(cache, Map.of(
- new Tuple(expectedCononicalString, "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980), rightDeepOption), ""),
+ new Tuple(expectedCononicalString, "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980), rightDeepOption), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970),
- new Tuple(expectedCononicalString, "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ new Tuple(expectedCononicalString, "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
cache.cleanUp();
@@ -985,16 +958,16 @@ void testExplainReusesCachedPlan() throws Exception {
final var ticker = new FakeTicker();
final var cache = getCache(ticker);
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
- planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
- planQuery(cache, "EXPLAIN SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, 100, Set.of(i1970, i1980), i1970);
- shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, 100, configOf(Set.of(i1970, i1980)), ""),
+ planQuery(cache, "EXPLAIN SELECT * FROM BOOKS WHERE YEAR > 1970 AND YEAR < 1979", "SCHEMA_TEMPLATE_1", 10, Set.of(i1970, i1980), i1970);
+ shouldBe(cache, Map.of(new Tuple("SELECT * FROM \"BOOKS\" WHERE \"YEAR\" > ? AND \"YEAR\" < ? ", "SCHEMA_TEMPLATE_1", 10, configOf(Set.of(i1970, i1980)), ""),
Map.of(ppe(cons(c1970Cp0(7), c1970Cp1(11)), cons(ofTypeIntCp0(7), ofTypeIntCp1(11), isNotNullInt(7), isNotNullInt(11))), i1970)));
}
}