{"record":{"id":"7b96138674fb16b9","repo":"risingwavelabs/risingwave","slug":"partition-source-column-does-not-exist-in-schema","errorCode":null,"errorMessage":"Partition source column does not exist in schema: {}","messagePattern":"Partition source column does not exist in schema: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/iceberg/create_table.rs","lineNumber":196,"sourceCode":"    };\n\n    let partition_spec = match &config.partition_by {\n        Some(partition_by) => {\n            let mut partition_fields = Vec::<UnboundPartitionField>::new();\n            for (i, (column, transform)) in parse_partition_by_exprs(partition_by.clone())?\n                .into_iter()\n                .enumerate()\n            {\n                match iceberg_schema.field_id_by_name(&column) {\n                    Some(id) => partition_fields.push(\n                        UnboundPartitionField::builder()\n                            .source_id(id)\n                            .transform(transform)\n                            .name(format!(\"_p_{}\", column))\n                            .field_id(PARTITION_DATA_ID_START + i as i32)\n                            .build(),\n                    ),\n                    None => bail!(format!(\n                        \"Partition source column does not exist in schema: {}\",\n                        column\n                    )),\n                };\n            }\n            Some(\n                UnboundPartitionSpec::builder()\n                    .with_spec_id(0)\n                    .add_partition_fields(partition_fields)\n                    .map_err(|e| SinkError::Iceberg(anyhow!(e)))\n                    .context(\"failed to add partition columns\")?\n                    .build(),\n            )\n        }\n        None => None,\n    };\n\n    let sort_order = match &config.order_key {","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/iceberg/create_table.rs#L178-L214","documentation":"When the sink defines partitioning, each partition column must exist in the sink schema so a partition field (with source_id and transform) can be built. If a configured partition column name does not match any schema column, creation fails with this error naming the missing column.","triggerScenarios":"create_table_if_not_exists_impl looks up each name from the sink's partition config (column) in the schema's name-to-id map; the lookup returns None and the code bails — e.g. `partition.by = 'event_day'` where no column named event_day exists in the sink.","commonSituations":"Partition column renamed or dropped from the MV after the sink was defined; typo in partition.by; partitioning on a derived/alias column not included in the sink schema; case-sensitivity mismatch.","solutions":["Correct the partition column name in `partition.by` to exactly match a sink column.","Ensure the column exists in the materialized view/sink output (add it if it was dropped).","Recreate the sink after schema changes to refresh the partition config.","Check column name casing matches the schema exactly."],"exampleFix":"// before\nWITH (connector='iceberg', partition.by='event_day') -- column doesn't exist\n// after: add the column or fix the name\nCREATE MATERIALIZED VIEW mv AS SELECT date_trunc('day', ts) AS event_day, ... ;\nWITH (connector='iceberg', partition.by='event_day')","handlingStrategy":"validation","validationCode":"// Ensure every partition column exists in the sink schema\nfor col in partition_columns {\n    if !schema.fields().iter().any(|f| f.name().field_name == col) {\n        eprintln!(\"partition column {col} missing from sink schema\");\n    }\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Partition source column does not exist\") => {\n        // fix partition.by names or add the column to the MV\n    }\n    other => other?,\n}","preventionTips":["Keep partition.by names in sync with the MV columns; recreate the sink after schema changes.","Avoid renaming partition columns in upstream MVs.","Check exact casing of column names.","Add the derived partition column (e.g. date_trunc) to the MV before partitioning on it."],"tags":["rust","iceberg","partition","config"],"backgroundTag":"invalid-config-value","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"}