code: def test_pk_cast(use_helper=False):
      # Base Case
      table = wandb.Table(
          columns=["id", "b"], data=[["1", "a"], ["2", "b"]]
      )
  
      # Validate that iterrows works as intended for no pks
      assert [id_ for id_, row in list(table.iterrows())] == [0, 1]
  
      # Cast as a PK
      if use_helper:
          table.set_pk("id")
      else:
          table.cast("id", wandb.data_types._PrimaryKeyType())
  
      assert all(
          [
              row[0]._table == table and row[0]._col_name == "id"
              for row in table.data
          ]
      )
  
      # Adding is supported
      table.add_data("3", "c")
  
      # Adding Duplicates fail
      # TODO: Enforce duplicate (not supported today)
      # with pytest.raises(TypeError):
      #     table.add_data("3", "d")
  
      # Adding None should fail
      with pytest.raises(TypeError):
          table.add_data(None, "d")
  
      # Assert that the data in this column is valid, but also properly typed
      assert [row[0] for row in table.data] == ["1", "2", "3"]
      assert all(row[0]._table == table for row in table.data)
      assert isinstance(
          table._column_types.params["type_map"]["id"],
          wandb.data_types._PrimaryKeyType,
      )
  
      # Assert that multiple PKs are not supported
      with pytest.raises(AssertionError):
          if use_helper:
              table.set_pk("b")
          else:
              table.cast("b", wandb.data_types._PrimaryKeyType())
  
      # Fails on Numerics for now
      table = wandb.Table(
          columns=["id", "b"], data=[[1, "a"], [2, "b"]]
      )
      with pytest.raises(TypeError):
          if use_helper:
              table.set_pk("id")
          else:
              table.cast("id", wandb.data_types._PrimaryKeyType())
  
      # Assert that the table was not modified
      assert all([row[0].__class__ == int for row in table.data])
      assert not isinstance(
          table._column_types.params["type_map"]["id"],
          wandb.data_types._PrimaryKeyType,
      )
  
file_path: wandb/tests/pytest_tests/unit_tests/test_tables.py
imports: import datetime
  import numpy
  import pytest
  import wandb
label_desc: Use image node_id 2 for calling a global function with example usage: test_pk_cast(use_helper) without return types