That's an elegant solution; I can understand it better now. I developed my version slightly differently: instead of then set the schema for my DLT pipeline. I used the configuration variable DLT_GOLD_SCHEMA for the target database, as shown below.

targets:

  dev:
    variables:
      ENVIRONMENT: 'dev'
      DLT_GOLD_SCHEMA: "gold_${workspace.current_user.short_name}"

    mode: development
    default: true

    workspace:
      host: XXXXX

  qa:
    variables:
      ENVIRONMENT: 'qa'
      DLT_GOLD_SCHEMA: "gold"

    mode: development

    workspace:
      host: XXXXX

    run_as:
      service_principal_name: ${var.DATABRICKS_SP_DEV}

  prod:
    variables:
      DLT_GOLD_SCHEMA: "gold"
      ENVIRONMENT: 'prod'

    mode: production

    workspace:
      host: xxxxxx
      root_path: "/Databricks/Template"

    run_as:
      service_principal_name: ${var.DATABRICKS_SP_PROD}

 

resources:
  pipelines:
    dlt-data-engineering:
      name: DE_Template

      libraries:
        - glob:
            include: ../../src/data_engineering/transformations/**

      schema: "${var.DLT_GOLD_SCHEMA}"
      catalog:  "mul_${var.ENVIRONMENT}_template_streaming"