{"record":{"id":"85add122c92e2662","repo":"risingwavelabs/risingwave","slug":"partition-spec-not-found","errorCode":null,"errorMessage":"partition spec {} not found","messagePattern":"partition spec (.+?) not found","errorType":"exception","errorClass":"SinkError::Iceberg","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/iceberg/writer.rs","lineNumber":1019,"sourceCode":"            let truncated = truncate_datafile(f);\n            Ok(SerializedDataFile::try_from(\n                truncated,\n                partition_type,\n                format_version,\n            )?)\n        })\n        .collect()\n}\n\n/// Resolves a partition spec by id from the table metadata, with a consolidated\n/// error message. Shared spec-lookup mechanic for the pk-index merger, commit\n/// coordinator, and sink commit paths.\npub fn resolve_partition_spec(table: &Table, spec_id: i32) -> Result<PartitionSpecRef> {\n    table\n        .metadata()\n        .partition_spec_by_id(spec_id)\n        .cloned()\n        .ok_or_else(|| SinkError::Iceberg(anyhow!(\"partition spec {} not found\", spec_id)))\n}\n\n/// Resolves the partition [`StructType`] for the given `spec_id` against `schema`.\n///\n/// `schema` is passed explicitly (rather than read from the table) so callers can\n/// preserve their chosen schema, and `spec_id` is passed explicitly so callers can\n/// preserve their chosen spec (e.g. a file's own spec vs. the default spec).\npub fn resolve_partition_type(table: &Table, spec_id: i32, schema: &Schema) -> Result<StructType> {\n    resolve_partition_spec(table, spec_id)?\n        .partition_type(schema)\n        .map_err(|e| SinkError::Iceberg(anyhow!(e)))\n}\n\n/// Truncate large column statistics from `DataFile` BEFORE serialization.\n///\n/// This function directly modifies `DataFile`'s `lower_bounds` and `upper_bounds`\n/// to remove entries that exceed `MAX_COLUMN_STAT_SIZE`.\n///","sourceCodeStart":1001,"sourceCodeEnd":1037,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/iceberg/writer.rs#L1001-L1037","documentation":"resolve_partition_spec looks up a PartitionSpec by its id in the Iceberg table metadata. If the table has no spec with the given id (e.g. the referenced spec was replaced/removed or the id comes from stale metadata), it returns this SinkError::Iceberg error.","triggerScenarios":"Calling resolve_partition_spec(table, spec_id) with a spec_id that is absent from table.metadata().partition_specs — typically a spec_id persisted in sink state or data files that no longer exists in the current table metadata after a partition-spec change.","commonSituations":"Table schema/partition evolution between sink creation and commit; restoring sink state referencing an old spec id; pointing the sink at a different table than the one that produced the data files.","solutions":["Verify the spec_id against the current table metadata before committing (e.g. resolve via metadata.default_partition_spec_id() or partition_specs keys)","Recreate or rebuild the sink so its stored spec id matches the current table","Ensure commits read the same table snapshot/metadata that produced the data files"],"exampleFix":"// before\nlet spec = resolve_partition_spec(&table, file_spec_id)?;\n// after\nlet spec_id = table.metadata().default_partition_spec_id();\nlet spec = resolve_partition_spec(&table, spec_id)?;","handlingStrategy":"validation","validationCode":"fn has_spec(table: &Table, spec_id: i32) -> bool {\n    table.metadata().partition_spec_by_id(spec_id).is_some()\n}\n// guard: if !has_spec(&table, spec_id) { return Err(...); }","typeGuard":null,"tryCatchPattern":"let spec = resolve_partition_spec(&table, spec_id).context(\"resolving partition spec for commit\")?;","preventionTips":["Use the table's current default_partition_spec_id() unless a file's own spec is required","Re-check stored spec ids after any partition-spec evolution on the table","Commit against the same table metadata snapshot that produced the data files"],"tags":["iceberg","metadata","partition-spec","sink"],"backgroundTag":"resource-not-found","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}