prestodb/presto · error · PrestoException

INVALID_ANALYZE_PROPERTY

INVALID_ANALYZE_PROPERTY

Error message

Only partitioned table can be analyzed with a partition list

What it means

ANALYZE with a partition-values list only makes sense for partitioned tables. getTableHandleForStatisticsCollection throws INVALID_ANALYZE_PROPERTY when analyze_partition_values is supplied but the target table has no partitioned_by property.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java:590

        return new HiveTableHandle(tableName.getSchemaName(), tableName.getTableName());
    }

    @Override
    public ConnectorTableHandle getTableHandleForStatisticsCollection(ConnectorSession session, SchemaTableName tableName, Map<String, Object> analyzeProperties)
    {
        HiveTableHandle handle = getTableHandle(session, tableName);
        if (handle == null) {
            return null;
        }
        Optional<List<List<String>>> partitionValuesList = getPartitionList(analyzeProperties);
        ConnectorTableMetadata tableMetadata = getTableMetadata(session, handle);
        handle = handle.withAnalyzePartitionValues(partitionValuesList);

        List<String> partitionedBy = getPartitionedBy(tableMetadata.getProperties());

        if (partitionValuesList.isPresent() && partitionedBy.isEmpty()) {
            throw new PrestoException(INVALID_ANALYZE_PROPERTY, "Only partitioned table can be analyzed with a partition list");
        }
        return handle;
    }

    @Override
    public Optional<SystemTable> getSystemTable(ConnectorSession session, SchemaTableName tableName)
    {
        if (SystemTableHandler.PARTITIONS.matches(tableName)) {
            return getPartitionsSystemTable(session, tableName, SystemTableHandler.PARTITIONS.getSourceTableName(tableName));
        }
        if (SystemTableHandler.PROPERTIES.matches(tableName)) {
            return getPropertiesSystemTable(session, tableName, SystemTableHandler.PROPERTIES.getSourceTableName(tableName));
        }
        return Optional.empty();
    }

    private Optional<SystemTable> getPropertiesSystemTable(ConnectorSession session, SchemaTableName tableName, SchemaTableName sourceTableName)
    {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Remove the PARTITIONS clause from the ANALYZE statement for this table
  2. Partition the table if partition-scoped statistics are required
  3. Restrict the ANALYZE script to partitioned tables (check SHOW CREATE TABLE output first)

Example fix

-- before
ANALYZE TABLE unpartitioned_t WITH PARTITIONS (ds = '2024-01-01');
-- after
ANALYZE TABLE unpartitioned_t;
Defensive patterns

Strategy: validation

Validate before calling

List<String> partitionedBy = getPartitionedBy(getTableMetadata(session, handle).getProperties());
if (partitionValuesList.isPresent() && partitionedBy.isEmpty()) {
    throw new IllegalArgumentException("PARTITIONS clause requires a partitioned table");
}

Try / catch

try {
    // ANALYZE with partition list
} catch (PrestoException e) {
    if (e.getErrorCode().getCode() == INVALID_ANALYZE_PROPERTY.toErrorCode().getCode()) {
        // retry ANALYZE without the PARTITIONS clause
    } else throw e;
}

Prevention

When it happens

Trigger: Running ANALYZE TABLE ... WITH PARTITIONS (or the statistics-collection table handle with AnalyzePartitionValues) on an unpartitioned Hive table.

Common situations: Scripts that run ANALYZE with a PARTITIONS clause against every table in a schema without checking partitioning; copying ANALYZE commands between partitioned and unpartitioned tables.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/6de38d1b4e022244. Report an issue: GitHub.