Skip to content
Merged
Show file tree
Hide file tree
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 @@ -72,13 +72,8 @@ public RowType rowType() {
List<DataField> fields = new ArrayList<>();
fields.add(SpecialFields.ROW_KIND);
for (DataField field : wrapped.rowType().getFields()) {
DataField newField =
new DataField(
field.id(),
field.name(),
new ArrayType(field.type().nullable()), // convert to nullable
field.description());
fields.add(newField);
// convert to nullable
fields.add(field.newType(new ArrayType(field.type().nullable())));
}
return new RowType(fields);
}
Expand All @@ -99,6 +94,19 @@ private BinlogRead(InnerTableRead dataRead) {
super(dataRead);
}

@Override
public InnerTableRead withReadType(RowType readType) {
List<DataField> fields = new ArrayList<>();
for (DataField field : readType.getFields()) {
if (field.name().equals(SpecialFields.ROW_KIND.name())) {
fields.add(field);
} else {
fields.add(field.newType(((ArrayType) field.type()).getElementType()));
}
}
return super.withReadType(readType.copy(fields));
}

@Override
public RecordReader<InternalRow> createReader(Split split) throws IOException {
DataSplit dataSplit = (DataSplit) split;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,20 @@ class PaimonSystemTableTest extends PaimonSparkTestBase {
spark.sql("select partition,bucket from `T$buckets`"),
Row("[2024-10-10, 01]", 0) :: Row("[2024-10-10, 01]", 1) :: Row("[2024-10-10, 01]", 2) :: Nil)
}

test("system table: binlog table") {
sql("""
|CREATE TABLE T (a INT, b INT)
|TBLPROPERTIES ('primary-key'='a', 'changelog-producer' = 'lookup', 'bucket' = '2')
|""".stripMargin)

sql("INSERT INTO T VALUES (1, 2)")
sql("INSERT INTO T VALUES (1, 3)")
sql("INSERT INTO T VALUES (2, 2)")

checkAnswer(
sql("SELECT * FROM `T$binlog`"),
Seq(Row("+I", Array(1), Array(3)), Row("+I", Array(2), Array(2)))
)
}
}
Loading