Skip to content

Commit

Permalink
Simplify toString of BigQuery table and column
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Oct 30, 2024
1 parent f0b25ef commit 7a3f815
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@ public long getRetainedSizeInBytes()
+ estimatedSizeOf(subColumns, BigQueryColumnHandle::getRetainedSizeInBytes)
+ estimatedSizeOf(description);
}

@Override
public String toString()
{
return "%s:%s".formatted(getQualifiedName(), trinoType.getDisplayName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.Objects;
import java.util.Optional;

import static com.google.common.base.MoreObjects.toStringHelper;
import static java.util.Objects.requireNonNull;

public class BigQueryNamedRelationHandle
Expand Down Expand Up @@ -105,11 +104,6 @@ public int hashCode()
@Override
public String toString()
{
return toStringHelper(this)
.add("remoteTableName", remoteTableName)
.add("schemaTableName", schemaTableName)
.add("type", type)
.add("comment", comment)
.toString();
return "%s:%s".formatted(remoteTableName, type);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.joining;

public record BigQueryTableHandle(
BigQueryRelationHandle relationHandle,
Expand Down Expand Up @@ -73,6 +74,24 @@ public boolean isQueryRelation()
return relationHandle instanceof BigQueryQueryRelationHandle;
}

@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append(relationHandle);
if (constraint.isNone()) {
builder.append(" constraint=FALSE");
}
else if (!constraint.isAll()) {
builder.append(" constraint on ");
builder.append(constraint.getDomains().orElseThrow().keySet().stream()
.map(columnHandle -> ((BigQueryColumnHandle) columnHandle).name())
.collect(joining(", ", "[", "]")));
}
projectedColumns.ifPresent(columns -> builder.append(" columns=").append(columns));
return builder.toString();
}

public BigQueryNamedRelationHandle asPlainTable()
{
checkState(!isSynthetic(), "The table handle does not represent a plain table: %s", this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@ protected MaterializedResult getDescribeOrdersResult()
.build();
}

@Test
@Override // Override because the regexp is different from the base test
public void testPredicateReflectedInExplain()
{
assertExplain(
"EXPLAIN SELECT name FROM nation WHERE nationkey = 42",
"nationkey", "bigint", "42");
}

@Test
public void testPredicatePushdown()
{
Expand Down

0 comments on commit 7a3f815

Please sign in to comment.