code: def _add_table_metrics(datasource: SqlaTable) -> None:
      # By accessing the attribute first, we make sure `datasource.columns` and
      # `datasource.metrics` are already loaded. Otherwise accessing them later
      # may trigger an unnecessary and unexpected `after_update` event.
      columns, metrics = datasource.columns, datasource.metrics
  
      if not any(
          col.column_name == "num_california" for col in columns
      ):
          col_state = str(column("state").compile(db.engine))
          col_num = str(column("num").compile(db.engine))
          columns.append(
              TableColumn(
                  column_name="num_california",
                  expression=f"CASE WHEN {col_state} = 'CA' THEN {col_num} ELSE 0 END",
              )
          )
  
      if not any(col.metric_name == "sum__num" for col in metrics):
          col = str(column("num").compile(db.engine))
          metrics.append(
              SqlMetric(
                  metric_name="sum__num", expression=f"SUM({col})"
              )
          )
  
      for col in columns:
          if col.column_name == "ds":  # type: ignore
              col.is_dttm = True  # type: ignore
              break
  
      datasource.columns = columns
      datasource.metrics = metrics
  
imports: import json
  import textwrap
  from typing import Union
  import pandas
  from sqlalchemy import DateTime, inspect, String
  from sqlalchemy.sql import column
  from superset import app, db
  from superset.connectors.sqla.models import SqlaTable, SqlMetric, TableColumn
  from superset.models.core import Database
  from superset.models.dashboard import Dashboard
  from superset.models.slice import Slice
  from superset.utils.core import DatasourceType
  from ..utils.database import get_example_database
  from .helpers import get_example_url, get_slice_json, get_table_connector_registry, merge_slice, misc_dash_slices, update_slice_ids
label_desc: Use image node_id 5 for calling a global function with example usage: _add_table_metrics(datasource) without return types