prestodb/presto · error · PrestoException

HIVE_INVALID_METADATA

HIVE_INVALID_METADATA

Error message

Invalid value for %s property: %s

What it means

Thrown by getPositiveIntegerValue when a table property (e.g. orc_bloom_filter_fpp, buckets-related integers) parsed from the Hive schema Properties is negative. Presto requires these stored properties to be positive integers.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveUtil.java:1087

    }

    public static int getHeaderCount(Properties schema)
    {
        return getPositiveIntegerValue(schema, "skip.header.line.count", "0");
    }

    public static int getFooterCount(Properties schema)
    {
        return getPositiveIntegerValue(schema, "skip.footer.line.count", "0");
    }

    private static int getPositiveIntegerValue(Properties schema, String key, String defaultValue)
    {
        String value = schema.getProperty(key, defaultValue);
        try {
            int intValue = Integer.parseInt(value);
            if (intValue < 0) {
                throw new PrestoException(HIVE_INVALID_METADATA, format("Invalid value for %s property: %s", key, value));
            }
            return intValue;
        }
        catch (NumberFormatException e) {
            throw new PrestoException(HIVE_INVALID_METADATA, format("Invalid value for %s property: %s", key, value));
        }
    }

    public static Object typedPartitionKey(ConnectorSession session, String value, Type type, String name, DateTimeZone hiveStorageTimeZone)
    {
        byte[] bytes = value.getBytes(UTF_8);

        if (isHiveNull(bytes)) {
            return null;
        }
        else if (type.equals(BOOLEAN)) {
            return booleanPartitionKey(value, name);
        }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Fix the table property in the metastore: ALTER TABLE ... SET TBLPROPERTIES ('key'='positive_value')
  2. Inspect the table's SERDEPROPERTIES/TBLPROPERTIES and remove the negative key
  3. Recreate the table with correct properties if the metastore entry is corrupt

Example fix

-- before
ALTER TABLE db.t SET TBLPROPERTIES ('orc_bloom_filter_fpp'='-0.5');
-- after
ALTER TABLE db.t SET TBLPROPERTIES ('orc_bloom_filter_fpp'='0.05');
Defensive patterns

Strategy: validation

Validate before calling

Properties schema = /* metastore table properties */;
String v = schema.getProperty("orc_bloom_filter_fpp", "0.05");
if (Integer.parseInt(v) < 0) throw new IllegalStateException("fix table property: negative value " + v);

Type guard

boolean hasPositiveIntProperty(java.util.Properties schema, String key) {
    try { return Integer.parseInt(schema.getProperty(key, "0")) >= 0; }
    catch (NumberFormatException e) { return false; }
}

Try / catch

try { conn.createStatement().executeQuery("SELECT ... FROM db.t"); }
catch (com.facebook.presto.spi.PrestoException e) {
    if ("HIVE_INVALID_METADATA".equals(e.getErrorCode().getName())) { /* ALTER TABLE SET TBLPROPERTIES */ }
    else throw e;
}

Prevention

When it happens

Trigger: Reading table metadata where a known integer property stored in the metastore's Properties is a negative integer (parses fine but intValue < 0).

Common situations: Corrupt/manually edited table properties in the metastore; external tools writing negative values; schema-injected properties with invalid defaults.

Related errors


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