{"record":{"id":"44cf5139326713e3","repo":"apache/beam","slug":"encountered-unknown-type-other-r","errorCode":null,"errorMessage":"Encountered unknown type {other!r}","messagePattern":"Encountered unknown type (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/partitionings.py","lineNumber":105,"sourceCode":"    if self._levels:\n      return hash(tuple(sorted(self._levels)))\n    else:\n      return hash(type(self))\n\n  def is_subpartitioning_of(self, other):\n    if isinstance(other, Singleton):\n      return True\n    elif isinstance(other, Index):\n      if self._levels is None:\n        return True\n      elif other._levels is None:\n        return False\n      else:\n        return all(level in self._levels for level in other._levels)\n    elif isinstance(other, (Arbitrary, JoinIndex)):\n      return False\n    else:\n      raise ValueError(f\"Encountered unknown type {other!r}\")\n\n  def _hash_index(self, df):\n    if self._levels is None:\n      levels = list(range(df.index.nlevels))\n    else:\n      levels = self._levels\n    return sum(\n        pd.util.hash_array(np.asarray(df.index.get_level_values(level)))\n        for level in levels)\n\n  def partition_fn(self, df, num_partitions):\n    hashes = self._hash_index(df)\n    for key in range(num_partitions):\n      yield key, df[hashes % num_partitions == key]\n\n  def check(self, dfs):\n    # Drop empty DataFrames\n    dfs = [df for df in dfs if len(df)]","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/partitionings.py#L87-L123","documentation":"IndexingIsSubpartitioningOf.is_subpartitioning_of compares the current partitioning against another partitioning object; if the other object is not one of the known partitioning types (DefaultIndexing/Order/Arbitrary/JoinIndex/Hashing etc.), it raises ValueError because no containment rule is defined.","triggerScenarios":"A custom Partitioning implementation is passed into Beam DataFrame internals (e.g. via partitionings or stage hints) that is not a recognized subclass; internal API misuse when extending the DataFrame API.","commonSituations":"Developers writing custom partitionings for the Beam DataFrame API and forgetting to subclass one of the built-in types or register it with the partitioning-aware stages.","solutions":["Ensure the custom partitioning subclasses one of apache_beam.dataframe.partitionings.Partitioning's known types (e.g. Arbitrary, Hashing, JoinIndex)","Implement is_subpartitioning_of on the custom class so it handles comparisons instead of falling through","Inspect repr(other) in the message to identify the unknown object and add handling for it upstream"],"exampleFix":"// before\nclass MyPartitioning:\n  ...\n// after\nfrom apache_beam.dataframe.partitionings import Hashing\nclass MyPartitioning(Hashing):\n  def is_subpartitioning_of(self, other): ...","handlingStrategy":"type-guard","validationCode":"from apache_beam.dataframe import partitionings\nif not isinstance(other, partitionings.Partitioning):\n    raise TypeError(f'Expected a partitionings.Partitioning, got {type(other)!r}')","typeGuard":"def is_known_partitioning(p) -> bool:\n    from apache_beam.dataframe import partitionings\n    return isinstance(p, partitionings.Partitioning)","tryCatchPattern":null,"preventionTips":["Always subclass a built-in Partitioning type when writing custom partitionings","Use repr() of the unknown object in the message to trace where it came from","Add isinstance checks at custom-transform boundaries"],"tags":["python","apache-beam","dataframe","partitioning","type-error"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}