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
@@ -0,0 +1,198 @@
/*
* ConstantArrayDistinctValue.java
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2015-2025 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.cascades.values;

import com.apple.foundationdb.annotation.API;
import com.apple.foundationdb.annotation.SpotBugsSuppressWarnings;
import com.apple.foundationdb.record.EvaluationContext;
import com.apple.foundationdb.record.ObjectPlanHash;
import com.apple.foundationdb.record.PlanDeserializer;
import com.apple.foundationdb.record.PlanHashable;
import com.apple.foundationdb.record.PlanSerializationContext;
import com.apple.foundationdb.record.planprotos.PConstantArrayDistinctValue;
import com.apple.foundationdb.record.planprotos.PValue;
import com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase;
import com.apple.foundationdb.record.query.plan.cascades.AliasMap;
import com.apple.foundationdb.record.query.plan.cascades.BuiltInFunction;
import com.apple.foundationdb.record.query.plan.cascades.SemanticException;
import com.apple.foundationdb.record.query.plan.cascades.typing.Type;
import com.apple.foundationdb.record.query.plan.cascades.typing.Typed;
import com.apple.foundationdb.record.query.plan.explain.ExplainTokens;
import com.apple.foundationdb.record.query.plan.explain.ExplainTokensWithPrecedence;
import com.google.auto.service.AutoService;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.Message;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;


/**
* A value that returns the array of the {@link Value} that is passed in with all duplicate elements removed.
* This value only supports underlying constant values that result in an array type, see {@link Value#isConstant()}.
*/
@API(API.Status.EXPERIMENTAL)
public class ConstantArrayDistinctValue extends AbstractValue implements ValueWithChild {
private static final ObjectPlanHash BASE_HASH = new ObjectPlanHash("Constant-Array-Distinct-Value");

@Nonnull
private final Value childValue;
@Nonnull
private final Type resultType;

public ConstantArrayDistinctValue(@Nonnull final Value childValue) {
Verify.verify(childValue.isConstant());
final var innerResultType = Objects.requireNonNull(childValue.getResultType());
Verify.verify(innerResultType.isArray());
this.childValue = childValue;
this.resultType = innerResultType;
}

@Nonnull
@Override
public List<? extends Value> computeChildren() {
return ImmutableList.of(childValue);

Check warning on line 76 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValue.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValue.java#L76

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=4AEDCE7F65F4C1E439D86E5B69EDDF4A
}

@Nonnull
@Override
public Value getChild() {
return childValue;
}

@Nonnull
@Override
public ValueWithChild withNewChild(@Nonnull final Value rebasedChild) {
return new ConstantArrayDistinctValue(rebasedChild);
}


@Nonnull
@Override
public Type getResultType() {
return resultType;
}

@Override
public <M extends Message> Object eval(@Nullable final FDBRecordStoreBase<M> store, @Nonnull final EvaluationContext context) {
final var childResult = childValue.eval(store, context);
if (childResult == null) {
return null;
}
return ((List<?>)childResult).stream().distinct().collect(ImmutableList.toImmutableList());
}

@Override
public int hashCodeWithoutChildren() {
return PlanHashable.objectsPlanHash(PlanHashable.CURRENT_FOR_CONTINUATION, BASE_HASH);
}

@Override
public int planHash(@Nonnull final PlanHashMode mode) {
return PlanHashable.objectsPlanHash(mode, BASE_HASH, childValue);
}

@Nonnull
@Override
public ExplainTokensWithPrecedence explain(@Nonnull final Iterable<Supplier<ExplainTokensWithPrecedence>> explainSuppliers) {
return ExplainTokensWithPrecedence.of(new ExplainTokens().addFunctionCall("constantArrayDistinct",
Value.explainFunctionArguments(explainSuppliers)));
}

@Override
public int hashCode() {
return semanticHashCode();
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@SpotBugsSuppressWarnings("EQ_UNUSUAL")
@Override
public boolean equals(final Object other) {
return semanticEquals(other, AliasMap.emptyMap());
}

Check warning on line 134 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValue.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValue.java#L108-L134

Clone with 3 instances of length 10 https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=13AED874D2ACA9A64E4B00C1A83840D9

@Nonnull
private static Value encapsulateInternal(@Nonnull final List<? extends Typed> typedArgs) {
Verify.verify(typedArgs.size() == 1);
final var arg0 = typedArgs.get(0);
SemanticException.check(
arg0 instanceof Value && arg0.getResultType().isArray() && ((Value)arg0).isConstant(),
SemanticException.ErrorCode.FUNCTION_UNDEFINED_FOR_GIVEN_ARGUMENT_TYPES
);
return new ConstantArrayDistinctValue((Value)arg0);
}

@Nonnull
@Override
public PConstantArrayDistinctValue toProto(@Nonnull final PlanSerializationContext serializationContext) {
return PConstantArrayDistinctValue.newBuilder()
.setChildValue(childValue.toValueProto(serializationContext))
.build();
}

@Nonnull
@Override
public PValue toValueProto(@Nonnull PlanSerializationContext serializationContext) {
return PValue.newBuilder().setConstantArrayDistinctValue(toProto(serializationContext)).build();
}

@Nonnull
public static ConstantArrayDistinctValue fromProto(@Nonnull final PlanSerializationContext serializationContext,
@Nonnull final PConstantArrayDistinctValue constantArrayDistinctValueProto) {
return new ConstantArrayDistinctValue(
Value.fromValueProto(serializationContext, Objects.requireNonNull(constantArrayDistinctValueProto.getChildValue()))
);
}

/**
* Deserializer.
*/
@AutoService(PlanDeserializer.class)
public static class Deserializer implements PlanDeserializer<PConstantArrayDistinctValue, ConstantArrayDistinctValue> {
@Nonnull
@Override
public Class<PConstantArrayDistinctValue> getProtoMessageClass() {
return PConstantArrayDistinctValue.class;
}

@Nonnull
@Override
public ConstantArrayDistinctValue fromProto(@Nonnull final PlanSerializationContext serializationContext,
@Nonnull final PConstantArrayDistinctValue constantArrayDistinctValueProto) {
return ConstantArrayDistinctValue.fromProto(serializationContext, constantArrayDistinctValueProto);
}
}

Check warning on line 186 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValue.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValue.java#L149-L186

Clone with 10 instances of length 11 https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=0D704A48079BD42BDEE17193D40428FB

/**
* The {@code constant_array_distinct} function.
*/
@AutoService(BuiltInFunction.class)
public static class ConstantArrayDistinctFn extends BuiltInFunction<Value> {
public ConstantArrayDistinctFn() {
super("constant_array_distinct",
ImmutableList.of(), new Type.Array(), (builtInFunction, typedArgs) -> encapsulateInternal(typedArgs));

Check warning on line 195 in fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValue.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValue.java#L195

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=5BF0E60ECF091C00137042182629563E
}
}
}
5 changes: 5 additions & 0 deletions fdb-record-layer-core/src/main/proto/record_query_plan.proto
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ message PValue {
PRangeValue range_value = 48;
PFirstOrDefaultStreamingValue first_or_default_streaming_value = 49;
PEvaluatesToValue evaluates_to_value = 50;
PConstantArrayDistinctValue constant_array_distinct_value = 51;
}
}

Expand Down Expand Up @@ -1259,6 +1260,10 @@ message PRangeValue {
optional PValue step_child = 3;
}

message PConstantArrayDistinctValue {
optional PValue child_value = 1;
}

//
// Comparisons
//
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* ConstantArrayDistinctValueTest.java
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2015-2025 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.cascades.values;

import com.apple.foundationdb.record.EvaluationContext;
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.typing.Type;
import com.google.common.base.VerifyException;
import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.List;
import java.util.stream.Stream;

import static org.junit.jupiter.params.provider.Arguments.arguments;

class ConstantArrayDistinctValueTest {

@Test
void rejectsNonConstantValues() {
Assertions.assertThrowsExactly(VerifyException.class, () -> {
new ConstantArrayDistinctValue(
QuantifiedObjectValue.of(CorrelationIdentifier.uniqueID(), new Type.Array())
);
});
}

@Test
void rejectsNonArrayValues() {
Assertions.assertThrowsExactly(VerifyException.class, () -> {
new ConstantArrayDistinctValue(LiteralValue.ofScalar(42));
});
}

static Stream<Arguments> arraysSource() {
return Stream.of(
arguments(ImmutableList.of(1, 2, 1, 2, 1, 2, 3), ImmutableList.of(1, 2, 3)),

Check warning on line 60 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L60

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=51BEE2BF221293808AFB2FB99AF0E45D

Check warning on line 60 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L60

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=5B82F7CAF7CB14DE9009F1AD43ED63F6
arguments(ImmutableList.of(1, 2, 3, 4, 5), ImmutableList.of(1, 2, 3, 4, 5)),

Check warning on line 61 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L61

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=11C0E53174F35079F6A90AC98AEB23C9

Check warning on line 61 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L61

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=5A5DB0FB8707FD688EE2669DE9B39767
arguments(
ImmutableList.of("val2", "val1", "val3", "val1", "val2"),

Check warning on line 63 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L63

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=573B5E672EFE566E18C46C5A8E63DC91
ImmutableList.of("val2", "val1", "val3")

Check warning on line 64 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L64

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=0965E9E121B686BEAAFAFD93B4C40F91
)
);
}

@ParameterizedTest(name = "returnsArrayWithoutDuplicates[input={0}, expected={1}])")
@MethodSource("arraysSource")
void returnsArrayWithoutDuplicates(List<?> inputArray, List<?> expectedArray) {
final var literalValue = LiteralValue.ofList(inputArray);

final var constantArrayDistinctValue = new ConstantArrayDistinctValue(literalValue);
final var actualArray = constantArrayDistinctValue.evalWithoutStore(EvaluationContext.EMPTY);

Assertions.assertEquals(expectedArray, actualArray);
}

@ParameterizedTest(name = "builtInFunctionReturnsArrayWithoutDuplicates[input={0}, expected={1}])")
@MethodSource("arraysSource")
void builtInFunctionReturnsArrayWithoutDuplicates(List<?> inputArray, List<?> expectedArray) {
final var fn = new ConstantArrayDistinctValue.ConstantArrayDistinctFn();

final var retValue = fn.encapsulate(List.of(LiteralValue.ofList(inputArray)));

Assertions.assertInstanceOf(ConstantArrayDistinctValue.class, retValue);
Assertions.assertEquals(expectedArray, ((Value)retValue).evalWithoutStore(EvaluationContext.EMPTY));
}

@Test
void withNewChildReplacesUnderlyingArray() {
final var expectedArray = ImmutableList.of(1, 2, 3);

Check warning on line 93 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L93

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=E0B566EF51C9115B4DF4EEC75ABEC62A
final ConstantArrayDistinctValue value = new ConstantArrayDistinctValue(LiteralValue.ofList(ImmutableList.of(4, 5, 6)));

Check warning on line 94 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L94

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=6BC0946F5BA8D4311D014D210C1E8C49

final var newValue = value.withNewChild(LiteralValue.ofList(expectedArray));

Assertions.assertEquals(expectedArray, newValue.evalWithoutStore(EvaluationContext.EMPTY));
}

@Test
void equalsComparesUnderlyingValues() {
final var val1 = new ConstantArrayDistinctValue(LiteralValue.ofList(ImmutableList.of(5, 6, 7)));

Check warning on line 103 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L103

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=BA490740C36D33DDE1F20CFDA6648C85
final var val2 = new ConstantArrayDistinctValue(LiteralValue.ofList(ImmutableList.of(5, 6, 7)));

Check warning on line 104 in fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java

View check run for this annotation

fdb.teamscale.io / Teamscale | Findings

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/values/ConstantArrayDistinctValueTest.java#L104

Use `java.util.List.of` instead https://fdb.teamscale.io/findings/details/foundationdb-fdb-record-layer?t=FORK_MR%2F3560%2Fhazefully%2Fprepare-for-fixing-in-duplicates%3AHEAD&id=C4C6283CE2841ACB5557E61203C9F766
final var val3 = new ConstantArrayDistinctValue(
ConstantObjectValue.of(Quantifier.constant(), "c0", new Type.Array())
);

Assertions.assertEquals(val1, val2);
Assertions.assertNotEquals(val1, val3);
Assertions.assertNotEquals(val2, val3);
}
}
1 change: 1 addition & 0 deletions fdb-relational-core/src/main/antlr/RelationalLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ VARIANCE: 'VARIANCE';
CURRENT_DATE: 'CURRENT_DATE';
CURRENT_TIME: 'CURRENT_TIME';
CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
CONSTANT_ARRAY_DISTINCT: 'CONSTANT_ARRAY_DISTINCT';
LOCALTIME: 'LOCALTIME';
CURDATE: 'CURDATE';
CURTIME: 'CURTIME';
Expand Down
2 changes: 1 addition & 1 deletion fdb-relational-core/src/main/antlr/RelationalParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ functionNameBase
| BUFFER | CEIL | CEILING | CENTROID | CHARACTER_LENGTH
| CHARSET | CHAR_LENGTH | COERCIBILITY | COLLATION
| COMPRESS | COALESCE | CONCAT | CONCAT_WS | CONNECTION_ID | CONV
| CONVERT_TZ | COS | COT | CRC32
| CONVERT_TZ | COS | COT | CRC32 | CONSTANT_ARRAY_DISTINCT
| CREATE_ASYMMETRIC_PRIV_KEY | CREATE_ASYMMETRIC_PUB_KEY
| CREATE_DH_PARAMETERS | CREATE_DIGEST | CROSSES | CUME_DIST | DATABASE | DATE
| DATEDIFF | DATE_FORMAT | DAY | DAYNAME | DAYOFMONTH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private static ImmutableMap<String, Function<Integer, Optional<BuiltInFunction<?
.put("__pattern_for_like", argumentsCount -> BuiltInFunctionCatalog.resolve("patternForLike", argumentsCount))
.put("__internal_array", argumentsCount -> BuiltInFunctionCatalog.resolve("array", argumentsCount))
.put("__pick_value", argumentsCount -> BuiltInFunctionCatalog.resolve("pick", argumentsCount))
.put("constant_array_distinct", argumentsCount -> BuiltInFunctionCatalog.resolve("constant_array_distinct", argumentsCount))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,17 @@ private static ResultSetMatchResult matchField(@Nullable final Object expected,
}
}
}
if (actualArrayContent.next()) {
return ResultSetMatchResult.fail(String.format(
Locale.ROOT,
"cell mismatch at row: %d cellRef: %s%n expected 🟢contains less items than 🟡.%n🟢 %s%n🟡 %s",
rowNumber,
cellRef,
expected,
actual
));
}

return ResultSetMatchResult.success();
}

Expand Down
15 changes: 15 additions & 0 deletions yaml-tests/src/test/resources/functions.yamsql
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ test_block:
- query: update C set st = coalesce(st, (5, 'e', 5.0)) where c1 = 4 returning "new".st
- unorderedResult: [
{{ T1: 5, A: 'e', B: 5.0}}]
---
test_block:
preset: single_repetition_ordered
options:
supported_version: !current_version
tests:
-
- query: select constant_array_distinct([1, 1, 3, 3, 2, 5]) as arr, a1 from A
- result: [{ a1: 1, arr: [1, 3, 2, 5] }]
-
- query: select constant_array_distinct([1+1, 2*1, 3*0, 99*0, 5]) as arr, a1 from A
- result: [{ a1: 1, arr: [2, 0, 5] }]
-
- query: select constant_array_distinct([a2, 2*1, 3*0, 99*0, 5]) as arr, a1 from A
- error: '22F00'
...


Loading