This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new e898726b42 [core] Fix field ID mismatch in AllTablesTable,
AllPartitionsTable and AllTableOptionsTable (#6973)
e898726b42 is described below
commit e898726b4224e433862fdf4aefd30f311db9a793
Author: XiaoHongbo <[email protected]>
AuthorDate: Thu Jan 8 13:03:52 2026 +0800
[core] Fix field ID mismatch in AllTablesTable, AllPartitionsTable and
AllTableOptionsTable (#6973)
---
.../paimon/table/system/AllPartitionsTable.java | 5 +---
.../paimon/table/system/AllTableOptionsTable.java | 5 +---
.../apache/paimon/table/system/AllTablesTable.java | 5 +---
.../table/system/AllPartitionsTableTest.java | 35 ++++++++++++++++++++++
.../table/system/AllTableOptionsTableTest.java | 33 ++++++++++++++++++++
.../paimon/table/system/AllTablesTableTest.java | 33 ++++++++++++++++++++
6 files changed, 104 insertions(+), 12 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/system/AllPartitionsTable.java
b/paimon-core/src/main/java/org/apache/paimon/table/system/AllPartitionsTable.java
index fd2790b9c6..b73a403c53 100644
---
a/paimon-core/src/main/java/org/apache/paimon/table/system/AllPartitionsTable.java
+++
b/paimon-core/src/main/java/org/apache/paimon/table/system/AllPartitionsTable.java
@@ -213,10 +213,7 @@ public class AllPartitionsTable implements ReadonlyTable {
iterator =
Iterators.transform(
iterator,
- row ->
- ProjectedRow.from(
- readType,
AggregationFieldsTable.TABLE_TYPE)
- .replaceRow(row));
+ row -> ProjectedRow.from(readType,
TABLE_TYPE).replaceRow(row));
}
//noinspection ReassignedVariable,unchecked
return new IteratorRecordReader<>((Iterator<InternalRow>)
iterator);
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/system/AllTableOptionsTable.java
b/paimon-core/src/main/java/org/apache/paimon/table/system/AllTableOptionsTable.java
index 4bf7efadb0..6e70da201d 100644
---
a/paimon-core/src/main/java/org/apache/paimon/table/system/AllTableOptionsTable.java
+++
b/paimon-core/src/main/java/org/apache/paimon/table/system/AllTableOptionsTable.java
@@ -206,10 +206,7 @@ public class AllTableOptionsTable implements ReadonlyTable
{
iterator =
Iterators.transform(
iterator,
- row ->
- ProjectedRow.from(
- readType,
AggregationFieldsTable.TABLE_TYPE)
- .replaceRow(row));
+ row -> ProjectedRow.from(readType,
TABLE_TYPE).replaceRow(row));
}
return new IteratorRecordReader<>(iterator);
}
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/system/AllTablesTable.java
b/paimon-core/src/main/java/org/apache/paimon/table/system/AllTablesTable.java
index d88c674728..4c29a5145b 100644
---
a/paimon-core/src/main/java/org/apache/paimon/table/system/AllTablesTable.java
+++
b/paimon-core/src/main/java/org/apache/paimon/table/system/AllTablesTable.java
@@ -233,10 +233,7 @@ public class AllTablesTable implements ReadonlyTable {
iterator =
Iterators.transform(
iterator,
- row ->
- ProjectedRow.from(
- readType,
AggregationFieldsTable.TABLE_TYPE)
- .replaceRow(row));
+ row -> ProjectedRow.from(readType,
TABLE_TYPE).replaceRow(row));
}
//noinspection ReassignedVariable,unchecked
return new IteratorRecordReader<>((Iterator<InternalRow>)
iterator);
diff --git
a/paimon-core/src/test/java/org/apache/paimon/table/system/AllPartitionsTableTest.java
b/paimon-core/src/test/java/org/apache/paimon/table/system/AllPartitionsTableTest.java
index 2dfdbcae8a..e5cca01f45 100644
---
a/paimon-core/src/test/java/org/apache/paimon/table/system/AllPartitionsTableTest.java
+++
b/paimon-core/src/test/java/org/apache/paimon/table/system/AllPartitionsTableTest.java
@@ -20,9 +20,15 @@ package org.apache.paimon.table.system;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.reader.RecordReader;
import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.ReadonlyTable;
import org.apache.paimon.table.TableTestBase;
+import org.apache.paimon.table.source.InnerTableRead;
+import org.apache.paimon.table.source.InnerTableScan;
import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -33,6 +39,7 @@ import java.util.stream.Collectors;
import static org.apache.paimon.catalog.Catalog.SYSTEM_DATABASE_NAME;
import static org.apache.paimon.table.system.AllPartitionsTable.ALL_PARTITIONS;
+import static org.apache.paimon.table.system.AllPartitionsTable.TABLE_TYPE;
import static org.assertj.core.api.Assertions.assertThat;
/** Unit tests for {@link AllPartitionsTable}. */
@@ -67,4 +74,32 @@ public class AllPartitionsTableTest extends TableTestBase {
result = result.stream().filter(r ->
!r.contains("path")).collect(Collectors.toList());
assertThat(result.get(0).toString()).startsWith("+I(default,T,f1=1,1,680,1,");
}
+
+ @Test
+ void testAllPartitionsTableWithProjection() throws Exception {
+ ReadonlyTable table = allPartitionsTable;
+
+ RowType readType =
+ new RowType(
+ java.util.Arrays.asList(
+ TABLE_TYPE.getField(0), // database_name
+ TABLE_TYPE.getField(1), // table_name
+ TABLE_TYPE.getField(5))); // file_count (field
ID 5)
+
+ InnerTableScan scan = table.newScan();
+ InnerTableRead read = table.newRead().withReadType(readType);
+
+ List<InternalRow> rows = new java.util.ArrayList<>();
+ try (RecordReader<InternalRow> reader =
read.createReader(scan.plan())) {
+ reader.forEachRemaining(rows::add);
+ }
+
+ assertThat(rows).isNotEmpty();
+ for (InternalRow row : rows) {
+ assertThat(row.getFieldCount()).isEqualTo(3);
+ if (!row.isNullAt(2)) {
+ row.getLong(2);
+ }
+ }
+ }
}
diff --git
a/paimon-core/src/test/java/org/apache/paimon/table/system/AllTableOptionsTableTest.java
b/paimon-core/src/test/java/org/apache/paimon/table/system/AllTableOptionsTableTest.java
index 16e3baadfa..7c2641c8be 100644
---
a/paimon-core/src/test/java/org/apache/paimon/table/system/AllTableOptionsTableTest.java
+++
b/paimon-core/src/test/java/org/apache/paimon/table/system/AllTableOptionsTableTest.java
@@ -19,9 +19,15 @@
package org.apache.paimon.table.system;
import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.reader.RecordReader;
import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.ReadonlyTable;
import org.apache.paimon.table.TableTestBase;
+import org.apache.paimon.table.source.InnerTableRead;
+import org.apache.paimon.table.source.InnerTableScan;
import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -32,6 +38,7 @@ import java.util.stream.Collectors;
import static org.apache.paimon.catalog.Catalog.SYSTEM_DATABASE_NAME;
import static
org.apache.paimon.table.system.AllTableOptionsTable.ALL_TABLE_OPTIONS;
+import static org.apache.paimon.table.system.AllTableOptionsTable.TABLE_TYPE;
import static org.assertj.core.api.Assertions.assertThat;
/** Unit tests for {@link AllTableOptionsTable}. */
@@ -71,4 +78,30 @@ public class AllTableOptionsTableTest extends TableTestBase {
"+I(default,T,merge-engine,aggregation)",
"+I(default,T,fields.price.aggregate-function,max)");
}
+
+ @Test
+ void testAllTableOptionsTableWithProjection() throws Exception {
+ ReadonlyTable table = allTableOptionsTable;
+
+ RowType readType =
+ new RowType(
+ java.util.Arrays.asList(
+ TABLE_TYPE.getField(0), // database_name
+ TABLE_TYPE.getField(1), // table_name
+ TABLE_TYPE.getField(3))); // value (field ID 3)
+
+ InnerTableScan scan = table.newScan();
+ InnerTableRead read = table.newRead().withReadType(readType);
+
+ List<InternalRow> rows = new java.util.ArrayList<>();
+ try (RecordReader<InternalRow> reader =
read.createReader(scan.plan())) {
+ reader.forEachRemaining(rows::add);
+ }
+
+ assertThat(rows).isNotEmpty();
+ for (InternalRow row : rows) {
+ assertThat(row.getFieldCount()).isEqualTo(3);
+ assertThat(row.isNullAt(2) || row.getString(2) != null).isTrue();
+ }
+ }
}
diff --git
a/paimon-core/src/test/java/org/apache/paimon/table/system/AllTablesTableTest.java
b/paimon-core/src/test/java/org/apache/paimon/table/system/AllTablesTableTest.java
index 9f47688cf1..e55dc5a607 100644
---
a/paimon-core/src/test/java/org/apache/paimon/table/system/AllTablesTableTest.java
+++
b/paimon-core/src/test/java/org/apache/paimon/table/system/AllTablesTableTest.java
@@ -19,9 +19,15 @@
package org.apache.paimon.table.system;
import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.reader.RecordReader;
import org.apache.paimon.schema.Schema;
+import org.apache.paimon.table.ReadonlyTable;
import org.apache.paimon.table.TableTestBase;
+import org.apache.paimon.table.source.InnerTableRead;
+import org.apache.paimon.table.source.InnerTableScan;
import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -32,6 +38,7 @@ import java.util.stream.Collectors;
import static org.apache.paimon.catalog.Catalog.SYSTEM_DATABASE_NAME;
import static org.apache.paimon.table.system.AllTablesTable.ALL_TABLES;
+import static org.apache.paimon.table.system.AllTablesTable.TABLE_TYPE;
import static org.assertj.core.api.Assertions.assertThat;
/** Unit tests for {@link AllTablesTable}. */
@@ -64,4 +71,30 @@ public class AllTablesTableTest extends TableTestBase {
.containsOnly(
"+I(default,T,table,true,true,null,null,null,null,null,null,null,null,null)");
}
+
+ @Test
+ void testAllTablesTableWithOwnerField() throws Exception {
+ ReadonlyTable table = allTablesTable;
+
+ RowType readType =
+ new RowType(
+ java.util.Arrays.asList(
+ TABLE_TYPE.getField(0), // database_name
+ TABLE_TYPE.getField(1), // table_name
+ TABLE_TYPE.getField(5))); // owner (field ID 5)
+
+ InnerTableScan scan = table.newScan();
+ InnerTableRead read = table.newRead().withReadType(readType);
+
+ List<InternalRow> rows = new java.util.ArrayList<>();
+ try (RecordReader<InternalRow> reader =
read.createReader(scan.plan())) {
+ reader.forEachRemaining(rows::add);
+ }
+
+ assertThat(rows).isNotEmpty();
+ for (InternalRow row : rows) {
+ assertThat(row.getFieldCount()).isEqualTo(3);
+ assertThat(row.isNullAt(2) || row.getString(2) != null).isTrue();
+ }
+ }
}