{"record":{"id":"6de38d1b4e022244","repo":"prestodb/presto","slug":"invalid-analyze-property-6de38d","errorCode":"INVALID_ANALYZE_PROPERTY","errorMessage":"Only partitioned table can be analyzed with a partition list","messagePattern":"Only partitioned table can be analyzed with a partition list","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java","lineNumber":590,"sourceCode":"\n        return new HiveTableHandle(tableName.getSchemaName(), tableName.getTableName());\n    }\n\n    @Override\n    public ConnectorTableHandle getTableHandleForStatisticsCollection(ConnectorSession session, SchemaTableName tableName, Map<String, Object> analyzeProperties)\n    {\n        HiveTableHandle handle = getTableHandle(session, tableName);\n        if (handle == null) {\n            return null;\n        }\n        Optional<List<List<String>>> partitionValuesList = getPartitionList(analyzeProperties);\n        ConnectorTableMetadata tableMetadata = getTableMetadata(session, handle);\n        handle = handle.withAnalyzePartitionValues(partitionValuesList);\n\n        List<String> partitionedBy = getPartitionedBy(tableMetadata.getProperties());\n\n        if (partitionValuesList.isPresent() && partitionedBy.isEmpty()) {\n            throw new PrestoException(INVALID_ANALYZE_PROPERTY, \"Only partitioned table can be analyzed with a partition list\");\n        }\n        return handle;\n    }\n\n    @Override\n    public Optional<SystemTable> getSystemTable(ConnectorSession session, SchemaTableName tableName)\n    {\n        if (SystemTableHandler.PARTITIONS.matches(tableName)) {\n            return getPartitionsSystemTable(session, tableName, SystemTableHandler.PARTITIONS.getSourceTableName(tableName));\n        }\n        if (SystemTableHandler.PROPERTIES.matches(tableName)) {\n            return getPropertiesSystemTable(session, tableName, SystemTableHandler.PROPERTIES.getSourceTableName(tableName));\n        }\n        return Optional.empty();\n    }\n\n    private Optional<SystemTable> getPropertiesSystemTable(ConnectorSession session, SchemaTableName tableName, SchemaTableName sourceTableName)\n    {","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java#L572-L608","documentation":"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.","triggerScenarios":"Running ANALYZE TABLE ... WITH PARTITIONS (or the statistics-collection table handle with AnalyzePartitionValues) on an unpartitioned Hive table.","commonSituations":"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.","solutions":["Remove the PARTITIONS clause from the ANALYZE statement for this table","Partition the table if partition-scoped statistics are required","Restrict the ANALYZE script to partitioned tables (check SHOW CREATE TABLE output first)"],"exampleFix":"-- before\nANALYZE TABLE unpartitioned_t WITH PARTITIONS (ds = '2024-01-01');\n-- after\nANALYZE TABLE unpartitioned_t;","handlingStrategy":"validation","validationCode":"List<String> partitionedBy = getPartitionedBy(getTableMetadata(session, handle).getProperties());\nif (partitionValuesList.isPresent() && partitionedBy.isEmpty()) {\n    throw new IllegalArgumentException(\"PARTITIONS clause requires a partitioned table\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    // ANALYZE with partition list\n} catch (PrestoException e) {\n    if (e.getErrorCode().getCode() == INVALID_ANALYZE_PROPERTY.toErrorCode().getCode()) {\n        // retry ANALYZE without the PARTITIONS clause\n    } else throw e;\n}","preventionTips":["Check SHOW CREATE TABLE for partitioned_by before adding a PARTITIONS clause to ANALYZE","Write ANALYZE scripts that branch on whether a table is partitioned","Keep ANALYZE commands per-table rather than templated across schemas"],"tags":["hive","analyze","statistics","partitioning"],"backgroundTag":"invalid-analyze-partition-list","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}