Skip to content
Merged
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 @@ -314,80 +314,6 @@ public void testMultiSequenceFieldsRepeatDefine() {
.hasMessageContaining("is defined repeatedly by multiple groups");
}

@Test
public void testAdjustProjectionRepeatProject() {
Options options = new Options();
options.set("fields.f4.sequence-group", "f1,f3");
options.set("fields.f5.sequence-group", "f7");
RowType rowType =
RowType.of(
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT());
// the field 'f1' is projected twice
int[][] projection = new int[][] {{1}, {1}, {3}, {7}};
MergeFunctionFactory<KeyValue> factory =
PartialUpdateMergeFunction.factory(options, rowType, ImmutableList.of("f0"));
MergeFunctionFactory.AdjustedProjection adjustedProjection =
factory.adjustProjection(projection);

validate(adjustedProjection, new int[] {1, 1, 3, 7, 4, 5}, new int[] {0, 1, 2, 3});

MergeFunction<KeyValue> func = factory.create(adjustedProjection.pushdownProjection);
func.reset();
add(func, 1, 1, 1, 1, 1, 1);
add(func, 2, 2, 6, 2, 2, 2);
validate(func, 2, 2, 6, 2, 2, 2);

// enable field updated by null
add(func, 3, 3, null, 7, 4, null);
validate(func, 3, 3, null, 2, 4, 2);
}

@Test
public void testMultiSequenceFieldsAdjustProjectionRepeatProject() {
Options options = new Options();
options.set("fields.f2,f4.sequence-group", "f1,f3");
options.set("fields.f5,f6.sequence-group", "f7");
RowType rowType =
RowType.of(
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT(),
DataTypes.INT());
// the field 'f1' is projected twice
int[][] projection = new int[][] {{1}, {1}, {3}, {7}};
MergeFunctionFactory<KeyValue> factory =
PartialUpdateMergeFunction.factory(options, rowType, ImmutableList.of("f0"));
MergeFunctionFactory.AdjustedProjection adjustedProjection =
factory.adjustProjection(projection);

validate(adjustedProjection, new int[] {1, 1, 3, 7, 2, 4, 5, 6}, new int[] {0, 1, 2, 3});

MergeFunction<KeyValue> func = factory.create(adjustedProjection.pushdownProjection);
func.reset();
add(func, 1, 1, 1, 1, 1, 1, 1, 1);
add(func, 2, 2, 6, 2, 2, 2, 2, 6);
validate(func, 2, 2, 6, 2, 2, 2, 2, 6);

// update first sequence group
add(func, 3, 3, null, 7, 4, null, 1, 8);
validate(func, 3, 3, null, 2, 4, null, 2, 6);

// update second sequence group
add(func, 5, 5, 3, 3, 3, 5, 5, 6);
validate(func, 5, 3, null, 3, 4, null, 5, 6);
}

@Test
public void testAdjustProjectionSequenceFieldsProject() {
Options options = new Options();
Expand Down
Loading