Java Code Examples for io.prestosql.spi.connector.SchemaTableName

The following examples show how to use io.prestosql.spi.connector.SchemaTableName. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: presto   Source File: BaseJdbcClient.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<SchemaTableName> getTableNames(JdbcIdentity identity, Optional<String> schema)
{
    try (Connection connection = connectionFactory.openConnection(identity)) {
        Optional<String> remoteSchema = schema.map(schemaName -> toRemoteSchemaName(identity, connection, schemaName));
        try (ResultSet resultSet = getTables(connection, remoteSchema, Optional.empty())) {
            ImmutableList.Builder<SchemaTableName> list = ImmutableList.builder();
            while (resultSet.next()) {
                String tableSchema = getTableSchemaName(resultSet);
                String tableName = resultSet.getString("TABLE_NAME");
                list.add(new SchemaTableName(tableSchema, tableName));
            }
            return list.build();
        }
    }
    catch (SQLException e) {
        throw new PrestoException(JDBC_ERROR, e);
    }
}
 
Example 2
Source Project: presto   Source File: ColumnRangesSystemTable.java    License: Apache License 2.0 6 votes vote down vote up
public ColumnRangesSystemTable(RaptorTableHandle sourceTable, IDBI dbi)
{
    this.sourceTable = requireNonNull(sourceTable, "sourceTable is null");
    this.dbi = requireNonNull(dbi, "dbi is null");

    this.indexedRaptorColumns = dbi.onDemand(MetadataDao.class)
            .listTableColumns(sourceTable.getTableId()).stream()
            .filter(column -> isIndexedType(column.getDataType()))
            .collect(toImmutableList());
    List<ColumnMetadata> systemTableColumns = indexedRaptorColumns.stream()
            .flatMap(column -> Stream.of(
                    new ColumnMetadata(column.getColumnName() + MIN_COLUMN_SUFFIX, column.getDataType()),
                    new ColumnMetadata(column.getColumnName() + MAX_COLUMN_SUFFIX, column.getDataType())))
            .collect(toImmutableList());
    SchemaTableName tableName = new SchemaTableName(sourceTable.getSchemaName(), sourceTable.getTableName() + COLUMN_RANGES_TABLE_SUFFIX);
    this.tableMetadata = new ConnectorTableMetadata(tableName, systemTableColumns);
}
 
Example 3
Source Project: presto   Source File: ZooKeeperMetadataManager.java    License: Apache License 2.0 6 votes vote down vote up
public AccumuloView getView(SchemaTableName stName)
{
    try {
        String tablePath = getTablePath(stName);
        if (curator.checkExists().forPath(tablePath) != null) {
            byte[] data = curator.getData().forPath(tablePath);
            if (isAccumuloView(data)) {
                return toAccumuloView(data);
            }
        }

        return null;
    }
    catch (Exception e) {
        // Capture race condition between checkExists and getData
        if (e instanceof KeeperException && ((KeeperException) e).code() == NONODE) {
            return null;
        }

        throw new PrestoException(ZOOKEEPER_ERROR, "Error fetching view", e);
    }
}
 
Example 4
Source Project: presto   Source File: ZooKeeperMetadataManager.java    License: Apache License 2.0 6 votes vote down vote up
public AccumuloTable getTable(SchemaTableName stName)
{
    try {
        if (curator.checkExists().forPath(getTablePath(stName)) != null) {
            return toAccumuloTable(curator.getData().forPath(getTablePath(stName)));
        }

        return null;
    }
    catch (Exception e) {
        // Capture race condition between checkExists and getData
        if (e instanceof KeeperException && ((KeeperException) e).code() == NONODE) {
            return null;
        }

        throw new PrestoException(ZOOKEEPER_ERROR, "Error fetching table", e);
    }
}
 
Example 5
Source Project: presto   Source File: ManifestsTable.java    License: Apache License 2.0 6 votes vote down vote up
public ManifestsTable(SchemaTableName tableName, Table icebergTable, Optional<Long> snapshotId)
{
    this.icebergTable = requireNonNull(icebergTable, "icebergTable is null");

    tableMetadata = new ConnectorTableMetadata(
            tableName,
            ImmutableList.<ColumnMetadata>builder()
                    .add(new ColumnMetadata("path", VARCHAR))
                    .add(new ColumnMetadata("length", BIGINT))
                    .add(new ColumnMetadata("partition_spec_id", INTEGER))
                    .add(new ColumnMetadata("added_snapshot_id", BIGINT))
                    .add(new ColumnMetadata("added_data_files_count", INTEGER))
                    .add(new ColumnMetadata("existing_data_files_count", INTEGER))
                    .add(new ColumnMetadata("deleted_data_files_count", INTEGER))
                    .add(new ColumnMetadata("partitions", RowType.rowType(
                            RowType.field("contains_null", BOOLEAN),
                            RowType.field("lower_bound", VARCHAR),
                            RowType.field("upper_bound", VARCHAR))))
                    .build());
    this.snapshotId = requireNonNull(snapshotId, "snapshotId is null");
}
 
Example 6
@JsonCreator
public HBaseInsertTableHandle(
        @JsonProperty("connectorId") String connectorId,
        @JsonProperty("schemaTableName") SchemaTableName schemaTableName,
        @JsonProperty("columnNames") List<String> columnNames,
        @JsonProperty("columnTypes") List<Type> columnTypes,
        @JsonProperty("rowKeyColumnChannel") int rowKeyColumnChannel,
        @JsonProperty("colNameAndFamilyNameMap") Map<String, String> colNameAndFamilyNameMap) {
    // super(connectorId, schemaTableName, columnNames, columnTypes);
    this.schemaTableName = requireNonNull(schemaTableName, "schemaTableName is null");
    requireNonNull(columnNames, "columnNames is null");
    requireNonNull(columnTypes, "columnTypes is null");
    checkArgument(columnNames.size() == columnTypes.size(), "columnNames and columnTypes sizes don't match");
    this.columnNames = ImmutableList.copyOf(columnNames);
    this.columnTypes = ImmutableList.copyOf(columnTypes);
    this.connectorId = requireNonNull(connectorId, "connectorId is null");
    this.rowKeyColumnChannel = rowKeyColumnChannel;
    this.colNameAndFamilyNameMap = colNameAndFamilyNameMap;
}
 
Example 7
Source Project: presto   Source File: RedisMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
    requireNonNull(prefix, "prefix is null");

    ImmutableMap.Builder<SchemaTableName, List<ColumnMetadata>> columns = ImmutableMap.builder();

    List<SchemaTableName> tableNames;
    if (prefix.getTable().isEmpty()) {
        tableNames = listTables(session, prefix.getSchema());
    }
    else {
        tableNames = ImmutableList.of(prefix.toSchemaTableName());
    }

    for (SchemaTableName tableName : tableNames) {
        ConnectorTableMetadata tableMetadata = getTableMetadata(tableName);
        // table can disappear during listing operation
        if (tableMetadata != null) {
            columns.put(tableName, tableMetadata.getColumns());
        }
    }
    return columns.build();
}
 
Example 8
Source Project: presto   Source File: IcebergMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public IcebergTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName)
{
    IcebergTableHandle handle = IcebergTableHandle.from(tableName);
    Optional<Table> table = metastore.getTable(new HiveIdentity(session), handle.getSchemaName(), handle.getTableName());
    if (table.isEmpty()) {
        return null;
    }
    if (handle.getTableType() != DATA) {
        throw new PrestoException(NOT_SUPPORTED, "Table type not yet supported: " + handle.getSchemaTableNameWithType());
    }
    if (!isIcebergTable(table.get())) {
        throw new UnknownTableTypeException(tableName);
    }
    return handle;
}
 
Example 9
Source Project: presto   Source File: TestRaptorMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testRenameTable()
{
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    metadata.createTable(SESSION, getOrdersTable(), false);
    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS);
    assertInstanceOf(tableHandle, RaptorTableHandle.class);

    RaptorTableHandle raptorTableHandle = (RaptorTableHandle) tableHandle;
    SchemaTableName renamedTable = new SchemaTableName(raptorTableHandle.getSchemaName(), "orders_renamed");

    metadata.renameTable(SESSION, raptorTableHandle, renamedTable);
    assertNull(metadata.getTableHandle(SESSION, DEFAULT_TEST_ORDERS));
    ConnectorTableHandle renamedTableHandle = metadata.getTableHandle(SESSION, renamedTable);
    assertNotNull(renamedTableHandle);
    assertEquals(((RaptorTableHandle) renamedTableHandle).getTableName(), renamedTable.getTableName());
}
 
Example 10
Source Project: presto   Source File: ThriftHiveMetastore.java    License: Apache License 2.0 6 votes vote down vote up
private static LockComponent createLockComponentForRead(SchemaTableName table, Optional<String> partitionName)
{
    requireNonNull(table, "table is null");
    requireNonNull(partitionName, "partitionName is null");

    LockComponentBuilder builder = new LockComponentBuilder();
    builder.setShared();
    builder.setOperationType(DataOperationType.SELECT);

    builder.setDbName(table.getSchemaName());
    builder.setTableName(table.getTableName());
    requireNonNull(partitionName, "partitionName is null").ifPresent(builder::setPartitionName);

    // acquire locks is called only for TransactionalTable
    builder.setIsTransactional(true);
    return builder.build();
}
 
Example 11
Source Project: presto   Source File: MockConnectorFactory.java    License: Apache License 2.0 6 votes vote down vote up
private MockConnector(
        ConnectorContext context,
        Function<ConnectorSession, List<String>> listSchemaNames,
        BiFunction<ConnectorSession, String, List<SchemaTableName>> listTables,
        BiFunction<ConnectorSession, SchemaTablePrefix, Map<SchemaTableName, ConnectorViewDefinition>> getViews,
        BiFunction<ConnectorSession, SchemaTableName, ConnectorTableHandle> getTableHandle,
        Function<SchemaTableName, List<ColumnMetadata>> getColumns,
        ApplyProjection applyProjection,
        BiFunction<ConnectorSession, SchemaTableName, Optional<ConnectorNewTableLayout>> getInsertLayout,
        BiFunction<ConnectorSession, ConnectorTableMetadata, Optional<ConnectorNewTableLayout>> getNewTableLayout,
        Supplier<Iterable<EventListener>> eventListeners,
        ListRoleGrants roleGrants)
{
    this.context = requireNonNull(context, "context is null");
    this.listSchemaNames = requireNonNull(listSchemaNames, "listSchemaNames is null");
    this.listTables = requireNonNull(listTables, "listTables is null");
    this.getViews = requireNonNull(getViews, "getViews is null");
    this.getTableHandle = requireNonNull(getTableHandle, "getTableHandle is null");
    this.getColumns = requireNonNull(getColumns, "getColumns is null");
    this.applyProjection = requireNonNull(applyProjection, "applyProjection is null");
    this.getInsertLayout = requireNonNull(getInsertLayout, "getInsertLayout is null");
    this.getNewTableLayout = requireNonNull(getNewTableLayout, "getNewTableLayout is null");
    this.eventListeners = requireNonNull(eventListeners, "eventListeners is null");
    this.roleGrants = requireNonNull(roleGrants, "roleGrants is null");
}
 
Example 12
Source Project: presto   Source File: JmxMetadata.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<SchemaTableName> listTables(ConnectorSession session, Optional<String> schemaName)
{
    Set<String> schemaNames = schemaName.map(ImmutableSet::of)
            .orElseGet(() -> ImmutableSet.copyOf(listSchemaNames(session)));
    ImmutableList.Builder<SchemaTableName> schemaTableNames = ImmutableList.builder();
    for (String schema : schemaNames) {
        if (JMX_SCHEMA_NAME.equals(schema)) {
            return listJmxTables();
        }
        else if (HISTORY_SCHEMA_NAME.equals(schema)) {
            return jmxHistoricalData.getTables().stream()
                    .map(tableName -> new SchemaTableName(JmxMetadata.HISTORY_SCHEMA_NAME, tableName))
                    .collect(toList());
        }
    }
    return schemaTableNames.build();
}
 
Example 13
Source Project: presto   Source File: SqlStandardAccessControl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void checkCanRevokeTablePrivilege(ConnectorSecurityContext context, Privilege privilege, SchemaTableName tableName, PrestoPrincipal revokee, boolean grantOption)
{
    if (isTableOwner(context, tableName)) {
        return;
    }

    if (!hasGrantOptionForPrivilege(context, privilege, tableName)) {
        denyRevokeTablePrivilege(privilege.name(), tableName.toString());
    }
}
 
Example 14
Source Project: presto   Source File: TestJmxMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testApplyFilterWithoutConstraint()
{
    JmxTableHandle handle = metadata.getTableHandle(SESSION, new SchemaTableName(JMX_SCHEMA_NAME, "java.lang:*"));
    Optional<ConstraintApplicationResult<ConnectorTableHandle>> result = metadata.applyFilter(SESSION, handle, new Constraint(TupleDomain.all()));

    assertFalse(result.isPresent());
}
 
Example 15
Source Project: presto   Source File: ThriftIndexHandle.java    License: Apache License 2.0 5 votes vote down vote up
private ThriftIndexHandle(
        SchemaTableName schemaTableName,
        TupleDomain<ColumnHandle> tupleDomain,
        Optional<ConnectorSession> session)
{
    this.schemaTableName = requireNonNull(schemaTableName, "schemaTableName is null");
    this.tupleDomain = requireNonNull(tupleDomain, "tupleDomain is null");
    this.session = requireNonNull(session, "session is null");
}
 
Example 16
Source Project: presto   Source File: TestMemoryMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = PrestoException.class, expectedExceptionsMessageRegExp = "View already exists: test\\.test_view")
public void testCreateViewWithoutReplace()
{
    SchemaTableName test = new SchemaTableName("test", "test_view");
    metadata.createSchema(SESSION, "test", ImmutableMap.of(), new PrestoPrincipal(USER, SESSION.getUser()));
    try {
        metadata.createView(SESSION, test, testingViewDefinition("test"), false);
    }
    catch (Exception e) {
        fail("should have succeeded");
    }
    metadata.createView(SESSION, test, testingViewDefinition("test"), false);
}
 
Example 17
Source Project: presto   Source File: KafkaMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<String> listSchemaNames(ConnectorSession session)
{
    return tableDescriptions.stream()
            .map(TableDescriptionSupplier::listTables)
            .flatMap(Set::stream)
            .map(SchemaTableName::getSchemaName)
            .collect(toImmutableList());
}
 
Example 18
Source Project: ranger   Source File: RangerSystemAccessControl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Set<SchemaTableName> filterTables(SystemSecurityContext context, String catalogName, Set<SchemaTableName> tableNames) {
  Set<SchemaTableName> filteredTableNames;
  try {
    activatePluginClassLoader();
    filteredTableNames = systemAccessControlImpl.filterTables(context, catalogName, tableNames);
  } finally {
    deactivatePluginClassLoader();
  }
  return filteredTableNames;
}
 
Example 19
Source Project: presto   Source File: FileBasedAccessControl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void checkCanDropTable(ConnectorSecurityContext context, SchemaTableName tableName)
{
    if (!checkTablePermission(context, tableName, OWNERSHIP)) {
        denyDropTable(tableName.toString());
    }
}
 
Example 20
Source Project: presto   Source File: TestCassandraConnector.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testListUnknownSchema()
{
    assertNull(metadata.getTableHandle(SESSION, new SchemaTableName("totally_invalid_database_name", "dual")));
    assertEquals(metadata.listTables(SESSION, Optional.of("totally_invalid_database_name")), ImmutableList.of());
    assertEquals(metadata.listTableColumns(SESSION, new SchemaTablePrefix("totally_invalid_database_name", "dual")), ImmutableMap.of());
}
 
Example 21
Source Project: presto   Source File: TestMemoryMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRenameTable()
{
    SchemaTableName tableName = new SchemaTableName("test_schema", "test_table_to_be_renamed");
    metadata.createSchema(SESSION, "test_schema", ImmutableMap.of(), new PrestoPrincipal(USER, SESSION.getUser()));
    ConnectorOutputTableHandle table = metadata.beginCreateTable(
            SESSION,
            new ConnectorTableMetadata(tableName, ImmutableList.of(), ImmutableMap.of()),
            Optional.empty());
    metadata.finishCreateTable(SESSION, table, ImmutableList.of(), ImmutableList.of());

    // rename table to schema which does not exist
    SchemaTableName invalidSchemaTableName = new SchemaTableName("test_schema_not_exist", "test_table_renamed");
    ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, tableName);
    Throwable throwable = expectThrows(SchemaNotFoundException.class, () -> metadata.renameTable(SESSION, tableHandle, invalidSchemaTableName));
    assertEquals(throwable.getMessage(), "Schema test_schema_not_exist not found");

    // rename table to same schema
    SchemaTableName sameSchemaTableName = new SchemaTableName("test_schema", "test_renamed");
    metadata.renameTable(SESSION, metadata.getTableHandle(SESSION, tableName), sameSchemaTableName);
    assertEquals(metadata.listTables(SESSION, Optional.of("test_schema")), ImmutableList.of(sameSchemaTableName));

    // rename table to different schema
    metadata.createSchema(SESSION, "test_different_schema", ImmutableMap.of(), new PrestoPrincipal(USER, SESSION.getUser()));
    SchemaTableName differentSchemaTableName = new SchemaTableName("test_different_schema", "test_renamed");
    metadata.renameTable(SESSION, metadata.getTableHandle(SESSION, sameSchemaTableName), differentSchemaTableName);
    assertEquals(metadata.listTables(SESSION, Optional.of("test_schema")), ImmutableList.of());
    assertEquals(metadata.listTables(SESSION, Optional.of("test_different_schema")), ImmutableList.of(differentSchemaTableName));
}
 
Example 22
Source Project: presto   Source File: InformationSchemaMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session, SchemaTablePrefix prefix)
{
    requireNonNull(prefix, "prefix is null");
    return Arrays.stream(InformationSchemaTable.values())
            .filter(table -> prefix.matches(table.getSchemaTableName()))
            .collect(toImmutableMap(InformationSchemaTable::getSchemaTableName, table -> table.getTableMetadata().getColumns()));
}
 
Example 23
Source Project: presto   Source File: SqlStandardAccessControl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void checkCanRenameColumn(ConnectorSecurityContext context, SchemaTableName tableName)
{
    if (!isTableOwner(context, tableName)) {
        denyRenameColumn(tableName.toString());
    }
}
 
Example 24
Source Project: presto   Source File: HiveMetadata.java    License: Apache License 2.0 5 votes vote down vote up
public static Optional<SchemaTableName> getSourceTableNameFromSystemTable(SchemaTableName tableName)
{
    return Stream.of(SystemTableHandler.values())
            .filter(handler -> handler.matches(tableName))
            .map(handler -> handler.getSourceTableName(tableName))
            .findAny();
}
 
Example 25
Source Project: presto   Source File: ThriftHiveMetastore.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void updateTableStatistics(HiveIdentity identity, String databaseName, String tableName, Function<PartitionStatistics, PartitionStatistics> update)
{
    Table originalTable = getTable(identity, databaseName, tableName)
            .orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName)));

    PartitionStatistics currentStatistics = getTableStatistics(identity, originalTable);
    PartitionStatistics updatedStatistics = update.apply(currentStatistics);

    Table modifiedTable = originalTable.deepCopy();
    HiveBasicStatistics basicStatistics = updatedStatistics.getBasicStatistics();
    modifiedTable.setParameters(updateStatisticsParameters(modifiedTable.getParameters(), basicStatistics));
    alterTable(identity, databaseName, tableName, modifiedTable);

    io.prestosql.plugin.hive.metastore.Table table = fromMetastoreApiTable(modifiedTable);
    OptionalLong rowCount = basicStatistics.getRowCount();
    List<ColumnStatisticsObj> metastoreColumnStatistics = updatedStatistics.getColumnStatistics().entrySet().stream()
            .flatMap(entry -> {
                Optional<Column> column = table.getColumn(entry.getKey());
                if (column.isEmpty() && isAvroTableWithSchemaSet(modifiedTable)) {
                    // Avro table can have different effective schema than declared in metastore. Still, metastore does not allow
                    // to store statistics for a column it does not know about.
                    return Stream.of();
                }

                HiveType type = column.orElseThrow(() -> new IllegalStateException("Column not found: " + entry.getKey())).getType();
                return Stream.of(createMetastoreColumnStatistics(entry.getKey(), type, entry.getValue(), rowCount));
            })
            .collect(toImmutableList());
    if (!metastoreColumnStatistics.isEmpty()) {
        setTableColumnStatistics(identity, databaseName, tableName, metastoreColumnStatistics);
    }
    Set<String> removedColumnStatistics = difference(currentStatistics.getColumnStatistics().keySet(), updatedStatistics.getColumnStatistics().keySet());
    removedColumnStatistics.forEach(column -> deleteTableColumnStatistics(identity, databaseName, tableName, column));
}
 
Example 26
Source Project: presto   Source File: ZooKeeperMetadataManager.java    License: Apache License 2.0 5 votes vote down vote up
public void deleteTableMetadata(SchemaTableName tableName)
{
    try {
        curator.delete().deletingChildrenIfNeeded().forPath(getTablePath(tableName));
    }
    catch (Exception e) {
        throw new PrestoException(ZOOKEEPER_ERROR, "ZK error when deleting table metadata", e);
    }
}
 
Example 27
Source Project: presto   Source File: TableInfo.java    License: Apache License 2.0 5 votes vote down vote up
public ConnectorTableMetadata getMetadata()
{
    return new ConnectorTableMetadata(
            new SchemaTableName(schemaName, tableName),
            columns.stream()
                    .map(ColumnInfo::getMetadata)
                    .collect(Collectors.toList()));
}
 
Example 28
Source Project: presto   Source File: PrometheusMetadata.java    License: Apache License 2.0 5 votes vote down vote up
private List<SchemaTableName> listTables(ConnectorSession session, SchemaTablePrefix prefix)
{
    if (!prefix.getTable().isPresent()) {
        return listTables(session, prefix.getSchema());
    }
    return ImmutableList.of(prefix.toSchemaTableName());
}
 
Example 29
Source Project: presto   Source File: ClassLoaderSafeConnectorMetadata.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void revokeTablePrivileges(ConnectorSession session, SchemaTableName tableName, Set<Privilege> privileges, PrestoPrincipal grantee, boolean grantOption)
{
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        delegate.revokeTablePrivileges(session, tableName, privileges, grantee, grantOption);
    }
}
 
Example 30
Source Project: presto   Source File: MetastoreHiveStatisticsProvider.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TableStatistics getTableStatistics(
        ConnectorSession session,
        SchemaTableName table,
        Map<String, ColumnHandle> columns,
        Map<String, Type> columnTypes,
        List<HivePartition> partitions)
{
    if (!isStatisticsEnabled(session)) {
        return TableStatistics.empty();
    }
    if (partitions.isEmpty()) {
        return createZeroStatistics(columns, columnTypes);
    }
    int sampleSize = getPartitionStatisticsSampleSize(session);
    List<HivePartition> partitionsSample = getPartitionsSample(partitions, sampleSize);
    try {
        Map<String, PartitionStatistics> statisticsSample = statisticsProvider.getPartitionsStatistics(session, table, partitionsSample);
        validatePartitionStatistics(table, statisticsSample);
        return getTableStatistics(columns, columnTypes, partitions, statisticsSample);
    }
    catch (PrestoException e) {
        if (e.getErrorCode().equals(HIVE_CORRUPTED_COLUMN_STATISTICS.toErrorCode()) && isIgnoreCorruptedStatistics(session)) {
            log.error(e);
            return TableStatistics.empty();
        }
        throw e;
    }
}