Skip to content

Commit 6e842d3

Browse files
fix failed cases
1 parent e8be1f7 commit 6e842d3

File tree

25 files changed

+1038
-159
lines changed

25 files changed

+1038
-159
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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
39+
@Test
40+
void testCreateNestedArrayInstanceMultipleTimes() {
41+
AlignedArray array = new AlignedArray();
42+
BinaryArray nested1 = array.createNestedArrayInstance();
43+
BinaryArray nested2 = array.createNestedArrayInstance();
44+
45+
assertThat(nested1).isInstanceOf(AlignedArray.class);
46+
assertThat(nested2).isInstanceOf(AlignedArray.class);
47+
assertThat(nested1).isNotSameAs(nested2);
48+
}
49+
50+
@Test
51+
void testSerializable() {
52+
AlignedArray array = new AlignedArray();
53+
assertThat(array).isInstanceOf(java.io.Serializable.class);
54+
}
55+
}
56+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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.types.ArrayType;
24+
import org.apache.fluss.types.DataTypes;
25+
import org.apache.fluss.types.RowType;
26+
27+
import org.junit.jupiter.api.Test;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
31+
32+
/** Test for {@link CompactedArray}. */
33+
class CompactedArrayTest {
34+
35+
@Test
36+
void testCreateNestedArrayInstanceWithArrayType() {
37+
ArrayType innerArrayType = DataTypes.ARRAY(DataTypes.INT());
38+
CompactedArray array = new CompactedArray(innerArrayType);
39+
40+
BinaryArray nestedArray = array.createNestedArrayInstance();
41+
assertThat(nestedArray).isInstanceOf(CompactedArray.class);
42+
}
43+
44+
@Test
45+
void testCreateNestedArrayInstanceWithNonArrayTypeThrowsException() {
46+
CompactedArray array = new CompactedArray(DataTypes.INT());
47+
48+
assertThatThrownBy(() -> array.createNestedArrayInstance())
49+
.isInstanceOf(IllegalArgumentException.class)
50+
.hasMessageContaining("Can not get nested array from Array of type");
51+
}
52+
53+
@Test
54+
void testNestedArrayCreation() {
55+
ArrayType nestedArrayType = DataTypes.ARRAY(DataTypes.ARRAY(DataTypes.STRING()));
56+
CompactedArray outerArray = new CompactedArray(nestedArrayType);
57+
58+
BinaryArray innerArray = outerArray.createNestedArrayInstance();
59+
assertThat(innerArray).isInstanceOf(CompactedArray.class);
60+
61+
CompactedArray innerCompactedArray = (CompactedArray) innerArray;
62+
BinaryArray innerInnerArray = innerCompactedArray.createNestedArrayInstance();
63+
assertThat(innerInnerArray).isInstanceOf(CompactedArray.class);
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+
73+
@Test
74+
void testConstructorWithPrimitiveType() {
75+
CompactedArray array = new CompactedArray(DataTypes.INT());
76+
assertThat(array).isNotNull();
77+
}
78+
79+
@Test
80+
void testSerializable() {
81+
CompactedArray array = new CompactedArray(DataTypes.INT());
82+
assertThat(array).isInstanceOf(java.io.Serializable.class);
83+
}
84+
}
85+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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.types.ArrayType;
24+
import org.apache.fluss.types.DataTypes;
25+
import org.apache.fluss.types.RowType;
26+
27+
import org.junit.jupiter.api.Test;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
31+
32+
/** Test for {@link IndexedArray}. */
33+
class IndexedArrayTest {
34+
35+
@Test
36+
void testCreateNestedArrayInstanceWithArrayType() {
37+
ArrayType innerArrayType = DataTypes.ARRAY(DataTypes.INT());
38+
IndexedArray array = new IndexedArray(innerArrayType);
39+
40+
BinaryArray nestedArray = array.createNestedArrayInstance();
41+
assertThat(nestedArray).isInstanceOf(IndexedArray.class);
42+
}
43+
44+
@Test
45+
void testCreateNestedArrayInstanceWithNonArrayTypeThrowsException() {
46+
IndexedArray array = new IndexedArray(DataTypes.INT());
47+
48+
assertThatThrownBy(() -> array.createNestedArrayInstance())
49+
.isInstanceOf(IllegalArgumentException.class)
50+
.hasMessageContaining("Can not get nested array from Array of type");
51+
}
52+
53+
@Test
54+
void testNestedArrayCreation() {
55+
ArrayType nestedArrayType = DataTypes.ARRAY(DataTypes.ARRAY(DataTypes.STRING()));
56+
IndexedArray outerArray = new IndexedArray(nestedArrayType);
57+
58+
BinaryArray innerArray = outerArray.createNestedArrayInstance();
59+
assertThat(innerArray).isInstanceOf(IndexedArray.class);
60+
61+
IndexedArray innerIndexedArray = (IndexedArray) innerArray;
62+
BinaryArray innerInnerArray = innerIndexedArray.createNestedArrayInstance();
63+
assertThat(innerInnerArray).isInstanceOf(IndexedArray.class);
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+
73+
@Test
74+
void testConstructorWithPrimitiveType() {
75+
IndexedArray array = new IndexedArray(DataTypes.INT());
76+
assertThat(array).isNotNull();
77+
}
78+
79+
@Test
80+
void testSerializable() {
81+
IndexedArray array = new IndexedArray(DataTypes.INT());
82+
assertThat(array).isInstanceOf(java.io.Serializable.class);
83+
}
84+
}
85+

0 commit comments

Comments
 (0)