{"record":{"id":"ac7a02030b9e9a83","repo":"risingwavelabs/risingwave","slug":"enable-pk-index-is-only-supported-for-upsert-ice","errorCode":null,"errorMessage":"`enable_pk_index` is only supported for upsert iceberg sink","messagePattern":"`enable_pk_index` is only supported for upsert iceberg sink","errorType":"validation","errorClass":"SinkError::Config","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/iceberg/config.rs","lineNumber":545,"sourceCode":"        sink_type: &str,\n        write_mode: IcebergWriteMode,\n    ) -> Result<()> {\n        if sink_type == SINK_TYPE_APPEND_ONLY && write_mode == IcebergWriteMode::CopyOnWrite {\n            return Err(SinkError::Config(anyhow!(\n                \"'copy-on-write' mode is not supported for append-only iceberg sink. \\\n                 Please use 'merge-on-read' instead, which is strictly better for append-only workloads.\"\n            )));\n        }\n        Ok(())\n    }\n\n    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!(","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/iceberg/config.rs#L527-L563","documentation":"This error is raised during Iceberg sink configuration validation when `enable_pk_index = true` is set on a sink whose `type` is not `upsert`. The primary-key index feature only makes sense for upsert sinks, where a per-key index is needed to locate and overwrite rows; append-only sinks never update existing rows, so the option is rejected. Validation happens in `validate_enable_pk_index` (src/connector/src/sink/iceberg/config.rs:539), which is run when the sink config is built via `IcebergConfig::from_btreemap`.","triggerScenarios":"Creating an Iceberg sink with WITH option `enable_pk_index = true` while `type = 'append-only'` (or any type other than 'upsert'). The check `self.r#type != SINK_TYPE_UPSERT` fails and `SinkError::Config` is returned before the sink is created.","commonSituations":"Copy-pasting a working upsert sink DDL and only changing the sink type to append-only while leaving `enable_pk_index` in the WITH clause; enabling the flag by habit on an append-only changelog sink; combining the flag with table-appender style sinks where it has no effect.","solutions":["Remove `enable_pk_index = true` from the sink WITH options if the sink is append-only.","Change the sink `type` to `'upsert'` (and provide a `primary-key` or keep `enable_pk_index`) if upsert semantics are intended.","If only append-only output is needed, drop the pk-index feature entirely — it provides no benefit for append-only sinks."],"exampleFix":"-- before\nCREATE SINK s INTO iceberg_t WITH (\n  connector = 'iceberg',\n  type = 'append-only',\n  enable_pk_index = true\n);\n\n-- after\nCREATE SINK s INTO iceberg_t WITH (\n  connector = 'iceberg',\n  type = 'append-only'\n);","handlingStrategy":"validation","validationCode":"-- run before creating the sink\nSELECT * FROM rw_catalog.rw_sinks WHERE name = 'my_sink';\n-- ensure WITH options satisfy: type = 'upsert' whenever enable_pk_index = true","typeGuard":null,"tryCatchPattern":"-- sink creation fails synchronously with a config error; fix the WITH clause and retry\nCREATE SINK s INTO t WITH (connector='iceberg', type='upsert', enable_pk_index=true);","preventionTips":["Never copy `enable_pk_index` into append-only sink templates.","Treat `enable_pk_index` as an upsert-only flag and document it next to `type`.","Validate the WITH clause against the flag matrix (type/write_mode/format_version/force_append_only) before submitting DDL."],"tags":["iceberg","sink","config-validation","risingwave"],"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"}