Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwenchi committed Feb 6, 2025
1 parent 8c45784 commit bf96eca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.paimon.data.InternalRow;
import org.apache.paimon.table.Table;
import org.apache.paimon.table.system.PartitionsTable;
import org.apache.paimon.table.system.SnapshotsTable;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand Down Expand Up @@ -94,18 +93,14 @@ private List<PaimonPartition> loadPartitions(PaimonSnapshotCacheKey key)
}

private PaimonSnapshot loadLatestSnapshot(PaimonSnapshotCacheKey key) throws IOException {
Table table = ((PaimonExternalCatalog) key.getCatalog()).getPaimonTable(key.getDbName(),
key.getTableName() + Catalog.SYSTEM_TABLE_SPLITTER + SnapshotsTable.SNAPSHOTS);
Table table = ((PaimonExternalCatalog) key.getCatalog()).getPaimonTable(key.getDbName(), key.getTableName());
// snapshotId and schemaId
List<InternalRow> rows = PaimonUtil.read(table, new int[] {0, 1}, null);
long latestSnapshotId = 0L;
long latestSchemaId = 0L;
for (InternalRow row : rows) {
long snapshotId = row.getLong(0);
if (snapshotId > latestSnapshotId) {
latestSnapshotId = snapshotId;
latestSchemaId = row.getLong(1);
}
OptionalLong optionalSnapshotId = table.latestSnapshotId();
if (optionalSnapshotId.isPresent()) {
latestSnapshotId = optionalSnapshotId.getAsLong();
latestSchemaId = table.snapshot(latestSnapshotId).schemaId();
}
return new PaimonSnapshot(latestSnapshotId, latestSchemaId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public static List<InternalRow> read(
for (Pair<ConfigOption<?>, String> pair : dynamicOptions) {
options.put(pair.getKey().key(), pair.getValue());
}
table = table.copy(options);
if (!options.isEmpty()) {
table = table.copy(options);
}
ReadBuilder readBuilder = table.newReadBuilder();
if (projection != null) {
readBuilder.withProjection(projection);
Expand Down

0 comments on commit bf96eca

Please sign in to comment.