{"record":{"id":"286faa498c61f7be","repo":"risingwavelabs/risingwave","slug":"enable-pk-index-is-only-supported-for-upsert-ice-286faa","errorCode":null,"errorMessage":"`enable_pk_index` is only supported for upsert iceberg sink with format version >= 2","messagePattern":"`enable_pk_index` is only supported for upsert iceberg sink with format version >= 2","errorType":"validation","errorClass":"SinkError::Config","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/iceberg/config.rs","lineNumber":557,"sourceCode":"    pub(crate) fn validate_enable_pk_index(&self) -> Result<()> {\n        if !self.enable_pk_index {\n            return Ok(());\n        }\n\n        if self.r#type != SINK_TYPE_UPSERT {\n            return Err(SinkError::Config(anyhow!(\n                \"`enable_pk_index` is only supported for upsert iceberg sink\"\n            )));\n        }\n\n        if self.write_mode != IcebergWriteMode::MergeOnRead {\n            return Err(SinkError::Config(anyhow!(\n                \"`enable_pk_index` is only supported for upsert iceberg sink with merge-on-read mode\"\n            )));\n        }\n\n        if self.format_version < FormatVersion::V2 {\n            return Err(SinkError::Config(anyhow!(\n                \"`enable_pk_index` is only supported for upsert iceberg sink with format version >= 2\"\n            )));\n        }\n\n        if self.force_append_only {\n            return Err(SinkError::Config(anyhow!(\n                \"`enable_pk_index` cannot be true when `force_append_only` is true\"\n            )));\n        }\n\n        Ok(())\n    }\n\n    pub fn from_btreemap(values: BTreeMap<String, String>) -> Result<Self> {\n        let mut config =\n            serde_json::from_value::<IcebergConfig>(serde_json::to_value(&values).unwrap())\n                .map_err(|e| SinkError::Config(anyhow!(e)))?;\n","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/iceberg/config.rs#L539-L575","documentation":"This error is raised when `enable_pk_index = true` is set on an upsert merge-on-read Iceberg sink whose `format_version` is below 2. Positional-delete/index structures used by the pk index require Iceberg format v2 features; v1 tables cannot represent them, so the config is rejected in `validate_enable_pk_index` (src/connector/src/sink/iceberg/config.rs:556).","triggerScenarios":"Creating an Iceberg upsert sink with `enable_pk_index = true`, `write_mode = 'merge-on-read'`, but `format_version = 1` (or omitted where the default resolves below v2). Fails at sink config validation.","commonSituations":"Writing to legacy Iceberg tables pinned to format v1; older table templates or existing catalogs created before v2 became standard; users unaware the pk index depends on v2 delete semantics.","solutions":["Set `format_version = 2` in the sink WITH options.","If the target Iceberg table is v1 and cannot be upgraded, remove `enable_pk_index` and supply an explicit `primary-key` instead.","Migrate the target table/catalog to format v2 if v1 is only a historical default."],"exampleFix":"-- before\nWITH (\n  connector = 'iceberg',\n  type = 'upsert',\n  write_mode = 'merge-on-read',\n  format_version = 1,\n  enable_pk_index = true\n);\n\n-- after\nWITH (\n  connector = 'iceberg',\n  type = 'upsert',\n  write_mode = 'merge-on-read',\n  format_version = 2,\n  enable_pk_index = true\n);","handlingStrategy":"validation","validationCode":"-- pin format_version = 2 whenever enable_pk_index = true\nWITH (connector='iceberg', type='upsert', write_mode='merge-on-read', format_version=2, enable_pk_index=true)","typeGuard":null,"tryCatchPattern":"-- config errors surface at CREATE SINK time; correct format_version and re-run","preventionTips":["Always set `format_version = 2` explicitly for new Iceberg sinks.","Check the target table's format version in the catalog before enabling v2-only features.","Avoid v1 unless legacy compatibility is required."],"tags":["iceberg","sink","format-version","config-validation"],"backgroundTag":"conflicting-config-options","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}