{"record":{"id":"c11b67e6c8acb84c","repo":"pathwaycom/pathway","slug":"output-table-type-snapshot-requires-the-primary","errorCode":null,"errorMessage":"output_table_type='snapshot' requires the primary_key parameter: pass the column(s) that identify each row so the connector can maintain the current snapshot keyed by them.","messagePattern":"output_table_type='snapshot' requires the primary_key parameter: pass the column\\(s\\) that identify each row so the connector can maintain the current snapshot keyed by them\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/clickhouse/__init__.py","lineNumber":246,"sourceCode":"    _check_entitlements(\"clickhouse\")\n\n    is_snapshot_mode = output_table_type == SNAPSHOT_OUTPUT_TABLE_TYPE\n\n    column_names = set(table.schema.column_names())\n    metadata_columns = (\n        {\"version\", \"is_deleted\"} if is_snapshot_mode else {\"time\", \"diff\"}\n    )\n    reserved = metadata_columns & column_names\n    if reserved:\n        raise ValueError(\n            f\"Column name(s) {sorted(reserved)!r} collide with the reserved \"\n            f\"{sorted(metadata_columns)!r} metadata columns appended by \"\n            \"pw.io.clickhouse.write. Rename the column(s) in your schema before writing.\"\n        )\n    key_field_names: list[str] | None = None\n    if is_snapshot_mode:\n        if primary_key is None or not list(primary_key):\n            raise ValueError(\n                \"output_table_type='snapshot' requires the primary_key parameter: \"\n                \"pass the column(s) that identify each row so the connector can \"\n                \"maintain the current snapshot keyed by them.\"\n            )\n        key_field_names = [column.name for column in primary_key]\n    elif primary_key is not None:\n        raise ValueError(\n            \"The primary_key parameter is only used with output_table_type='snapshot'; \"\n            \"remove it or set output_table_type='snapshot'.\"\n        )\n\n    data_storage = api.DataStorage(\n        storage_type=\"clickhouse\",\n        connection_string=connection_string,\n        table_name=table_name,\n        max_batch_size=max_batch_size,\n        table_writer_init_mode=init_mode_from_str(init_mode),\n        snapshot_maintenance_on_output=is_snapshot_mode,","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/clickhouse/__init__.py#L228-L264","documentation":"Error \"output_table_type='snapshot' requires the primary_key parameter: pass the column(s) that identify each row so the connector can maintain the current snapshot keyed by them.\" thrown in pathwaycom/pathway.","triggerScenarios":"Thrown at python/pathway/io/clickhouse/__init__.py:246 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass primary_key=[...] with the identifying columns when output_table_type='snapshot'."],"exampleFix":"pw.io.clickhouse.write(t, ..., output_table_type='snapshot', primary_key=[t.k])","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}