code: def upgrade():
      bind = op.get_bind()
      session = db.Session(bind=bind)
  
      for dashboard in session.query(Dashboard).all():
          if dashboard.json_metadata:
              updated = False
  
              try:
                  json_metadata = json.loads(dashboard.json_metadata)
  
                  if filters := json_metadata.get(
                      "native_filter_configuration"
                  ):
                      filter_ids = {fltr["id"] for fltr in filters}
  
                      for fltr in filters:
                          for parent_id in fltr.get(
                              "cascadeParentIds", []
                          )[:]:
                              if parent_id not in filter_ids:
                                  fltr["cascadeParentIds"].remove(
                                      parent_id
                                  )
                                  updated = True
  
                  if updated:
                      dashboard.json_metadata = json.dumps(
                          json_metadata
                      )
              except Exception:
                  logging.exception(
                      f"Unable to parse JSON metadata for dashboard {dashboard.id}"
                  )
  
      session.commit()
      session.close()
  
file_path: superset/superset/migrations/versions/2023-07-19_16-48_a23c6f8b1280_cleanup_erroneous_parent_filter_ids.py
imports: import json
  import logging
  from alembic import op
  from sqlalchemy import Column, Integer, Text
  from sqlalchemy.ext.declarative import declarative_base
  from superset import db
label_desc: Use image node_id 1 for calling a global function with example usage: upgrade() without return types