{"record":{"id":"b2965e575003e344","repo":"pathwaycom/pathway","slug":"indexing-a-table-with-a-pointer-type-with-probably","errorCode":null,"errorMessage":"Indexing a table with a Pointer type with probably mismatched primary keys. Type used was {key_dtype}. Indexed id type was {supertype}.","messagePattern":"Indexing a table with a Pointer type with probably mismatched primary keys\\. Type used was (.+?)\\. Indexed id type was (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/table.py","lineNumber":1504,"sourceCode":"                name=\"ix\",\n            )\n        restrict_universe = RestrictUniverseDesugaring(context)\n        expression = restrict_universe.eval_expression(expression)\n        key_tab = context.select(tmp=expression)\n        key_col = key_tab.tmp\n        key_dtype = key_tab.eval_type(key_col)\n        supertype = dt.ANY_POINTER\n        if optional:\n            supertype = dt.Optional(supertype)\n        if not dt.dtype_issubclass(key_dtype, supertype):\n            raise TypeError(\n                f\"Pathway supports indexing with Pointer type only. The type used was {key_dtype}.\"\n            )\n        supertype = self._id_column.dtype\n        if optional:\n            supertype = dt.Optional(supertype)\n        if not dt.dtype_issubclass(key_dtype, supertype):\n            raise TypeError(\n                \"Indexing a table with a Pointer type with probably mismatched primary keys.\"\n                + f\" Type used was {key_dtype}. Indexed id type was {supertype}.\"\n            )\n        if optional and isinstance(key_dtype, dt.Optional):\n            self_ = self.update_types(\n                **{name: dt.Optional(self.typehints()[name]) for name in self.keys()}\n            )\n        else:\n            self_ = self\n        if allow_misses:\n            subset = self_._having(key_col)\n            new_key_col = key_tab.restrict(subset).tmp\n            fill = key_tab.difference(subset).select(\n                **{name: None for name in self.column_names()}\n            )\n            return Table.concat(\n                self_._ix(new_key_col, optional=optional), fill\n            ).with_universe_of(key_tab)","sourceCodeStart":1486,"sourceCodeEnd":1522,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/table.py#L1486-L1522","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Build both tables' ids from the same underlying value type (e.g. both from pw.int_as_pointer or both from strings)","Verify the mismatch first: print t1._id_column.dtype and t2._id_column.dtype","If you are matching on a business key rather than table ids, switch to join()"],"exampleFix":"// before\nt3 = t1.ix(t2.id)  # Pointer[str] vs Pointer[int] -> TypeError\n\n// after\nt1_generic = t1.update_id_type(pw.Pointer())\nt3 = t1_generic.ix(t2.id)","handlingStrategy":"validation","validationCode":"from pathway.internals import dtype as dt\n\ndef ids_compatible(t1, t2) -> bool:\n    a, b = t1._id_column.dtype, t2._id_column.dtype\n    return dt.dtype_issubclass(a, b) or dt.dtype_issubclass(b, a)","typeGuard":"def same_id_dtype(t1, t2) -> bool:\n    return t1._id_column.dtype == t2._id_column.dtype","tryCatchPattern":"try:\n    t3 = t1.ix(t2.id)\nexcept TypeError as e:\n    if 'mismatched primary keys' in str(e):\n        t3 = t1.update_id_type(pw.Pointer()).ix(t2.id)","preventionTips":["Build ids for related tables from the same value type","Print _id_column.dtype when wiring tables from different connectors","Standardize on pw.Pointer for cross-source lookups"],"tags":["pathway","typing","table-indexing","pointer","id-type"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}