Skip to content

Commit

Permalink
Remove ConnectorMetadata#getTableLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveen2112 committed Jan 13, 2022
1 parent 76d7141 commit 56e024d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,6 @@ public TableProperties getTableProperties(Session session, TableHandle handle)
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);

if (metadata.usesLegacyTableLayouts()) {
return handle.getLayout()
.map(layout -> new TableProperties(catalogName, handle.getTransaction(), new ConnectorTableProperties(metadata.getTableLayout(connectorSession, layout))))
.orElseGet(() -> getLayout(session, handle, Constraint.alwaysTrue(), Optional.empty())
.get()
.getTableProperties());
}

return new TableProperties(catalogName, handle.getTransaction(), metadata.getTableProperties(connectorSession, handle.getConnectorHandle()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

import static io.trino.spi.StandardErrorCode.GENERIC_INTERNAL_ERROR;
import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED;
import static java.lang.String.format;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.toUnmodifiableList;
Expand Down Expand Up @@ -178,16 +177,6 @@ default List<ConnectorTableLayoutResult> getTableLayouts(
throw new UnsupportedOperationException("Not yet implemented");
}

@Deprecated
default ConnectorTableLayout getTableLayout(ConnectorSession session, ConnectorTableLayoutHandle handle)
{
if (usesLegacyTableLayouts()) {
throw new IllegalStateException("Connector uses legacy Table Layout but doesn't implement getTableLayout()");
}

throw new UnsupportedOperationException("Not yet implemented");
}

/**
* Return a table layout handle whose partitioning is converted to the provided partitioning handle,
* but otherwise identical to the provided table layout handle.
Expand Down Expand Up @@ -1006,11 +995,7 @@ default List<GrantInfo> listTablePrivileges(ConnectorSession session, SchemaTabl
}

/**
* Whether the connector uses the legacy Table Layout feature. If this method returns false,
* connectors are required to implement the following methods:
* <ul>
* <li>{@link #getTableProperties(ConnectorSession session, ConnectorTableHandle table)}</li>
* </ul>
* Whether the connector uses the legacy Table Layout feature.
*/
default boolean usesLegacyTableLayouts()
{
Expand All @@ -1019,17 +1004,7 @@ default boolean usesLegacyTableLayouts()

default ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table)
{
if (!usesLegacyTableLayouts()) {
throw new IllegalStateException("getTableProperties() must be implemented if usesLegacyTableLayouts is false");
}

List<ConnectorTableLayoutResult> layouts = getTableLayouts(session, table, Constraint.alwaysTrue(), Optional.empty());

if (layouts.size() != 1) {
throw new TrinoException(NOT_SUPPORTED, format("Connector must return a single layout for table %s, but got %s", table, layouts.size()));
}

return new ConnectorTableProperties(layouts.get(0).getTableLayout());
return new ConnectorTableProperties();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.ConnectorTableExecuteHandle;
import io.trino.spi.connector.ConnectorTableHandle;
import io.trino.spi.connector.ConnectorTableLayout;
import io.trino.spi.connector.ConnectorTableLayoutHandle;
import io.trino.spi.connector.ConnectorTableLayoutResult;
import io.trino.spi.connector.ConnectorTableMetadata;
Expand Down Expand Up @@ -110,14 +109,6 @@ public List<ConnectorTableLayoutResult> getTableLayouts(
}
}

@Override
public ConnectorTableLayout getTableLayout(ConnectorSession session, ConnectorTableLayoutHandle handle)
{
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
return delegate.getTableLayout(session, handle);
}
}

@Override
public Optional<ConnectorPartitioningHandle> getCommonPartitioningHandle(ConnectorSession session, ConnectorPartitioningHandle left, ConnectorPartitioningHandle right)
{
Expand Down

0 comments on commit 56e024d

Please sign in to comment.