code: def test_fk_cast(use_helper=False):
      # Base Case
      table_a = wandb.Table(
          columns=["id", "col_1"], data=[["1", "a"], ["2", "b"]]
      )
      table_a.set_pk("id")
  
      table = wandb.Table(
          columns=["fk", "col_2"], data=[["1", "c"], ["2", "d"]]
      )
  
      # Cast as a FK
      if use_helper:
          table.set_fk("fk", table_a, "id")
      else:
          table.cast(
              "fk", wandb.data_types._ForeignKeyType(table_a, "id")
          )
  
      # Adding is supported
      table.add_data("3", "c")
  
      # Adding Duplicates is supported
      table.add_data("3", "d")
  
      # TODO: Implement constraint to only allow valid keys
  
      # Assert that the data in this column is valid, but also properly typed
      assert [row[0] for row in table.data] == ["1", "2", "3", "3"]
      assert all(
          [
              row[0]._table == table_a and row[0]._col_name == "id"
              for row in table.data
          ]
      )
      assert isinstance(
          table._column_types.params["type_map"]["fk"],
          wandb.data_types._ForeignKeyType,
      )
  
      # Fails on Numerics for now
      table = wandb.Table(
          columns=["fk", "col_2"], data=[[1, "c"], [2, "d"]]
      )
      with pytest.raises(TypeError):
          if use_helper:
              table.set_fk("fk", table_a, "id")
          else:
              table.cast(
                  "fk", wandb.data_types._ForeignKeyType(table_a, "id")
              )
  
      # 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"]["fk"],
          wandb.data_types._ForeignKeyType,
      )
  
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 4 for calling a global function with example usage: test_fk_cast(use_helper) without return types