{"record":{"id":"6cacd1b9fd97b310","repo":"prestodb/presto","slug":"invalid-hive-object-for-s-s","errorCode":null,"errorMessage":"Invalid Hive object for %s.%s","messagePattern":"Invalid Hive object for (.+?)\\.(.+?)","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/HiveTableOperations.java","lineNumber":328,"sourceCode":"                    ImmutableMultimap.of());\n            try {\n                if (base == null) {\n                    metastore.createTable(metastoreContext, table, privileges, emptyList());\n                }\n                else {\n                    PartitionStatistics tableStats = metastore.getTableStatistics(metastoreContext, database, tableName);\n                    metastore.persistTable(metastoreContext, database, tableName, table, privileges, () -> tableStats, useHMSLock ? ImmutableMap.of() : hmsEnvContext(base.metadataFileLocation()));\n                }\n            }\n            catch (AlreadyExistsException e) {\n                throw new PrestoException(HIVE_METASTORE_ERROR, format(\"Table already exists: %s.%s\", database, tableName), e);\n            }\n            catch (CommitFailedException | CommitStateUnknownException e) {\n                throw e;\n            }\n            catch (Throwable e) {\n                if (e instanceof PrestoException && e.getCause() instanceof InvalidObjectException) {\n                    throw new ValidationException(e, \"Invalid Hive object for %s.%s\", database, tableName);\n                }\n                if (e.getMessage() != null\n                        && e.getMessage().contains(\"Table/View 'HIVE_LOCKS' does not exist\")) {\n                    throw new PrestoException(ICEBERG_COMMIT_ERROR,\n                            \"Failed to acquire locks from metastore because the underlying metastore \"\n                                    + \"table 'HIVE_LOCKS' does not exist. This can occur when using an embedded metastore which does not \"\n                                    + \"support transactions. To fix this use an alternative metastore.\",\n                            e);\n                }\n                CommitStatus commitStatus;\n                if (e.getMessage() != null\n                        && e.getMessage()\n                        .contains(\n                                \"The table has been modified. The parameter value for key '\"\n                                        + METADATA_LOCATION_PROP\n                                        + \"' is\")) {\n                    // It's possible the HMS client incorrectly retries a successful operation, due to network\n                    // issue for example, and triggers this exception. So we need double-check to make sure","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/HiveTableOperations.java#L310-L346","documentation":"When persisting the table to HMS throws anything whose root cause is java.security.InvalidObjectException, Presto treats it as a malformed Hive object and rethrows as a ValidationException 'Invalid Hive object for <db>.<table>'. This means the Table object built for HMS failed metastore-side validation.","triggerScenarios":"commit() (typically first create) where persistTable/metastore call fails with InvalidObjectException — e.g. invalid column names/types for Hive, illegal characters or reserved names in table/column identifiers.","commonSituations":"Iceberg columns with names/types HMS rejects (special characters, very long names, unsupported type mapping when Hive-style validation is on); table names with uppercase or invalid characters depending on metastore config.","solutions":["Inspect the wrapped InvalidObjectException cause to find the offending field; rename offending table/columns to HMS-valid identifiers.","Remove or change unsupported data types so toHiveColumns() produces valid Hive types.","Check metastore configuration (e.g. strict validation settings) and align naming conventions."],"exampleFix":"// before\nSchema schema = new Schema(\n    Types.NestedField.optional(1, \"order id\", Types.LongType.get()));\n// after\nSchema schema = new Schema(\n    Types.NestedField.optional(1, \"order_id\", Types.LongType.get()));","handlingStrategy":"validation","validationCode":"// ensure identifiers are HMS-safe before create\nString name = columnName;\nif (!name.matches(\"[a-zA-Z_][a-zA-Z0-9_]*\")) throw new IllegalArgumentException(\"Invalid column name: \" + name);","typeGuard":null,"tryCatchPattern":"try { commit(); }\ncatch (ValidationException e) { /* inspect e.getCause() (InvalidObjectException) and fix schema/naming */ }","preventionTips":["Stick to Hive-safe identifiers (alphanumeric + underscore).","Avoid types that map poorly to Hive columns.","Test DDL against the target metastore version first."],"tags":["iceberg","hive-metastore","validation","schema"],"backgroundTag":"invalid-hive-object","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"}