Skip to content

Commit

Permalink
Pass full session to system connector
Browse files Browse the repository at this point in the history
  • Loading branch information
kokosing committed Aug 30, 2019
1 parent eeecbe7 commit d9da0f7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.prestosql.connector.system;

import io.prestosql.FullConnectorSession;
import io.prestosql.Session;
import io.prestosql.connector.CatalogName;
import io.prestosql.metadata.Metadata;
Expand All @@ -31,7 +32,6 @@

import java.util.Map;

import static io.prestosql.connector.system.SystemConnectorSessionUtil.toSession;
import static io.prestosql.metadata.MetadataListing.listCatalogs;
import static io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder;
import static io.prestosql.spi.connector.SystemTable.Distribution.SINGLE_COORDINATOR;
Expand Down Expand Up @@ -72,7 +72,7 @@ public ConnectorTableMetadata getTableMetadata()
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
Session session = toSession(transactionHandle, connectorSession);
Session session = ((FullConnectorSession) connectorSession).getSession();
Builder table = InMemoryRecordSet.builder(CATALOG_TABLE);
for (Map.Entry<String, CatalogName> entry : listCatalogs(session, metadata, accessControl).entrySet()) {
table.addRow(entry.getKey(), entry.getValue().toString());
Expand Down

This file was deleted.

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

import com.google.common.collect.ImmutableSet;
import io.airlift.log.Logger;
import io.prestosql.FullConnectorSession;
import io.prestosql.Session;
import io.prestosql.metadata.Metadata;
import io.prestosql.metadata.QualifiedObjectName;
Expand All @@ -36,7 +37,6 @@
import java.util.Optional;
import java.util.Set;

import static io.prestosql.connector.system.SystemConnectorSessionUtil.toSession;
import static io.prestosql.connector.system.jdbc.FilterUtil.filter;
import static io.prestosql.connector.system.jdbc.FilterUtil.stringFilter;
import static io.prestosql.connector.system.jdbc.FilterUtil.tablePrefix;
Expand Down Expand Up @@ -90,7 +90,7 @@ public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, Connect
Optional<String> schemaFilter = stringFilter(constraint, 1);
Optional<String> tableFilter = stringFilter(constraint, 2);

Session session = toSession(transactionHandle, connectorSession);
Session session = ((FullConnectorSession) connectorSession).getSession();
Builder table = InMemoryRecordSet.builder(COMMENT_TABLE);

for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.prestosql.connector.system.jdbc;

import io.prestosql.FullConnectorSession;
import io.prestosql.Session;
import io.prestosql.metadata.Metadata;
import io.prestosql.security.AccessControl;
Expand All @@ -27,7 +28,6 @@

import javax.inject.Inject;

import static io.prestosql.connector.system.SystemConnectorSessionUtil.toSession;
import static io.prestosql.metadata.MetadataListing.listCatalogs;
import static io.prestosql.metadata.MetadataUtil.TableMetadataBuilder.tableMetadataBuilder;
import static io.prestosql.spi.type.VarcharType.createUnboundedVarcharType;
Expand Down Expand Up @@ -61,7 +61,7 @@ public ConnectorTableMetadata getTableMetadata()
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
Session session = toSession(transactionHandle, connectorSession);
Session session = ((FullConnectorSession) connectorSession).getSession();
Builder table = InMemoryRecordSet.builder(METADATA);
for (String name : listCatalogs(session, metadata, accessControl).keySet()) {
table.addRow(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.prestosql.connector.system.jdbc;

import io.prestosql.FullConnectorSession;
import io.prestosql.Session;
import io.prestosql.metadata.Metadata;
import io.prestosql.metadata.QualifiedTablePrefix;
Expand Down Expand Up @@ -40,7 +41,6 @@
import java.util.Map.Entry;
import java.util.Optional;

import static io.prestosql.connector.system.SystemConnectorSessionUtil.toSession;
import static io.prestosql.connector.system.jdbc.FilterUtil.filter;
import static io.prestosql.connector.system.jdbc.FilterUtil.stringFilter;
import static io.prestosql.metadata.MetadataListing.listCatalogs;
Expand Down Expand Up @@ -115,7 +115,7 @@ public ConnectorTableMetadata getTableMetadata()
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
Session session = toSession(transactionHandle, connectorSession);
Session session = ((FullConnectorSession) connectorSession).getSession();
Optional<String> catalogFilter = stringFilter(constraint, 0);
Optional<String> schemaFilter = stringFilter(constraint, 1);
Optional<String> tableFilter = stringFilter(constraint, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.prestosql.connector.system.jdbc;

import io.prestosql.FullConnectorSession;
import io.prestosql.Session;
import io.prestosql.metadata.Metadata;
import io.prestosql.security.AccessControl;
Expand All @@ -29,7 +30,6 @@

import java.util.Optional;

import static io.prestosql.connector.system.SystemConnectorSessionUtil.toSession;
import static io.prestosql.connector.system.jdbc.FilterUtil.filter;
import static io.prestosql.metadata.MetadataListing.listCatalogs;
import static io.prestosql.metadata.MetadataListing.listSchemas;
Expand Down Expand Up @@ -66,7 +66,7 @@ public ConnectorTableMetadata getTableMetadata()
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
Session session = toSession(transactionHandle, connectorSession);
Session session = ((FullConnectorSession) connectorSession).getSession();
Optional<String> catalogFilter = FilterUtil.stringFilter(constraint, 1);

Builder table = InMemoryRecordSet.builder(METADATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.prestosql.connector.system.jdbc;

import io.prestosql.FullConnectorSession;
import io.prestosql.Session;
import io.prestosql.metadata.Metadata;
import io.prestosql.metadata.QualifiedTablePrefix;
Expand All @@ -30,7 +31,6 @@

import java.util.Optional;

import static io.prestosql.connector.system.SystemConnectorSessionUtil.toSession;
import static io.prestosql.connector.system.jdbc.FilterUtil.filter;
import static io.prestosql.connector.system.jdbc.FilterUtil.stringFilter;
import static io.prestosql.connector.system.jdbc.FilterUtil.tablePrefix;
Expand Down Expand Up @@ -78,7 +78,7 @@ public ConnectorTableMetadata getTableMetadata()
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint)
{
Session session = toSession(transactionHandle, connectorSession);
Session session = ((FullConnectorSession) connectorSession).getSession();
Optional<String> catalogFilter = stringFilter(constraint, 0);
Optional<String> schemaFilter = stringFilter(constraint, 1);
Optional<String> tableFilter = stringFilter(constraint, 2);
Expand Down

0 comments on commit d9da0f7

Please sign in to comment.