pathwaycom/pathway · error · TypeError

Indexing a table with a Pointer type with probably mismatche

Error message

Indexing a table with a Pointer type with probably mismatched primary keys. Type used was {key_dtype}. Indexed id type was {supertype}.

What it means

Raised by Table.ix() when the key is Pointer-typed but its id dtype does not match the indexed table's id column dtype (self._id_column.dtype). Pathway needs the pointer's id type to be compatible with the table's primary key type to guarantee lookups resolve. With optional=True both sides are wrapped in dt.Optional before comparison.

Source

Thrown at python/pathway/internals/table.py:1504

                name="ix",
            )
        restrict_universe = RestrictUniverseDesugaring(context)
        expression = restrict_universe.eval_expression(expression)
        key_tab = context.select(tmp=expression)
        key_col = key_tab.tmp
        key_dtype = key_tab.eval_type(key_col)
        supertype = dt.ANY_POINTER
        if optional:
            supertype = dt.Optional(supertype)
        if not dt.dtype_issubclass(key_dtype, supertype):
            raise TypeError(
                f"Pathway supports indexing with Pointer type only. The type used was {key_dtype}."
            )
        supertype = self._id_column.dtype
        if optional:
            supertype = dt.Optional(supertype)
        if not dt.dtype_issubclass(key_dtype, supertype):
            raise TypeError(
                "Indexing a table with a Pointer type with probably mismatched primary keys."
                + f" Type used was {key_dtype}. Indexed id type was {supertype}."
            )
        if optional and isinstance(key_dtype, dt.Optional):
            self_ = self.update_types(
                **{name: dt.Optional(self.typehints()[name]) for name in self.keys()}
            )
        else:
            self_ = self
        if allow_misses:
            subset = self_._having(key_col)
            new_key_col = key_tab.restrict(subset).tmp
            fill = key_tab.difference(subset).select(
                **{name: None for name in self.column_names()}
            )
            return Table.concat(
                self_._ix(new_key_col, optional=optional), fill
            ).with_universe_of(key_tab)

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Align id dtypes before indexing: t1.update_id_type(pw.Pointer()) on one side, or cast the key column so both are the same Pointer subtype
  2. Build both tables' ids from the same underlying value type (e.g. both from pw.int_as_pointer or both from strings)
  3. Verify the mismatch first: print t1._id_column.dtype and t2._id_column.dtype
  4. If you are matching on a business key rather than table ids, switch to join()

Example fix

// before
t3 = t1.ix(t2.id)  # Pointer[str] vs Pointer[int] -> TypeError

// after
t1_generic = t1.update_id_type(pw.Pointer())
t3 = t1_generic.ix(t2.id)
Defensive patterns

Strategy: validation

Validate before calling

from pathway.internals import dtype as dt

def ids_compatible(t1, t2) -> bool:
    a, b = t1._id_column.dtype, t2._id_column.dtype
    return dt.dtype_issubclass(a, b) or dt.dtype_issubclass(b, a)

Type guard

def same_id_dtype(t1, t2) -> bool:
    return t1._id_column.dtype == t2._id_column.dtype

Try / catch

try:
    t3 = t1.ix(t2.id)
except TypeError as e:
    if 'mismatched primary keys' in str(e):
        t3 = t1.update_id_type(pw.Pointer()).ix(t2.id)

Prevention

When it happens

Trigger: t1.ix(t2.id) where t1's ids are Pointer[int] and t2's ids are Pointer[str] (or vice versa); tables built from different connectors whose id dtypes differ; indexing after update_id_type changed one side.

Common situations: Mixing tables from different sources (CSV ids vs. Kafka keys); using pointer_from_string on one table and integer ids on another; after schema changes in connectors between versions.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/b2965e575003e344. Report an issue: GitHub.