-
Notifications
You must be signed in to change notification settings - Fork 458
[lake/paimon] Support NestedRow types for tiering paimon #2260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -489,6 +489,93 @@ private String getPartitionOffsetStr(Map<Long, String> partitionNameByIds) { | |
| return "[" + String.join(",", partitionOffsetStrs) + "]"; | ||
| } | ||
|
|
||
| private static Stream<Arguments> tieringNestedRowWriteArgs() { | ||
| return Stream.of(Arguments.of(true), Arguments.of(false)); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @MethodSource("tieringNestedRowWriteArgs") | ||
| void testTieringForNestedRow(boolean isPrimaryKeyTable) throws Exception { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The IT cases are already quite heavy. This PR adds two new IT cases, but we should avoid introducing additional ones if we can reuse existing tests instead. In particular, it would be more efficient to add the new row-based test scenarios directly into For reference, see how this was done in: #2166.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Okay, I'll make the changes. |
||
| TablePath t1 = | ||
| TablePath.of( | ||
| DEFAULT_DB, | ||
| isPrimaryKeyTable ? "pkTableForNestedRow" : "logTableForNestedRow"); | ||
|
|
||
| Schema.Builder builder = | ||
| Schema.newBuilder() | ||
| .column("c0", DataTypes.INT()) | ||
| .column("c1", DataTypes.STRING()) | ||
| .column( | ||
| "c2", | ||
| DataTypes.ROW( | ||
| DataTypes.FIELD("nested_int", DataTypes.INT()), | ||
| DataTypes.FIELD("nested_string", DataTypes.STRING()), | ||
| DataTypes.FIELD("nested_double", DataTypes.DOUBLE()))); | ||
|
|
||
| if (isPrimaryKeyTable) { | ||
| builder.primaryKey("c0", "c1"); | ||
| } | ||
|
|
||
| TableDescriptor.Builder tableDescriptor = | ||
| TableDescriptor.builder() | ||
| .schema(builder.build()) | ||
| .distributedBy(1, "c0") | ||
| .property(ConfigOptions.TABLE_DATALAKE_ENABLED.key(), "true") | ||
| .property(ConfigOptions.TABLE_DATALAKE_FRESHNESS, Duration.ofMillis(500)); | ||
| tableDescriptor.customProperties(Collections.emptyMap()); | ||
| tableDescriptor.properties(Collections.emptyMap()); | ||
| long t1Id = createTable(t1, tableDescriptor.build()); | ||
| TableBucket t1Bucket = new TableBucket(t1Id, 0); | ||
|
|
||
| List<InternalRow> rows = | ||
| Collections.singletonList( | ||
| row( | ||
| builder.build().getRowType(), | ||
| 1, | ||
| "outer_value", | ||
| new Object[] {100, "nested_value", 3.14})); | ||
| writeRows(t1, rows, !isPrimaryKeyTable); | ||
|
|
||
| if (isPrimaryKeyTable) { | ||
| waitUntilSnapshot(t1Id, 1, 0); | ||
| } | ||
|
|
||
| JobClient jobClient = buildTieringJob(execEnv); | ||
|
|
||
| try { | ||
| assertReplicaStatus(t1Bucket, 1); | ||
|
|
||
| Iterator<org.apache.paimon.data.InternalRow> paimonRowIterator = | ||
| getPaimonRowCloseableIterator(t1); | ||
| for (InternalRow expectedRow : rows) { | ||
| org.apache.paimon.data.InternalRow row = paimonRowIterator.next(); | ||
| assertThat(row.getInt(0)).isEqualTo(expectedRow.getInt(0)); | ||
| assertThat(row.getString(1).toString()) | ||
| .isEqualTo(expectedRow.getString(1).toString()); | ||
|
|
||
| org.apache.paimon.data.InternalRow paimonNestedRow = row.getRow(2, 3); | ||
| assertThat(paimonNestedRow).isNotNull(); | ||
| org.apache.fluss.row.InternalRow flussNestedRow = expectedRow.getRow(2, 3); | ||
| assertThat(paimonNestedRow.getInt(0)).isEqualTo(flussNestedRow.getInt(0)); | ||
| assertThat(paimonNestedRow.getString(1).toString()) | ||
| .isEqualTo(flussNestedRow.getString(1).toString()); | ||
| assertThat(paimonNestedRow.getDouble(2)).isEqualTo(flussNestedRow.getDouble(2)); | ||
| } | ||
|
|
||
| Map<String, String> properties = | ||
| new HashMap<String, String>() { | ||
| { | ||
| put( | ||
| FLUSS_LAKE_SNAP_BUCKET_OFFSET_PROPERTY, | ||
| "[{\"bucket\":0,\"offset\":1}]"); | ||
| } | ||
| }; | ||
| checkSnapshotPropertyInPaimon(t1, properties); | ||
| } finally { | ||
| jobClient.cancel().get(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void testTieringToDvEnabledTable() throws Exception { | ||
| TablePath t1 = TablePath.of(DEFAULT_DB, "pkTableWithDv"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace by
@ValueSource(booleans = {true, false})and removetieringNestedRowWriteArgsmethod.