prestodb/presto · error · ValidationException

Invalid Hive object for %s.%s

Error message

Invalid Hive object for %s.%s

What it means

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.

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/HiveTableOperations.java:328

                    ImmutableMultimap.of());
            try {
                if (base == null) {
                    metastore.createTable(metastoreContext, table, privileges, emptyList());
                }
                else {
                    PartitionStatistics tableStats = metastore.getTableStatistics(metastoreContext, database, tableName);
                    metastore.persistTable(metastoreContext, database, tableName, table, privileges, () -> tableStats, useHMSLock ? ImmutableMap.of() : hmsEnvContext(base.metadataFileLocation()));
                }
            }
            catch (AlreadyExistsException e) {
                throw new PrestoException(HIVE_METASTORE_ERROR, format("Table already exists: %s.%s", database, tableName), e);
            }
            catch (CommitFailedException | CommitStateUnknownException e) {
                throw e;
            }
            catch (Throwable e) {
                if (e instanceof PrestoException && e.getCause() instanceof InvalidObjectException) {
                    throw new ValidationException(e, "Invalid Hive object for %s.%s", database, tableName);
                }
                if (e.getMessage() != null
                        && e.getMessage().contains("Table/View 'HIVE_LOCKS' does not exist")) {
                    throw new PrestoException(ICEBERG_COMMIT_ERROR,
                            "Failed to acquire locks from metastore because the underlying metastore "
                                    + "table 'HIVE_LOCKS' does not exist. This can occur when using an embedded metastore which does not "
                                    + "support transactions. To fix this use an alternative metastore.",
                            e);
                }
                CommitStatus commitStatus;
                if (e.getMessage() != null
                        && e.getMessage()
                        .contains(
                                "The table has been modified. The parameter value for key '"
                                        + METADATA_LOCATION_PROP
                                        + "' is")) {
                    // It's possible the HMS client incorrectly retries a successful operation, due to network
                    // issue for example, and triggers this exception. So we need double-check to make sure

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the wrapped InvalidObjectException cause to find the offending field; rename offending table/columns to HMS-valid identifiers.
  2. Remove or change unsupported data types so toHiveColumns() produces valid Hive types.
  3. Check metastore configuration (e.g. strict validation settings) and align naming conventions.

Example fix

// before
Schema schema = new Schema(
    Types.NestedField.optional(1, "order id", Types.LongType.get()));
// after
Schema schema = new Schema(
    Types.NestedField.optional(1, "order_id", Types.LongType.get()));
Defensive patterns

Strategy: validation

Validate before calling

// ensure identifiers are HMS-safe before create
String name = columnName;
if (!name.matches("[a-zA-Z_][a-zA-Z0-9_]*")) throw new IllegalArgumentException("Invalid column name: " + name);

Try / catch

try { commit(); }
catch (ValidationException e) { /* inspect e.getCause() (InvalidObjectException) and fix schema/naming */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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