Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@
public boolean equalsWithoutChildren(@Nonnull final RelationalExpression other, @Nonnull final AliasMap equivalences) {
if (this == other) {
return true;
}

Check notice on line 167 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryDeletePlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 78.0% (46/59 lines) | Changed lines: 66.7% (2/3 lines)
return getClass() == other.getClass();
if (getClass() != other.getClass()) {
return false;
}
return semanticEqualsForResults(other, equivalences);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@
}
if (getClass() != otherExpression.getClass()) {
return false;
}

Check notice on line 231 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryFetchFromPartialRecordPlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 88.8% (79/89 lines) | Changed lines: 50.0% (1/2 lines)

if (!semanticEqualsForResults(otherExpression, equivalences)) {
return false;
}
final var otherFetchPlan = (RecordQueryFetchFromPartialRecordPlan)otherExpression;
return fetchIndexRecords == otherFetchPlan.fetchIndexRecords;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@
}
if (getClass() != otherExpression.getClass()) {
return false;
}

Check notice on line 155 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryFilterPlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 78.0% (32/41 lines) | Changed lines: 50.0% (1/2 lines)
if (!semanticEqualsForResults(otherExpression, equivalencesMap)) {
return false;
}
final RecordQueryFilterPlan otherPlan = (RecordQueryFilterPlan)otherExpression;
return conjunctedFilter.equals(otherPlan.getConjunctedFilter());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@
}
if (getClass() != otherExpression.getClass()) {
return false;
}

Check notice on line 211 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryInJoinPlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 94.7% (71/75 lines) | Changed lines: 50.0% (1/2 lines)
if (!semanticEqualsForResults(otherExpression, equivalencesMap)) {
return false;
}
final RecordQueryInJoinPlan other = (RecordQueryInJoinPlan)otherExpression;
return inSource.equals(other.inSource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@
}
if (getClass() != otherExpression.getClass()) {
return false;
}

Check notice on line 285 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryInUnionPlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 94.9% (129/136 lines) | Changed lines: 50.0% (1/2 lines)
if (!semanticEqualsForResults(otherExpression, equivalencesMap)) {
return false;
}
final RecordQueryInUnionPlan other = (RecordQueryInUnionPlan)otherExpression;
return inSources.equals(other.inSources) && comparisonKeyFunction.equals(other.comparisonKeyFunction);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@
if (getClass() != otherExpression.getClass()) {
return false;
}
final var otherPlan = (RecordQueryPredicatesFilterPlan)otherExpression;

Check notice on line 182 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryPredicatesFilterPlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 87.5% (70/80 lines) | Changed lines: 50.0% (1/2 lines)
if (!semanticEqualsForResults(otherPlan, equivalencesMap)) {
return false;
}
final var otherPredicates = otherPlan.getPredicates();
if (predicates.size() != otherPredicates.size()) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@
}
if (!(otherExpression instanceof RecordQueryRecursiveLevelUnionPlan)) {
return false;
}

Check notice on line 286 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryRecursiveLevelUnionPlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 88.4% (114/129 lines) | Changed lines: 50.0% (1/2 lines)
if (!semanticEqualsForResults(otherExpression, equivalences)) {
return false;
}

final var otherRecursiveUnionQueryPlan = (RecordQueryRecursiveLevelUnionPlan)otherExpression;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@
}
if (getClass() != otherExpression.getClass()) {
return false;
}

Check notice on line 184 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryUnorderedDistinctPlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 54.2% (32/59 lines) | Changed lines: 50.0% (1/2 lines)
if (!semanticEqualsForResults(otherExpression, equivalencesMap)) {
return false;
}
return comparisonKey.equals(((RecordQueryUnorderedDistinctPlan)otherExpression).comparisonKey);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@
@Nonnull final AliasMap equivalencesMap) {
if (this == otherExpression) {
return true;
}

Check notice on line 167 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryUnorderedPrimaryKeyDistinctPlan.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 92.2% (47/51 lines) | Changed lines: 66.7% (2/3 lines)
return (getClass() == otherExpression.getClass());
if (getClass() != otherExpression.getClass()) {
return false;
}
return semanticEqualsForResults(otherExpression, equivalencesMap);
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* RecordQueryDeletePlanTest.java
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2026 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.apple.foundationdb.record.query.plan.plans;

import com.apple.foundationdb.record.query.plan.ScanComparisons;
import com.apple.foundationdb.record.query.plan.cascades.AliasMap;
import com.apple.foundationdb.record.query.plan.cascades.CorrelationIdentifier;
import com.apple.foundationdb.record.query.plan.cascades.Quantifier;
import com.apple.foundationdb.record.query.plan.cascades.Reference;
import com.apple.foundationdb.record.query.plan.cascades.typing.Type;
import com.google.common.collect.ImmutableSet;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class RecordQueryDeletePlanTest {

private static RecordQueryDeletePlan deletePlanOver(final Type flowedType,
final CorrelationIdentifier alias) {
final var scan = new RecordQueryScanPlan(ImmutableSet.of("R"), flowedType, null,
ScanComparisons.EMPTY, false, false);
return RecordQueryDeletePlan.deletePlan(Quantifier.physical(Reference.plannedOf(scan), alias));
}

private static Type recordTypeWith(final Type.TypeCode fieldType) {
return Type.Record.fromFields(false, List.of(
Type.Record.Field.of(Type.primitiveType(fieldType), Optional.of("a"))));
}

@Test
void equalsWithoutChildrenReturnsFalseWhenResultValuesDiffer() {
final var typeLong = recordTypeWith(Type.TypeCode.LONG);
final var deletePlan1 = deletePlanOver(typeLong, CorrelationIdentifier.of("q1"));
final var deletePlan2 = deletePlanOver(typeLong, CorrelationIdentifier.of("q2"));

assertFalse(deletePlan1.equalsWithoutChildren(deletePlan2, AliasMap.emptyMap()));
assertFalse(deletePlan2.equalsWithoutChildren(deletePlan1, AliasMap.emptyMap()));
}

@Test
void equalsWithoutChildrenReturnsTrueWhenResultValuesMatch() {
final var typeLong = recordTypeWith(Type.TypeCode.LONG);
final var alias = CorrelationIdentifier.of("q");
final var deletePlan1 = deletePlanOver(typeLong, alias);
final var deletePlan2 = deletePlanOver(typeLong, alias);

assertTrue(deletePlan1.equalsWithoutChildren(deletePlan2, AliasMap.emptyMap()));
assertTrue(deletePlan1.equalsWithoutChildren(deletePlan1, AliasMap.emptyMap()));
}
}
Loading