Skip to content

Commit cd49603

Browse files
fix failed cases
1 parent e8be1f7 commit cd49603

File tree

27 files changed

+998
-566
lines changed

27 files changed

+998
-566
lines changed

fluss-client/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@
113113
<include>*:*</include>
114114
</includes>
115115
</artifactSet>
116-
<filters>
117-
<filter>
118-
<artifact>*</artifact>
119-
<excludes>
120-
<exclude>LICENSE*</exclude>
121-
</excludes>
122-
</filter>
123-
</filters>
124116
</configuration>
125117
</execution>
126118
</executions>

fluss-client/src/test/java/org/apache/fluss/client/table/scanner/log/DefaultCompletedFetchTest.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,32 @@ void testComplexTypeFetch() throws Exception {
227227
new Object[] {
228228
1,
229229
new String[] {"a", "b"},
230-
new Object[] {new int[] {1, 2}, new int[] {3, 4}}
230+
new Object[] {new int[] {1, 2}, new int[] {3, 4}},
231+
new Object[] {10, new Object[] {20, "nested"}, "row1"}
231232
},
232233
new Object[] {
233-
2, new String[] {"c", null}, new Object[] {null, new int[] {3, 4}}
234+
2,
235+
new String[] {"c", null},
236+
new Object[] {null, new int[] {3, 4}},
237+
new Object[] {30, new Object[] {40, "test"}, "row2"}
234238
},
235239
new Object[] {
236240
3,
237241
new String[] {"e", "f"},
238-
new Object[] {new int[] {5, 6, 7}, new int[] {8}}
242+
new Object[] {new int[] {5, 6, 7}, new int[] {8}},
243+
new Object[] {50, new Object[] {60, "value"}, "row3"}
239244
});
240245
Schema schema =
241246
Schema.newBuilder()
242247
.column("a", DataTypes.INT())
243248
.column("b", DataTypes.ARRAY(DataTypes.STRING()))
244249
.column("c", DataTypes.ARRAY(DataTypes.ARRAY(DataTypes.INT())))
250+
.column(
251+
"d",
252+
DataTypes.ROW(
253+
DataTypes.INT(),
254+
DataTypes.ROW(DataTypes.INT(), DataTypes.STRING()),
255+
DataTypes.STRING()))
245256
.build();
246257
TableInfo tableInfo =
247258
TableInfo.of(
@@ -299,6 +310,17 @@ void testComplexTypeFetch() throws Exception {
299310
.isEqualTo(Arrays.deepToString((Object[]) complexData.get(i)[1]));
300311
assertThat(row.getArray(2).toString())
301312
.isEqualTo(Arrays.deepToString((Object[]) complexData.get(i)[2]));
313+
InternalRow nestedRow = row.getRow(3, 3);
314+
assertThat(nestedRow).isNotNull();
315+
assertThat(nestedRow.getInt(0)).isEqualTo(((Object[]) complexData.get(i)[3])[0]);
316+
InternalRow deeplyNestedRow = nestedRow.getRow(1, 2);
317+
assertThat(deeplyNestedRow).isNotNull();
318+
assertThat(deeplyNestedRow.getInt(0))
319+
.isEqualTo(((Object[]) ((Object[]) complexData.get(i)[3])[1])[0]);
320+
assertThat(deeplyNestedRow.getString(1).toString())
321+
.isEqualTo(((Object[]) ((Object[]) complexData.get(i)[3])[1])[1]);
322+
assertThat(nestedRow.getString(2).toString())
323+
.isEqualTo(((Object[]) complexData.get(i)[3])[2]);
302324
}
303325
}
304326

fluss-common/src/test/java/org/apache/fluss/row/TestInternalRowGenerator.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,15 @@ public static RowType createAllRowType() {
6363
new DataField("f17", DataTypes.TIMESTAMP_LTZ(1)),
6464
new DataField("f18", DataTypes.TIMESTAMP_LTZ(5)),
6565
new DataField("f19", DataTypes.ARRAY(DataTypes.INT())),
66-
// TODO: Add Map and Row fields in Issue #1973
6766
new DataField(
6867
"f20",
68+
DataTypes.ARRAY(DataTypes.FLOAT().copy(false))), // vector embedding type
69+
new DataField(
70+
"f21",
71+
DataTypes.ARRAY(DataTypes.ARRAY(DataTypes.STRING()))), // nested array
72+
// TODO: Add Map and Row fields in Issue #1973
73+
new DataField(
74+
"f22",
6975
DataTypes.ROW(
7076
new DataField("u1", DataTypes.INT()),
7177
new DataField(
@@ -123,6 +129,17 @@ public static IndexedRow genIndexedRowForAllType() {
123129
GenericArray array1 = GenericArray.of(1, 2, 3, 4, 5, -11, null, 444, 102234);
124130
setRandomNull(writers[19], writer, 19, rnd, array1);
125131

132+
GenericArray array2 =
133+
GenericArray.of(0.1f, 1.1f, -0.5f, 6.6f, Float.MAX_VALUE, Float.MIN_VALUE);
134+
setRandomNull(writers[20], writer, 20, rnd, array2);
135+
136+
GenericArray array3 =
137+
GenericArray.of(
138+
GenericArray.of(fromString("a"), null, fromString("c")),
139+
null,
140+
GenericArray.of(fromString("hello"), fromString("world")));
141+
setRandomNull(writers[21], writer, 21, rnd, array3);
142+
126143
// TODO: Map type support will be added in Issue #1973
127144
// Map<Object, Object> javaMap = new HashMap<>();
128145
// javaMap.put(0, null);
@@ -131,9 +148,9 @@ public static IndexedRow genIndexedRowForAllType() {
131148
// GenericMap map = new GenericMap(javaMap);
132149
// setRandomNull(writers[20], writer, 20, rnd, map);
133150

134-
GenericRow innerRow = GenericRow.of(20);
151+
GenericRow innerRow = GenericRow.of(22);
135152
GenericRow genericRow = GenericRow.of(123, innerRow, BinaryString.fromString("Test"));
136-
setRandomNull(writers[20], writer, 20, rnd, genericRow);
153+
setRandomNull(writers[22], writer, 22, rnd, genericRow);
137154

138155
IndexedRow row = new IndexedRow(dataTypes);
139156
row.pointTo(writer.segment(), 0, writer.position());
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fluss.row.array;
21+
22+
import org.apache.fluss.row.BinaryArray;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
28+
/** Test for {@link AlignedArray}. */
29+
class AlignedArrayTest {
30+
31+
@Test
32+
void testCreateNestedArrayInstance() {
33+
AlignedArray array = new AlignedArray();
34+
BinaryArray nested = array.createNestedArrayInstance();
35+
assertThat(nested).isInstanceOf(AlignedArray.class);
36+
assertThat(nested).isNotSameAs(array);
37+
}
38+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fluss.row.array;
21+
22+
import org.apache.fluss.row.BinaryArray;
23+
import org.apache.fluss.row.BinaryArrayWriter;
24+
import org.apache.fluss.types.ArrayType;
25+
import org.apache.fluss.types.DataTypes;
26+
import org.apache.fluss.types.RowType;
27+
28+
import org.junit.jupiter.api.Test;
29+
30+
import static org.assertj.core.api.Assertions.assertThat;
31+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
32+
33+
/** Test for {@link CompactedArray}. */
34+
class CompactedArrayTest {
35+
36+
@Test
37+
void testGetRowWithNonRowType() {
38+
CompactedArray array = new CompactedArray(DataTypes.INT());
39+
BinaryArrayWriter writer = new BinaryArrayWriter(array, 1, 4);
40+
writer.writeInt(0, 42);
41+
writer.complete();
42+
43+
assertThatThrownBy(() -> array.getRow(0, 1))
44+
.isInstanceOf(IllegalArgumentException.class)
45+
.hasMessageContaining("Can not get row from Array of type");
46+
}
47+
48+
@Test
49+
void testCreateNestedArrayWithArrayType() {
50+
ArrayType arrayType = DataTypes.ARRAY(DataTypes.INT());
51+
CompactedArray array = new CompactedArray(arrayType);
52+
53+
BinaryArray nested = array.createNestedArrayInstance();
54+
assertThat(nested).isInstanceOf(CompactedArray.class);
55+
}
56+
57+
@Test
58+
void testCreateNestedArrayWithNonArrayType() {
59+
CompactedArray array = new CompactedArray(DataTypes.INT());
60+
61+
assertThatThrownBy(() -> array.createNestedArrayInstance())
62+
.isInstanceOf(IllegalArgumentException.class)
63+
.hasMessageContaining("Can not get nested array from Array of type");
64+
}
65+
66+
@Test
67+
void testConstructorWithRowType() {
68+
RowType rowType = RowType.of(DataTypes.INT(), DataTypes.STRING());
69+
CompactedArray array = new CompactedArray(rowType);
70+
assertThat(array).isNotNull();
71+
}
72+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fluss.row.array;
21+
22+
import org.apache.fluss.row.BinaryArray;
23+
import org.apache.fluss.row.BinaryArrayWriter;
24+
import org.apache.fluss.types.ArrayType;
25+
import org.apache.fluss.types.DataTypes;
26+
import org.apache.fluss.types.RowType;
27+
28+
import org.junit.jupiter.api.Test;
29+
30+
import static org.assertj.core.api.Assertions.assertThat;
31+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
32+
33+
/** Test for {@link IndexedArray}. */
34+
class IndexedArrayTest {
35+
36+
@Test
37+
void testGetRowWithNonRowType() {
38+
IndexedArray array = new IndexedArray(DataTypes.INT());
39+
BinaryArrayWriter writer = new BinaryArrayWriter(array, 1, 4);
40+
writer.writeInt(0, 42);
41+
writer.complete();
42+
43+
assertThatThrownBy(() -> array.getRow(0, 1))
44+
.isInstanceOf(IllegalArgumentException.class)
45+
.hasMessageContaining("Can not get row from Array of type");
46+
}
47+
48+
@Test
49+
void testCreateNestedArrayWithArrayType() {
50+
ArrayType arrayType = DataTypes.ARRAY(DataTypes.INT());
51+
IndexedArray array = new IndexedArray(arrayType);
52+
53+
BinaryArray nested = array.createNestedArrayInstance();
54+
assertThat(nested).isInstanceOf(IndexedArray.class);
55+
}
56+
57+
@Test
58+
void testCreateNestedArrayWithNonArrayType() {
59+
IndexedArray array = new IndexedArray(DataTypes.INT());
60+
61+
assertThatThrownBy(() -> array.createNestedArrayInstance())
62+
.isInstanceOf(IllegalArgumentException.class)
63+
.hasMessageContaining("Can not get nested array from Array of type");
64+
}
65+
66+
@Test
67+
void testConstructorWithRowType() {
68+
RowType rowType = RowType.of(DataTypes.INT(), DataTypes.STRING());
69+
IndexedArray array = new IndexedArray(rowType);
70+
assertThat(array).isNotNull();
71+
}
72+
}

0 commit comments

Comments
 (0)