pathwaycom/pathway · error · ValueError
Two different columns share the output name {column_name!r}.
Error message
Two different columns share the output name {column_name!r}. This typically happens when, e.g., a header is aliased to the same name as the 'topic_name' or 'key' column, or when two separate selects produce the same output name. Alias one of them to a different name (e.g. via `table.select(<new_name>=...)`). What it means
Raised by MessageQueueOutputFormat.add_column_reference_to_extract while collecting the columns (topic_name, key, headers, value, all table columns) into one selection. The result table is keyed by column name, and two different underlying columns mapping to the same output name would silently collapse — one would be lost. The guard compares the internal _column identity of a previously seen same-named reference with the new one and fails if they differ. Same-column references repeated under one name are fine; unresolved pw.this.X references (whose _column is None) are also allowed.
Source
Thrown at python/pathway/io/_utils.py:643
index_in_new_table = field_indices.get(column_name)
if index_in_new_table is not None:
existing = selection_list[index_in_new_table]
# If a *different* column reference shares the same output name we
# would silently drop the new value because `table.select(...)`
# collapses entries by name. Detect this and fail loudly so the
# user can alias one of them to a unique name.
#
# Note: a `pw.this.X` reference has ``_column is None`` because it
# is resolved later at expression time. We treat such references
# as compatible with any earlier same-named column — they refer to
# the same column in the target table by definition.
if (
existing._column is not None
and column_reference._column is not None
and existing._column is not column_reference._column
):
raise ValueError(
f"Two different columns share the output name "
f"{column_name!r}. This typically happens when, e.g., a "
f"header is aliased to the same name as the 'topic_name' "
f"or 'key' column, or when two separate selects produce "
f"the same output name. Alias one of them to a different "
f"name (e.g. via `table.select(<new_name>=...)`)."
)
# Same column referenced more than once is fine — reuse the slot.
return index_in_new_table
index_in_new_table = len(selection_list)
field_indices[column_name] = index_in_new_table
selection_list.append(column_reference)
return index_in_new_table
def maybe_schema_registry_settings(
schema_registry_settings: SchemaRegistrySettings | None,View on GitHub (pinned to fa2f74a464)
Solutions
- Alias the colliding column to a unique name with table.select(<new_name>=...) before the write call.
- If both names refer to the same logical column, make sure they resolve to the same underlying column (reference the same table column object).
- Inspect which writer arguments (key, value, topic_name, headers) contribute the duplicate name named in the message.
Example fix
# before
pw.io.kafka.write(t, ..., topic_name=pw.this.topic,
headers=[other_table.topic]) # two distinct 'topic' columns
# after
other = other_table.select(header_topic=pw.this.topic)
pw.io.kafka.write(t, ..., topic_name=pw.this.topic,
headers=[other.header_topic]) Defensive patterns
Strategy: validation
Validate before calling
names = [c.name for c in [topic_name, key, value, *(headers or [])] if c is not None]
dupes = {n for n in names if names.count(n) > 1}
assert not dupes, f"output name collision across writer args: {sorted(dupes)}; alias one column" Type guard
def unique_output_names(topic_name=None, key=None, value=None, headers=None) -> bool:
names = [c.name for c in (topic_name, key, value, *(headers or [])) if c is not None]
return len(names) == len(set(names)) Try / catch
try:
pw.io.kafka.write(t, ..., topic_name=tn, key=k, headers=hs)
except ValueError as e:
if "share the output name" in str(e):
raise SystemExit(f"Alias the colliding column named in: {e}")
raise Prevention
- Namespace special writer columns: alias headers as header_*, key as key_*.
- After joins/unions, check for distinct-origin same-name columns before writing to message queues.
When it happens
Trigger: Aliasing a header to the same name as the key or topic_name column, e.g. headers=[pw.this.topic] together with topic_name=pw.this.topic from different selects; a table where two distinct columns were both aliased to 'payload' in separate selects and both end up in the writer.
Common situations: Joining or unioning tables that produce same-named columns from different origins; generic code that forwards user-selected columns as headers while key/topic_name also reference identically named but distinct columns.
Related errors
- Failed to install dependencies
- Column {pseudocolumn} has to contain integers only.
- Column {api.TIME_PSEUDOCOLUMN} cannot contain negative times
- Unsupported argument for {data_format!r} format: 'value'
- 'delimiter' is only meaningful for the 'dsv' format, but {fo
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/3b0e5be8008ab173.
Report an issue: GitHub.