{"record":{"id":"8a52d9fa29a5c152","repo":"prestodb/presto","slug":"hudi-invalid-partition-value","errorCode":"HUDI_INVALID_PARTITION_VALUE","errorMessage":"Invalid partition value '%s' for %s partition key: %s","messagePattern":"Invalid partition value '(.+?)' for (.+?) partition key: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hudi/src/main/java/com/facebook/presto/hudi/HudiPageSource.java","lineNumber":245,"sourceCode":"            if (type instanceof VarcharType) {\n                return utf8Slice(valueString);\n            }\n            if (type.equals(VarbinaryType.VARBINARY)) {\n                return utf8Slice(valueString);\n            }\n            if (isShortDecimal(type) || isLongDecimal(type)) {\n                DecimalType decimalType = (DecimalType) type;\n                BigDecimal decimal = new BigDecimal(valueString);\n                decimal = decimal.setScale(decimalType.getScale(), BigDecimal.ROUND_UNNECESSARY);\n                if (decimal.precision() > decimalType.getPrecision()) {\n                    throw new IllegalArgumentException();\n                }\n                BigInteger unscaledValue = decimal.unscaledValue();\n                return isShortDecimal(type) ? unscaledValue.longValue() : Decimals.encodeUnscaledValue(unscaledValue);\n            }\n        }\n        catch (IllegalArgumentException e) {\n            throw new PrestoException(HUDI_INVALID_PARTITION_VALUE, format(\n                    \"Invalid partition value '%s' for %s partition key: %s\",\n                    valueString,\n                    type.getDisplayName(),\n                    name));\n        }\n        // Hudi tables don't partition by non-primitive-type columns.\n        throw new PrestoException(NOT_SUPPORTED, \"Invalid partition type \" + type);\n    }\n}\n","sourceCodeStart":227,"sourceCodeEnd":255,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hudi/src/main/java/com/facebook/presto/hudi/HudiPageSource.java#L227-L255","documentation":"A partition value string read from the Hudi split could not be parsed into the partition column's declared Presto type. deserializePartitionValue converts string partition values (path segments / key-values) to the target type; any IllegalArgumentException from the parser is rethrown as HUDI_INVALID_PARTITION_VALUE with the value, type, and column name.","triggerScenarios":"Scanning a Hudi partition whose stored string value cannot be converted by the target type's parser — e.g. non-numeric string for an integer partition column, malformed date/timestamp, out-of-range decimal, or empty value.","commonSituations":"Partition directories written with inconsistent formats (e.g. date partitioned as '2026-9-1' vs '2026-09-01'), partitions created by external tools with unparsable names, schema changed after data was written, URL-encoded or escaped values.","solutions":["Find the offending partition from the message and rewrite its value to match the column type (repair the partition path/data)","Fix the writer so partition values are serialized in the canonical format for the column type (e.g. ISO dates)","Alter the partition column type to one compatible with the stored string format and reload metadata","Use Hudi's repair/overwrite tooling (e.g. repair partition or overwrite the partition with corrected key values)"],"exampleFix":"// before: partition dir written as 'dt=2026/09/01' for a date column\n// after: write canonical value 'dt=2026-09-01'\nwriter.writePartitionValue(\"dt\", LocalDate.of(2026, 9, 1).toString()); // \"2026-09-01\"","handlingStrategy":"validation","validationCode":"// Before scanning, validate partition values against the column type\nString value = partitionKeyValue;      // e.g. from directory name\nType type = partitionColumnType;       // e.g. DATE\nif (!canParse(value, type)) {\n    throw new IllegalStateException(\"Partition value '\" + value +\n        \"' is not a valid \" + type.getDisplayName());\n}\nboolean canParse(String s, Type t) {\n    try {\n        if (t == BIGINT) Long.parseLong(s);\n        else if (t == DATE) LocalDate.parse(s);\n        else if (t == INTEGER) Integer.parseInt(s);\n        else return true;\n        return true;\n    } catch (RuntimeException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return pageSource.getNextPage();\n} catch (PrestoException e) {\n    if (isHudiErrorCode(e, \"HUDI_INVALID_PARTITION_VALUE\")) {\n        // repair/rewrite the offending partition, then retry\n    } else { throw e; }\n}","preventionTips":["Standardize partition value serialization in writers (canonical ISO formats, zero-padded numbers)","Add writer-side round-trip tests: parse every emitted partition value with the column type","Validate partition directory names after external jobs write to the table","Avoid renaming/reformatting partition columns after data exists"],"tags":["presto","hudi","partitioning","parsing","invalid-partition-value"],"backgroundTag":"invalid-partition-value","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"}