code: def add_data(
      columns: Optional[list[ColumnInfo]],
      num_rows: int,
      table_name: str,
      append: bool = True,
  ) -> None:
      """
      Generate synthetic data for testing migrations and features.
  
      If the table already exists `columns` can be `None`.
  
      :param Optional[List[ColumnInfo]] columns: list of column names and types to create
      :param int num_rows: how many rows to generate and insert
      :param str table_name: name of table, will be created if it doesn't exist
      :param bool append: if the table already exists, append data or replace?
      """
      # pylint: disable=import-outside-toplevel
      from superset.utils.database import get_example_database
  
      database = get_example_database()
      table_exists = database.has_table_by_name(table_name)
  
      with database.get_sqla_engine_with_context() as engine:
          if columns is None:
              if not table_exists:
                  raise Exception(  # pylint: disable=broad-exception-raised
                      f"The table {table_name} does not exist. To create it you need to "
                      "pass a list of column names and types."
                  )
  
              inspector = inspect(engine)
              columns = inspector.get_columns(table_name)
  
          # create table if needed
          column_objects = get_column_objects(columns)
          metadata = MetaData()
          table = Table(table_name, metadata, *column_objects)
          metadata.create_all(engine)
  
          if not append:
              engine.execute(table.delete())
  
          data = generate_data(columns, num_rows)
          engine.execute(table.insert(), data)
  
imports: import decimal
  import json
  import logging
  import os
  import random
  import string
  import sys
  from collections.abc import Iterator
  from datetime import date, datetime, time, timedelta
  from typing import Any, Callable, cast, Optional, TypedDict
  from uuid import uuid4
  import sqlalchemy.sql.sqltypes
  import sqlalchemy_utils
  from flask_appbuilder import Model
  from sqlalchemy import Column, inspect, MetaData, Table
  from sqlalchemy.dialects import postgresql
  from sqlalchemy.orm import Session
  from sqlalchemy.sql import func
  from sqlalchemy.sql.visitors import VisitableType
  from superset import db
label_desc: Use image node_id 2 for calling a global function with example usage: add_data(columns, num_rows, table_name, append) without return types