|
21 | 21 | import org.apache.paimon.KeyValue; |
22 | 22 | import org.apache.paimon.data.GenericRow; |
23 | 23 | import org.apache.paimon.options.Options; |
| 24 | +import org.apache.paimon.types.DataType; |
24 | 25 | import org.apache.paimon.types.DataTypes; |
25 | 26 | import org.apache.paimon.types.RowKind; |
26 | 27 | import org.apache.paimon.types.RowType; |
|
31 | 32 | import org.junit.jupiter.api.Test; |
32 | 33 |
|
33 | 34 | import static org.apache.paimon.CoreOptions.FIELDS_DEFAULT_AGG_FUNC; |
| 35 | +import static org.apache.paimon.testutils.assertj.PaimonAssertions.anyCauseMatches; |
34 | 36 | import static org.assertj.core.api.Assertions.assertThat; |
35 | 37 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
36 | 38 |
|
@@ -820,14 +822,39 @@ public void testMultiSequenceFieldsPartialUpdateWithAggregationProjectPushDown() |
820 | 822 |
|
821 | 823 | @Test |
822 | 824 | public void testAggregationWithoutSequenceGroup() { |
823 | | - Options options = new Options(); |
824 | | - options.set("fields.f1.aggregate-function", "listagg"); |
825 | | - RowType rowType = RowType.of(DataTypes.INT(), DataTypes.INT()); |
| 825 | + RowType rowType = |
| 826 | + RowType.of( |
| 827 | + new DataType[] { |
| 828 | + DataTypes.INT(), |
| 829 | + DataTypes.INT(), |
| 830 | + DataTypes.INT(), |
| 831 | + DataTypes.INT(), |
| 832 | + DataTypes.INT() |
| 833 | + }, |
| 834 | + new String[] {"pk", "f0", "g0", "f1", "g1"}); |
| 835 | + |
| 836 | + Options options1 = new Options(); |
| 837 | + options1.set("fields.f0.aggregate-function", "listagg"); |
| 838 | + options1.set("fields.f1.aggregate-function", "listagg"); |
826 | 839 | assertThatThrownBy( |
827 | 840 | () -> |
828 | 841 | PartialUpdateMergeFunction.factory( |
829 | | - options, rowType, ImmutableList.of("f0"))) |
830 | | - .hasMessageContaining("Must use sequence group for aggregation functions"); |
| 842 | + options1, rowType, ImmutableList.of("pk"))) |
| 843 | + .satisfies( |
| 844 | + anyCauseMatches( |
| 845 | + IllegalArgumentException.class, |
| 846 | + "Must use sequence group for aggregation functions but not found for field f0.")); |
| 847 | + |
| 848 | + Options options2 = new Options(options1.toMap()); |
| 849 | + options2.set("fields.g0.sequence-group", "f0"); |
| 850 | + assertThatThrownBy( |
| 851 | + () -> |
| 852 | + PartialUpdateMergeFunction.factory( |
| 853 | + options2, rowType, ImmutableList.of("pk"))) |
| 854 | + .satisfies( |
| 855 | + anyCauseMatches( |
| 856 | + IllegalArgumentException.class, |
| 857 | + "Must use sequence group for aggregation functions but not found for field f1.")); |
831 | 858 | } |
832 | 859 |
|
833 | 860 | private void add(MergeFunction<KeyValue> function, Integer... f) { |
|
0 commit comments