Skip to content

Commit

Permalink
Remove redundant code from BigQueryMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Nov 1, 2024
1 parent 61a79dd commit 32b07c3
Showing 1 changed file with 2 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ public BigQueryMetadata(
@Override
public List<String> listSchemaNames(ConnectorSession session)
{
log.debug("listSchemaNames(session=%s)", session);
return listRemoteSchemaNames(session).stream()
.map(schema -> schema.toLowerCase(ENGLISH))
.collect(toImmutableList());
Expand Down Expand Up @@ -215,7 +214,6 @@ public boolean schemaExists(ConnectorSession session, String schemaName)
DatasetId localDatasetId = client.toDatasetId(schemaName);

// Overridden to make sure an error message is returned in case of an ambiguous schema name
log.debug("schemaExists(session=%s)", session);
return client.toRemoteDataset(localDatasetId)
.map(RemoteDatabaseObject::getOnlyRemoteName)
.filter(remoteSchema -> client.getDataset(DatasetId.of(localDatasetId.getProject(), remoteSchema)) != null)
Expand All @@ -227,7 +225,6 @@ public List<SchemaTableName> listTables(ConnectorSession session, Optional<Strin
{
BigQueryClient client = bigQueryClientFactory.create(session);

log.debug("listTables(session=%s, schemaName=%s)", session, schemaName);
String projectId;

Set<String> remoteSchemaNames;
Expand Down Expand Up @@ -326,7 +323,6 @@ public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTable
}

BigQueryClient client = bigQueryClientFactory.create(session);
log.debug("getTableHandle(session=%s, schemaTableName=%s)", session, schemaTableName);
DatasetId localDatasetId = client.toDatasetId(schemaTableName.getSchemaName());
String remoteSchemaName = client.toRemoteDataset(localDatasetId)
.map(RemoteDatabaseObject::getOnlyRemoteName)
Expand Down Expand Up @@ -375,7 +371,6 @@ private Optional<TableInfo> getTableInfoIgnoringConflicts(ConnectorSession sessi
public ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle tableHandle)
{
BigQueryClient client = bigQueryClientFactory.create(session);
log.debug("getTableMetadata(session=%s, tableHandle=%s)", session, tableHandle);
BigQueryTableHandle handle = (BigQueryTableHandle) tableHandle;

List<ColumnMetadata> columns = client.getColumns(handle).stream()
Expand Down Expand Up @@ -422,24 +417,9 @@ private Optional<SystemTable> getViewDefinitionSystemTable(ConnectorSession sess
@Override
public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
{
BigQueryClient client = bigQueryClientFactory.create(session);
log.debug("getColumnHandles(session=%s, tableHandle=%s)", session, tableHandle);

BigQueryTableHandle table = (BigQueryTableHandle) tableHandle;
if (table.projectedColumns().isPresent()) {
return table.projectedColumns().get().stream()
.collect(toImmutableMap(columnHandle -> columnHandle.getColumnMetadata().getName(), identity()));
}

checkArgument(table.isNamedRelation(), "Cannot get columns for %s", tableHandle);

ImmutableList.Builder<BigQueryColumnHandle> columns = ImmutableList.builder();
columns.addAll(client.getColumns(table));
if (table.asPlainTable().getPartitionType().isPresent() && table.asPlainTable().getPartitionType().get() == INGESTION) {
columns.add(PARTITION_DATE.getColumnHandle());
columns.add(PARTITION_TIME.getColumnHandle());
}
return columns.build().stream()
checkArgument(table.projectedColumns().isPresent(), "Project columns must be present: %s", table);
return table.projectedColumns().get().stream()
.collect(toImmutableMap(columnHandle -> columnHandle.getColumnMetadata().getName(), identity()));
}

Expand All @@ -449,7 +429,6 @@ public ColumnMetadata getColumnMetadata(
ConnectorTableHandle tableHandle,
ColumnHandle columnHandle)
{
log.debug("getColumnMetadata(session=%s, tableHandle=%s, columnHandle=%s)", session, columnHandle, columnHandle);
return ((BigQueryColumnHandle) columnHandle).getColumnMetadata();
}

Expand All @@ -458,7 +437,6 @@ public ColumnMetadata getColumnMetadata(
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
BigQueryClient client = bigQueryClientFactory.create(session);
log.debug("listTableColumns(session=%s, prefix=%s)", session, prefix);
List<SchemaTableName> tables = prefix.toOptionalSchemaTableName()
.<List<SchemaTableName>>map(ImmutableList::of)
.orElseGet(() -> listTables(session, prefix.getSchema()));
Expand Down Expand Up @@ -894,8 +872,6 @@ public Optional<ProjectionApplicationResult<ConnectorTableHandle>> applyProjecti
List<ConnectorExpression> projections,
Map<String, ColumnHandle> assignments)
{
log.debug("applyProjection(session=%s, handle=%s, projections=%s, assignments=%s)",
session, handle, projections, assignments);
BigQueryTableHandle bigQueryTableHandle = (BigQueryTableHandle) handle;
if (!isProjectionPushdownEnabled(session)) {
List<ColumnHandle> newColumns = ImmutableList.copyOf(assignments.values());
Expand Down Expand Up @@ -1049,8 +1025,6 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(
ConnectorTableHandle handle,
Constraint constraint)
{
log.debug("applyFilter(session=%s, handle=%s, summary=%s, predicate=%s, columns=%s)",
session, handle, constraint.getSummary(), constraint.predicate(), constraint.getPredicateColumns());
BigQueryTableHandle bigQueryTableHandle = (BigQueryTableHandle) handle;

TupleDomain<ColumnHandle> oldDomain = bigQueryTableHandle.constraint();
Expand Down

0 comments on commit 32b07c3

Please sign in to comment.