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 @@ -1790,10 +1790,12 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(C
else {
Table icebergTable = catalog.loadTable(session, table.getSchemaTableName());

Long snapshotId = table.getSnapshotId().orElseThrow(() -> new IllegalStateException("Snapshot id must be present"));
Set<Integer> partitionSpecIds = icebergTable.snapshot(snapshotId).allManifests(icebergTable.io()).stream()
.map(ManifestFile::partitionSpecId)
.collect(toImmutableSet());
Set<Integer> partitionSpecIds = table.getSnapshotId().map(
snapshot -> icebergTable.snapshot(snapshot).allManifests(icebergTable.io()).stream()
.map(ManifestFile::partitionSpecId)
.collect(toImmutableSet()))
// No snapshot, so no data. This case doesn't matter.
.orElseGet(() -> ImmutableSet.copyOf(icebergTable.specs().keySet()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.orElseGet(() -> ImmutableSet.copyOf(icebergTable.specs().keySet()));
// No snapshot, so no data. This case doesn't matter.
.orElseGet(() -> ImmutableSet.copyOf(icebergTable.specs().keySet()));


Map<IcebergColumnHandle, Domain> unsupported = new LinkedHashMap<>();
Map<IcebergColumnHandle, Domain> newEnforced = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void testTrinoReadingSparkData(StorageFormat storageFormat, int specVersi
// Validate queries on an empty table created by Spark
assertThat(onTrino().executeQuery(format("SELECT * FROM %s", trinoTableName("\"" + baseTableName + "$snapshots\"")))).hasNoRows();
assertThat(onTrino().executeQuery(format("SELECT * FROM %s", trinoTableName))).hasNoRows();
assertThat(onTrino().executeQuery(format("SELECT * FROM %s WHERE _integer > 0", trinoTableName))).hasNoRows();

onSpark().executeQuery(format(
"INSERT INTO %s VALUES (" +
Expand Down