{"record":{"id":"6fb8548639595c14","repo":"apache/flink","slug":"cannot-find-the-partition-value-from-path-for-part","errorCode":null,"errorMessage":"Cannot find the partition value from path for partition: %s","messagePattern":"Cannot find the partition value from path for partition: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileInfoExtractorBulkFormat.java","lineNumber":147,"sourceCode":"        // Fill the metadata + partition columns row\n        final GenericRowData fileInfoRowData =\n                new GenericRowData(metadataColumnsFunctions.size() + partitionColumnTypes.size());\n        int fileInfoRowIndex = 0;\n        for (; fileInfoRowIndex < metadataColumnsFunctions.size(); fileInfoRowIndex++) {\n            fileInfoRowData.setField(\n                    fileInfoRowIndex,\n                    metadataColumnsFunctions.get(fileInfoRowIndex).getValue(split));\n        }\n        if (!partitionColumnTypes.isEmpty()) {\n            final LinkedHashMap<String, String> partitionSpec =\n                    PartitionPathUtils.extractPartitionSpecFromPath(split.path());\n            for (int partitionFieldIndex = 0;\n                    fileInfoRowIndex < fileInfoRowData.getArity();\n                    fileInfoRowIndex++, partitionFieldIndex++) {\n                final String fieldName = partitionColumnTypes.get(partitionFieldIndex).getKey();\n                final DataType fieldType = partitionColumnTypes.get(partitionFieldIndex).getValue();\n                if (!partitionSpec.containsKey(fieldName)) {\n                    throw new RuntimeException(\n                            \"Cannot find the partition value from path for partition: \"\n                                    + fieldName);\n                }\n\n                String valueStr = partitionSpec.get(fieldName);\n                valueStr = valueStr.equals(defaultPartName) ? null : valueStr;\n                fileInfoRowData.setField(\n                        fileInfoRowIndex,\n                        PartitionPathUtils.convertStringToInternalValue(valueStr, fieldType));\n            }\n        }\n\n        // This row is going to be reused for every record\n        final EnrichedRowData producedRowData =\n                new EnrichedRowData(fileInfoRowData, this.extendedRowIndexMapping);\n\n        return RecordMapperWrapperRecordIterator.wrapReader(\n                superReader,","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileInfoExtractorBulkFormat.java#L129-L165","documentation":"FileInfoExtractorBulkFormat reads partition column values from the file path using PartitionPathUtils.extractPartitionSpecFromPath. For each declared partition column, it looks up the field name in the extracted partition spec map. If the field name is not found (the path does not contain a matching partition directory), it throws a RuntimeException.","triggerScenarios":"The table declares partition columns (partitionColumnTypes is non-empty) but the actual file path does not contain the expected partition directory structure. For example, the table expects partitions like /path/year=2024/month=01/ but the file is at /path/data.parquet without partition directories.","commonSituations":"Mismatch between the table's partition key definitions and the actual directory structure of the data files. Files placed outside the expected partition directory hierarchy. Table DDL changed to add partition keys but data files not moved to the correct partition paths. Using __HIVE_DEFAULT_PARTITION__ incorrectly.","solutions":["Verify the file path matches the partition directory structure expected by the table DDL. Ensure directories follow the pattern key=value/.","Check the table DDL partition columns match the directory names in the file system path.","If the data is genuinely unpartitioned, remove the partition key declarations from the table definition."],"exampleFix":"-- before\nCREATE TABLE t (a INT, b STRING) PARTITIONED BY (year, month)\n-- files at: /data/file.parquet  (no year= / month= dirs)\n\n-- after\n-- ensure files are at: /data/year=2024/month=01/file.parquet\n-- OR remove partitioning if data is not partitioned:\nCREATE TABLE t (a INT, b STRING) WITH ('path'='file:///data', 'format'='parquet')","handlingStrategy":"validation","validationCode":"// Validate partition paths before reading\nfor (String partitionKey : partitionKeys) {\n    String partitionDir = extractPartitionFromPath(filePath, partitionKey);\n    if (partitionDir == null) {\n        throw new RuntimeException(\n            \"Partition column '\" + partitionKey + \"' not found in path: \" + filePath);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure partition directory structure matches the table DDL partition key definitions.","Verify files are placed under key=value/ partition directories.","Test with a small sample file before running on the full dataset.","Use Flink's filesystem catalog to validate table-path consistency."],"tags":["partition","metadata","file-path","bulk-format","flink"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}