Skip to content

Commit

Permalink
Add support for getTableStatistics to base-jdbc connector
Browse files Browse the repository at this point in the history
  • Loading branch information
kokosing committed Jan 30, 2019
1 parent 23f8793 commit fa65182
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
import com.google.common.collect.ImmutableSet;
import io.airlift.log.Logger;
import io.prestosql.spi.PrestoException;
import io.prestosql.spi.connector.ColumnHandle;
import io.prestosql.spi.connector.ColumnMetadata;
import io.prestosql.spi.connector.ConnectorSession;
import io.prestosql.spi.connector.ConnectorSplitSource;
import io.prestosql.spi.connector.ConnectorTableMetadata;
import io.prestosql.spi.connector.FixedSplitSource;
import io.prestosql.spi.connector.SchemaTableName;
import io.prestosql.spi.connector.TableNotFoundException;
import io.prestosql.spi.predicate.TupleDomain;
import io.prestosql.spi.statistics.TableStatistics;
import io.prestosql.spi.type.CharType;
import io.prestosql.spi.type.DecimalType;
import io.prestosql.spi.type.Type;
Expand Down Expand Up @@ -449,6 +452,12 @@ protected SchemaTableName getSchemaTableName(ResultSet resultSet)
resultSet.getString("TABLE_NAME").toLowerCase(ENGLISH));
}

@Override
public TableStatistics getTableStatistics(ConnectorSession session, JdbcTableHandle handle, TupleDomain<ColumnHandle> tupleDomain)
{
return TableStatistics.empty();
}

protected void execute(Connection connection, String query)
throws SQLException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
*/
package io.prestosql.plugin.jdbc;

import io.prestosql.spi.connector.ColumnHandle;
import io.prestosql.spi.connector.ConnectorSession;
import io.prestosql.spi.connector.ConnectorSplitSource;
import io.prestosql.spi.connector.ConnectorTableMetadata;
import io.prestosql.spi.connector.SchemaTableName;
import io.prestosql.spi.predicate.TupleDomain;
import io.prestosql.spi.statistics.TableStatistics;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -78,4 +81,6 @@ Connection getConnection(JdbcOutputTableHandle handle)

PreparedStatement getPreparedStatement(Connection connection, String sql)
throws SQLException;

TableStatistics getTableStatistics(ConnectorSession session, JdbcTableHandle handle, TupleDomain<ColumnHandle> tupleDomain);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.prestosql.spi.connector.SchemaTablePrefix;
import io.prestosql.spi.connector.TableNotFoundException;
import io.prestosql.spi.statistics.ComputedStatistics;
import io.prestosql.spi.statistics.TableStatistics;

import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -212,4 +213,11 @@ public Optional<ConnectorOutputMetadata> finishInsert(ConnectorSession session,
jdbcClient.finishInsertTable(jdbcInsertHandle);
return Optional.empty();
}

@Override
public TableStatistics getTableStatistics(ConnectorSession session, ConnectorTableHandle tableHandle, Constraint<ColumnHandle> constraint)
{
JdbcTableHandle handle = (JdbcTableHandle) tableHandle;
return jdbcClient.getTableStatistics(session, handle, constraint.getSummary());
}
}

0 comments on commit fa65182

Please sign in to comment.