code: def bootstrap_sqllab_data(user_id: int | None) -> dict[str, Any]:
      tabs_state: list[Any] = []
      active_tab: Any = None
      databases: dict[int, Any] = {}
      for database in DatabaseDAO.find_all():
          databases[database.id] = {
              k: v
              for k, v in database.to_json().items()
              if k in DATABASE_KEYS
          }
          databases[database.id]["backend"] = database.backend
      queries: dict[str, Any] = {}
  
      # These are unnecessary if sqllab backend persistence is disabled
      if is_feature_enabled("SQLLAB_BACKEND_PERSISTENCE"):
          # send list of tab state ids
          tabs_state = (
              db.session.query(TabState.id, TabState.label)
              .filter_by(user_id=user_id)
              .all()
          )
          tab_state_ids = [
              str(tab_state[0]) for tab_state in tabs_state
          ]
          # return first active tab, or fallback to another one if no tab is active
          active_tab = (
              db.session.query(TabState)
              .filter_by(user_id=user_id)
              .order_by(TabState.active.desc())
              .first()
          )
          # return all user queries associated with existing SQL editors
          user_queries = (
              db.session.query(Query)
              .filter_by(user_id=user_id)
              .filter(Query.sql_editor_id.in_(tab_state_ids))
              .all()
          )
          queries = {
              query.client_id: dict(query.to_dict().items())
              for query in user_queries
          }
  
      return {
          "tab_state_ids": tabs_state,
          "active_tab": active_tab.to_dict() if active_tab else None,
          "databases": databases,
          "queries": queries,
      }
  
file_path: superset/superset/sqllab/utils.py
imports: from __future__ import annotations
  from typing import Any
  import pyarrow
  from superset import db, is_feature_enabled
  from superset.common.db_query_status import QueryStatus
  from superset.daos.database import DatabaseDAO
  from superset.models.sql_lab import Query, TabState
label_desc: Use image node_id 3 for calling a global function with example usage: bootstrap_sqllab_data(user_id) and returns: dict