code: def add_partitioning_values(
      table: pa.Table,
      fragment: pa.dataset.Fragment,
      columns: Optional[List[str]],
  ) -> pa.Table:
      """
      When loading a single fragment, pyarrow does not add the partitioning columns,
      so we need to do it manually.
      """
      for key, val in get_partition_keys(
          fragment.partition_expression
      ).items():
          if columns is None or key in columns:
              values = pa.DictionaryArray.from_arrays(
                  np.zeros(len(table), dtype=np.int32), [val]
              )
              table = table.append_column(key, values)
      return table
  
imports: from contextlib import contextmanager
  from typing import Dict, Generator, List, Optional, Union
  import numpy
  import pandas
  import pyarrow
  import pyarrow.parquet
  import torch
  from numpy.typing import NDArray
  from pyarrow.dataset import get_partition_keys
  from fairseq2.data import CString
  from fairseq2.data.data_pipeline import DataPipeline, DataPipelineBuilder, read_sequence
label_desc: Use image node_id 8 for calling a global function with example usage: add_partitioning_values(table, fragment, columns) and returns: table