{"record":{"id":"23666f3173328d07","repo":"pathwaycom/pathway","slug":"metadata-column-col-name-r-does-not-belong-to-t","errorCode":null,"errorMessage":"metadata column {col._name!r} does not belong to the provided table. Pass column references from the same table, e.g. table.{col._name}.","messagePattern":"metadata column (.+?) does not belong to the provided table\\. Pass column references from the same table, e\\.g\\. table\\.(.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/leann/__init__.py","lineNumber":270,"sourceCode":"\n    >>> pw.run()  # doctest: +SKIP\n    \"\"\"\n    _check_entitlements(\"leann\")\n    _check_leann_available()\n\n    if text_column._table is not table:\n        raise ValueError(\n            f\"text_column {text_column._name!r} does not belong to the provided \"\n            f\"table. Pass a column reference from the same table, \"\n            f\"e.g. text_column=table.{text_column._name}.\"\n        )\n    _check_str_column(text_column, \"text_column\")\n\n    metadata_col_names: list[str] | None = None\n    if metadata_columns is not None:\n        for col in metadata_columns:\n            if col._table is not table:\n                raise ValueError(\n                    f\"metadata column {col._name!r} does not belong to the provided \"\n                    f\"table. Pass column references from the same table, \"\n                    f\"e.g. table.{col._name}.\"\n                )\n            _check_str_column(col, \"metadata column\")\n        metadata_col_names = [col._name for col in metadata_columns]\n\n    # Import here to avoid circular import\n    from pathway.io.python import write as python_write\n\n    observer = _LeannObserver(\n        index_path=index_path,\n        text_column=text_column._name,\n        metadata_columns=metadata_col_names,\n        backend_name=backend_name,\n        embedding_mode=embedding_mode,\n        embedding_model=embedding_model,\n        embedding_options=embedding_options,","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/leann/__init__.py#L252-L288","documentation":"Like text_column, every column in metadata_columns of pw.io.leann.write must belong to the table passed as the first argument. Pathway checks each reference's bound table and raises this ValueError for the first mismatch, suggesting the correct reference form table.<name>.","triggerScenarios":"pw.io.leann.write(table, path, text_column=table.text, metadata_columns=[other.author]) where other is any table other than the one passed (e.g. a join partner or an earlier transform stage).","commonSituations":"Collecting metadata columns from several sources (joins) and forgetting to flatten them into one table; passing columns from a table before with_columns renames.","solutions":["Join or select all needed metadata columns into the single table passed to write(), then reference them from that table","Build metadata_columns as [table[c] for c in names] right before the call so references always match","Check table == col._table for each column before calling if references come from dynamic code"],"exampleFix":"# before\nenriched = table.join(authors, table.aid == authors.id)\npw.io.leann.write(table, \"idx\", table.text, metadata_columns=[enriched.name])\n\n# after\nenriched = table.join(authors, table.aid == authors.id).select(table.text, author=authors.name)\npw.io.leann.write(enriched, \"idx\", enriched.text, metadata_columns=[enriched.author])","handlingStrategy":"validation","validationCode":"for col in metadata_columns or []:\n    assert col._table is table, f\"metadata column {col._name!r} not from the written table\"\n_ = [table[c._name] for c in metadata_columns or []]  # canonical references","typeGuard":"def all_columns_from(table: pw.Table, cols: list[pw.ColumnReference]) -> bool:\n    return all(c._table is table for c in cols)","tryCatchPattern":"try:\n    pw.io.leann.write(table, \"idx\", table.text, metadata_columns=cols)\nexcept ValueError as e:\n    if \"does not belong to the provided table\" in str(e):\n        cols = [table[c._name] for c in cols]\n        pw.io.leann.write(table, \"idx\", table.text, metadata_columns=cols)\n    else:\n        raise","preventionTips":["Flatten joins into one table before the connector call","Build metadata_columns as table[name] lookups at the call site","Assert col._table is table for every column passed to sinks"],"tags":["leann","pathway","column-reference","metadata","validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}