prestodb/presto · error · PrestoException

HIVE_INVALID_PARTITION_VALUE

HIVE_INVALID_PARTITION_VALUE

Error message

Invalid partition value '%s' for BOOLEAN partition key: %s

What it means

This error is thrown by HiveUtil.booleanPartitionKey when a partition value string for a BOOLEAN partition column cannot be interpreted as true or false. The Hive connector parses string partition values in the metastore into their typed representations; if the string is not (case-insensitively) 'true' or 'false', the connector cannot build the partition and throws HIVE_INVALID_PARTITION_VALUE. It indicates the partition value stored in or supplied to the metastore does not match the declared column type.

Source

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

    {
        String baseName = type.getTypeSignature().getBase();
        return baseName.equals(StandardTypes.MAP) || baseName.equals(StandardTypes.ARRAY) || baseName.equals(StandardTypes.ROW);
    }

    public static boolean isStructuralType(HiveType hiveType)
    {
        return hiveType.getCategory() == Category.LIST || hiveType.getCategory() == Category.MAP || hiveType.getCategory() == Category.STRUCT;
    }

    public static boolean booleanPartitionKey(String value, String name)
    {
        if (value.equalsIgnoreCase("true")) {
            return true;
        }
        if (value.equalsIgnoreCase("false")) {
            return false;
        }
        throw new PrestoException(HIVE_INVALID_PARTITION_VALUE, format("Invalid partition value '%s' for BOOLEAN partition key: %s", value, name));
    }

    public static long bigintPartitionKey(String value, String name)
    {
        try {
            return parseLong(value);
        }
        catch (NumberFormatException e) {
            throw new PrestoException(HIVE_INVALID_PARTITION_VALUE, format("Invalid partition value '%s' for BIGINT partition key: %s", value, name));
        }
    }

    public static long integerPartitionKey(String value, String name)
    {
        try {
            return parseInt(value);
        }
        catch (NumberFormatException e) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Correct the partition value string to 'true' or 'false' (case-insensitive) at the source that writes the partition (writer job, ALTER TABLE ADD PARTITION, or metastore data).
  2. If partitions already exist with bad values, repair them: drop and re-add the partition with a valid value, or use MSCK/ALTER TABLE to fix the metastore entries.
  3. Verify the partition column type matches the data actually written; if values are genuinely 1/0, consider a BIGINT/INTEGER partition key instead of BOOLEAN.
  4. Filter out or map special sentinel values (e.g. __HIVE_DEFAULT_PARTITION__, empty strings) before parsing.

Example fix

// before (writer)
String value = boolVal ? "1" : "0";
// after
String value = boolVal ? "true" : "false";
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidBooleanPartitionValue(String v) { return "true".equalsIgnoreCase(v) || "false".equalsIgnoreCase(v); }

Try / catch

try { ... } catch (PrestoException e) { if (HiveErrorCode.HIVE_INVALID_PARTITION_VALUE.toErrorCode().getCode() == e.getErrorCode().getCode()) { /* repair partition value or skip partition */ } else throw e; }

Prevention

When it happens

Trigger: Calling parsePartitionValue or typedPartitionKey for a BOOLEAN partition key whose string value is anything other than 'true'/'false' (ignoring case), e.g. '1', '0', 'yes', '', 'TRUE ' with trailing whitespace.

Common situations: Writing partitions with tools that serialize booleans as 1/0 (common in Spark/Python writers), empty partition directories like key=__HIVE_DEFAULT_PARTITION__ or blank values, or a table whose partition column type was changed to BOOLEAN after partitions were created with raw strings.

Related errors


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