Skip to content

Commit

Permalink
Reveal enforced constraint in EXPLAIN for Iceberg table scan
Browse files Browse the repository at this point in the history
Include `enforcedPredicate`'s columns in `IcebergTableHandle.toString` so that
it's visible in `EXPLAIN` output.
  • Loading branch information
findepi committed Sep 7, 2022
1 parent f6cad5e commit 8259b5c
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Set;

import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.joining;

public class IcebergTableHandle
implements ConnectorTableHandle
Expand Down Expand Up @@ -381,6 +382,17 @@ public int hashCode()
@Override
public String toString()
{
return getSchemaTableNameWithType() + snapshotId.map(v -> "@" + v).orElse("");
StringBuilder builder = new StringBuilder(getSchemaTableNameWithType().toString());
snapshotId.ifPresent(snapshotId -> builder.append("@").append(snapshotId));
if (enforcedPredicate.isNone()) {
builder.append(" constraint=FALSE");
}
else if (!enforcedPredicate.isAll()) {
builder.append(" constraint on ");
builder.append(enforcedPredicate.getDomains().orElseThrow().keySet().stream()
.map(IcebergColumnHandle::getQualifiedName)
.collect(joining(", ", "[", "]")));
}
return builder.toString();
}
}

0 comments on commit 8259b5c

Please sign in to comment.