Repository: apache/flink
File: flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/utils/DeltaJoinUtilTest.java (Java)

Code before:
import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.planner.calcite.FlinkTypeFactory;
import org.apache.flink.table.planner.calcite.FlinkTypeSystem;
import org.apache.flink.table.types.utils.TypeConversions;

import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.util.ImmutableBitSet;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.apache.flink.table.planner.plan.utils.DeltaJoinUtil.isFilterOnOneSetOfUpsertKeys;
import static org.assertj.core.api.Assertions.assertThat;

/** Test for {@link DeltaJoinUtil}. */
public class DeltaJoinUtilTest {

    @Test
    public void testIsFilterOnOneSetOfUpsertKeys() {
        FlinkTypeFactory typeFactory =
                new FlinkTypeFactory(
                        Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
        // input schema:
        // a string,
        // b bigint,
        // c bigint
        List<RelDataType> allFieldTypes =
                Stream.of(DataTypes.VARCHAR(100), DataTypes.BIGINT(), DataTypes.BIGINT())
                        .map(TypeConversions::fromDataToLogicalType)
                        .map(typeFactory::createFieldTypeFromLogicalType)
                        .collect(Collectors.toList());

        RexBuilder rexBuilder = new RexBuilder(typeFactory);

        // a = 'jim'
        RexNode filter =
                rexBuilder.makeCall(
                        SqlStdOperatorTable.EQUALS,
                        rexBuilder.makeInputRef(allFieldTypes.get(0), 0),
                        rexBuilder.makeLiteral("jim", allFieldTypes.get(0)));

        assertThat(isFilterOnOneSetOfUpsertKeys(filter, buildUpsertKeys(ImmutableBitSet.of(0))))
                .isTrue();
        assertThat(isFilterOnOneSetOfUpsertKeys(filter, buildUpsertKeys(ImmutableBitSet.of(2))))

Review comment (suggestion):
nit
```suggestion
class DeltaJoinUtilTest {

    @Test
    void testIsFilterOnOneSetOfUpsertKeys() {
```

Code after:
import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.planner.calcite.FlinkTypeFactory;
import org.apache.flink.table.planner.calcite.FlinkTypeSystem;
import org.apache.flink.table.types.utils.TypeConversions;

import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.util.ImmutableBitSet;
import org.junit.jupiter.api.Test;

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

import static org.apache.flink.table.planner.plan.utils.DeltaJoinUtil.isFilterOnOneSetOfUpsertKeys;
import static org.assertj.core.api.Assertions.assertThat;

/** Test for {@link DeltaJoinUtil}. */
class DeltaJoinUtilTest {

    @Test
    void testIsFilterOnOneSetOfUpsertKeys() {
        FlinkTypeFactory typeFactory =
                new FlinkTypeFactory(
                        Thread.currentThread().getContextClassLoader(), FlinkTypeSystem.INSTANCE);
        // input schema:
        // a string,
        // b bigint,
        // c bigint
        List<RelDataType> allFieldTypes =
                Stream.of(DataTypes.VARCHAR(100), DataTypes.BIGINT(), DataTypes.BIGINT())
                        .map(TypeConversions::fromDataToLogicalType)
                        .map(typeFactory::createFieldTypeFromLogicalType)
                        .collect(Collectors.toList());

        RexBuilder rexBuilder = new RexBuilder(typeFactory);

        // a = 'jim'
        RexNode filter =
                rexBuilder.makeCall(
                        SqlStdOperatorTable.EQUALS,
                        rexBuilder.makeInputRef(allFieldTypes.get(0), 0),
                        rexBuilder.makeLiteral("jim", allFieldTypes.get(0)));

        assertThat(isFilterOnOneSetOfUpsertKeys(filter, Set.of(ImmutableBitSet.of(0)))).isTrue();
        assertThat(isFilterOnOneSetOfUpsertKeys(filter, Set.of(ImmutableBitSet.of(2)))).isFalse();
        assertThat(isFilterOnOneSetOfUpsertKeys(filter, Set.of(ImmutableBitSet.of(0, 1)))).isTrue();
        assertThat(isFilterOnOneSetOfUpsertKeys(filter, Set.of(ImmutableBitSet.of(1, 2))))