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
42 changes: 21 additions & 21 deletions docs/content/concepts/system-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,45 +279,45 @@ You can query all manifest files contained in the latest snapshot or the specifi
SELECT * FROM my_table$manifests;

/*
+--------------------------------+-------------+------------------+-------------------+---------------+
| file_name | file_size | num_added_files | num_deleted_files | schema_id |
+--------------------------------+-------------+------------------+-------------------+---------------+
| manifest-f4dcab43-ef6b-4713... | 12365| 40 | 0 | 0 |
| manifest-f4dcab43-ef6b-4713... | 1648 | 1 | 0 | 0 |
+--------------------------------+-------------+------------------+-------------------+---------------+
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
| file_name | file_size | num_added_files | num_deleted_files | schema_id | min_partition_stats | max_partition_stats |
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
| manifest-f4dcab43-ef6b-4713... | 12365| 40 | 0 | 0 | {20230315, 00} | {20230315, 20} |
| manifest-f4dcab43-ef6b-4713... | 1648 | 1 | 0 | 0 | {20230115, 00} | {20230316, 23} |
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
2 rows in set
*/

-- You can also query the manifest with specified snapshot
SELECT * FROM my_table$manifests /*+ OPTIONS('scan.snapshot-id'='1') */;
/*
+--------------------------------+-------------+------------------+-------------------+---------------+
| file_name | file_size | num_added_files | num_deleted_files | schema_id |
+--------------------------------+-------------+------------------+-------------------+---------------+
| manifest-f4dcab43-ef6b-4713... | 12365| 40 | 0 | 0 |
+--------------------------------+-------------+------------------+-------------------+---------------+
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
| file_name | file_size | num_added_files | num_deleted_files | schema_id | min_partition_stats | max_partition_stats |
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
| manifest-f4dcab43-ef6b-4713... | 12365| 40 | 0 | 0 | {20230315, 00} | {20230315, 20} |
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
1 rows in set
*/

- You can also query the manifest with specified tagName
SELECT * FROM my_table$manifests /*+ OPTIONS('scan.tag-name'='tag1') */;
/*
+--------------------------------+-------------+------------------+-------------------+---------------+
| file_name | file_size | num_added_files | num_deleted_files | schema_id |
+--------------------------------+-------------+------------------+-------------------+---------------+
| manifest-f4dcab43-ef6b-4713... | 12365| 40 | 0 | 0 |
+--------------------------------+-------------+------------------+-------------------+---------------+
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
| file_name | file_size | num_added_files | num_deleted_files | schema_id | min_partition_stats | max_partition_stats |
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
| manifest-f4dcab43-ef6b-4713... | 12365| 40 | 0 | 0 | {20230315, 00} | {20230315, 20} |
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
1 rows in set
*/

- You can also query the manifest with specified timestamp in unix milliseconds
SELECT * FROM my_table$manifests /*+ OPTIONS('scan.timestamp-millis'='1678883047356') */;
/*
+--------------------------------+-------------+------------------+-------------------+---------------+
| file_name | file_size | num_added_files | num_deleted_files | schema_id |
+--------------------------------+-------------+------------------+-------------------+---------------+
| manifest-f4dcab43-ef6b-4713... | 12365| 40 | 0 | 0 |
+--------------------------------+-------------+------------------+-------------------+---------------+
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
| file_name | file_size | num_added_files | num_deleted_files | schema_id | min_partition_stats | max_partition_stats |
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
| manifest-f4dcab43-ef6b-4713... | 12365| 40 | 0 | 0 | {20230315, 00} | {20230315, 20} |
+--------------------------------+-------------+------------------+-------------------+---------------+---------------------+---------------------+
1 rows in set
*/
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import org.apache.paimon.CoreOptions;
import org.apache.paimon.Snapshot;
import org.apache.paimon.casting.CastExecutor;
import org.apache.paimon.casting.CastExecutors;
import org.apache.paimon.data.BinaryString;
import org.apache.paimon.data.GenericRow;
import org.apache.paimon.data.InternalRow;
Expand Down Expand Up @@ -64,7 +66,7 @@ public class ManifestsTable implements ReadonlyTable {

private static final Logger LOG = LoggerFactory.getLogger(ManifestsTable.class);

private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;

public static final String MANIFESTS = "manifests";

Expand All @@ -75,7 +77,15 @@ public class ManifestsTable implements ReadonlyTable {
new DataField(1, "file_size", new BigIntType(false)),
new DataField(2, "num_added_files", new BigIntType(false)),
new DataField(3, "num_deleted_files", new BigIntType(false)),
new DataField(4, "schema_id", new BigIntType(false))));
new DataField(4, "schema_id", new BigIntType(false)),
new DataField(
5,
"min_partition_stats",
SerializationUtils.newStringType(true)),
new DataField(
6,
"max_partition_stats",
SerializationUtils.newStringType(true))));

private final FileStoreTable dataTable;

Expand Down Expand Up @@ -176,8 +186,16 @@ public RecordReader<InternalRow> createReader(Split split) {
}
List<ManifestFileMeta> manifestFileMetas = allManifests(dataTable);

@SuppressWarnings("unchecked")
CastExecutor<InternalRow, BinaryString> partitionCastExecutor =
(CastExecutor<InternalRow, BinaryString>)
CastExecutors.resolveToString(
dataTable.schema().logicalPartitionType());

Iterator<InternalRow> rows =
Iterators.transform(manifestFileMetas.iterator(), this::toRow);
Iterators.transform(
manifestFileMetas.iterator(),
meta -> toRow(meta, partitionCastExecutor));
if (readType != null) {
rows =
Iterators.transform(
Expand All @@ -189,13 +207,17 @@ public RecordReader<InternalRow> createReader(Split split) {
return new IteratorRecordReader<>(rows);
}

private InternalRow toRow(ManifestFileMeta manifestFileMeta) {
private InternalRow toRow(
ManifestFileMeta manifestFileMeta,
CastExecutor<InternalRow, BinaryString> partitionCastExecutor) {
return GenericRow.of(
BinaryString.fromString(manifestFileMeta.fileName()),
manifestFileMeta.fileSize(),
manifestFileMeta.numAddedFiles(),
manifestFileMeta.numDeletedFiles(),
manifestFileMeta.schemaId());
manifestFileMeta.schemaId(),
partitionCastExecutor.cast(manifestFileMeta.partitionStats().minValues()),
partitionCastExecutor.cast(manifestFileMeta.partitionStats().maxValues()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,21 @@ private List<InternalRow> getExpectedResult(long snapshotId) {
manifestFileMeta.fileSize(),
manifestFileMeta.numAddedFiles(),
manifestFileMeta.numDeletedFiles(),
manifestFileMeta.schemaId()));
manifestFileMeta.schemaId(),
BinaryString.fromString(
String.format(
"{%d}",
manifestFileMeta
.partitionStats()
.minValues()
.getInt(0))),
BinaryString.fromString(
String.format(
"{%d}",
manifestFileMeta
.partitionStats()
.maxValues()
.getInt(0)))));
}
return expectedRow;
}
Expand Down
Loading