{"record":{"id":"1e1c54aac7e9d371","repo":"prestodb/presto","slug":"invalid-procedure-argument-1e1c54","errorCode":"INVALID_PROCEDURE_ARGUMENT","errorMessage":"Table is not partitioned: ","messagePattern":"Table is not partitioned: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/SyncPartitionMetadataProcedure.java","lineNumber":136,"sourceCode":"        SyncMode syncMode = toSyncMode(mode);\n        SemiTransactionalHiveMetastore metastore = hiveMetadataFactory.get().getMetastore();\n        SchemaTableName schemaTableName = new SchemaTableName(schemaName, tableName);\n\n        MetastoreContext metastoreContext = new MetastoreContext(\n                session.getIdentity(),\n                session.getQueryId(),\n                session.getClientInfo(),\n                session.getClientTags(),\n                session.getSource(),\n                getMetastoreHeaders(session),\n                isUserDefinedTypeEncodingEnabled(session),\n                metastore.getColumnConverterProvider(),\n                session.getWarningCollector(),\n                session.getRuntimeStats());\n        Table table = metastore.getTable(metastoreContext, schemaName, tableName)\n                .orElseThrow(() -> new TableNotFoundException(schemaTableName));\n        if (table.getPartitionColumns().isEmpty()) {\n            throw new PrestoException(INVALID_PROCEDURE_ARGUMENT, \"Table is not partitioned: \" + schemaTableName);\n        }\n        Path tableLocation = new Path(table.getStorage().getLocation());\n        HdfsContext context = new HdfsContext(session, schemaName, tableName, table.getStorage().getLocation(), false);\n\n        Set<String> partitionsToAdd;\n        Set<String> partitionsToDrop;\n\n        try {\n            FileSystem fileSystem = hdfsEnvironment.getFileSystem(context, tableLocation);\n            List<PartitionNameWithVersion> partitionNamesInMetastore = metastore.getPartitionNames(metastoreContext, schemaName, tableName)\n                    .orElseThrow(() -> new TableNotFoundException(schemaTableName));\n            ImmutableList.Builder<String> partitionsInMetastore = new ImmutableList.Builder<>();\n            for (List<PartitionNameWithVersion> batchPartitionNames : partition(partitionNamesInMetastore, GET_PARTITION_BY_NAMES_BATCH_SIZE)) {\n                Map<String, Optional<Partition>> partitionsOptionalMap = metastore.getPartitionsByNames(metastoreContext, schemaName, tableName, batchPartitionNames);\n                for (Map.Entry<String, Optional<Partition>> entry : partitionsOptionalMap.entrySet()) {\n                    if (entry.getValue().isPresent()) {\n                        partitionsInMetastore.add(tableLocation.toUri().relativize(new Path(entry.getValue().get().getStorage().getLocation()).toUri()).getPath());\n                    }","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/SyncPartitionMetadataProcedure.java#L118-L154","documentation":"INVALID_PROCEDURE_ARGUMENT from the system.sync_partition_metadata procedure when invoked on a table that has no partition columns. The procedure synchronizes partition metadata with files on HDFS, which is only meaningful for partitioned tables.","triggerScenarios":"CALL system.sync_partition_metadata('schema','table','ADD'|'DROP'|'FULL') on a non-partitioned table: metastore.getTable succeeds but table.getPartitionColumns().isEmpty() is true in doSyncPartitionMetadata.","commonSituations":"Running the procedure against an unpartitioned table by mistake; passing wrong table name that resolves to a plain table; assuming all tables in a schema are partitioned in scripted maintenance jobs.","solutions":["Confirm the table is partitioned: SHOW CREATE TABLE and check PARTITIONED BY; only run the procedure on partitioned tables","Correct the schema/table name arguments if you meant a different table","For unpartitioned tables there is nothing to sync; skip the call or drop/re-register the table if metadata is stale"],"exampleFix":"// before\nCALL system.sync_partition_metadata('default', 'events_flat', 'FULL');\n// after: verify first, then target a partitioned table\nSHOW CREATE TABLE default.events_flat; -- confirm PARTITIONED BY\nCALL system.sync_partition_metadata('default', 'events_partitioned', 'FULL');","handlingStrategy":"validation","validationCode":"-- before calling the procedure\nSHOW CREATE TABLE schema.table; -- must show PARTITIONED BY\n-- or programmatic:\nTable t = metastore.getTable(metastoreContext, schema, tableName)\n    .orElseThrow(() -> new IllegalArgumentException(\"table missing\"));\nif (t.getPartitionColumns().isEmpty()) {\n    throw new IllegalArgumentException(\"Not partitioned, skip sync: \" + schema + \".\" + tableName);\n}","typeGuard":"static boolean isPartitioned(Table table) {\n    return table != null && !table.getPartitionColumns().isEmpty();\n}","tryCatchPattern":"try {\n    session.execute(\"CALL system.sync_partition_metadata('schema','table','FULL')\");\n} catch (PrestoException e) {\n    if (StandardErrorCode.INVALID_PROCEDURE_ARGUMENT.toErrorCode().equals(e.getErrorCode())\n            && e.getMessage().startsWith(\"Table is not partitioned:\")) {\n        // skip or correct the table name\n    } else throw e;\n}","preventionTips":["Check SHOW CREATE TABLE for PARTITIONED BY before running sync_partition_metadata","Validate schema/table arguments in maintenance scripts","Filter candidate tables to partitioned ones (e.g. via SHOW PARTITIONS probing)","Skip non-partitioned tables explicitly in scheduled sync jobs"],"tags":["hive","procedure","partitioning","invalid-argument"],"backgroundTag":"table-not-partitioned","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"}