code: def __configure_test_env_from_url(
      url: str, password: str, schema: str
  ) -> sqlalchemy.engine.URL:
      """Populates default env var mapping from a sqlalchemy URL string.
  
      This is used to configure the test environment from the original MF_SQL_ENGINE_URL environment variable in
      a manner compatible with the dbt profile configurations laid out for most supported engines. We return
      the parsed URL object so that individual engine configurations can override the environment variables
      as needed to match their dbt profile configuration.
      """
      parsed_url = sqlalchemy.engine.make_url(url)
  
      if parsed_url.drivername != "duckdb":
          assert (
              parsed_url.host
          ), "Engine host is not set in engine connection URL!"
          os.environ[DBT_ENV_SECRET_HOST] = parsed_url.host
  
      if parsed_url.username:
          os.environ[DBT_ENV_SECRET_USER] = parsed_url.username
  
      if parsed_url.database:
          os.environ[DBT_ENV_SECRET_DATABASE] = parsed_url.database
  
      if parsed_url.port:
          os.environ[DBT_PROFILE_PORT] = str(parsed_url.port)
  
      os.environ[DBT_ENV_SECRET_PASSWORD] = password
      os.environ[DBT_ENV_SECRET_SCHEMA] = schema
  
      return parsed_url
  
imports: from __future__ import annotations
  import json
  import logging
  import os
  from typing import Generator
  import pytest
  import sqlalchemy
  from dbt.adapters.factory import get_adapter_by_type
  from dbt.cli.main import dbtRunner
  from metricflow.protocols.sql_client import SqlClient
  from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState, dbt_project_dir, dialect_from_url
  from metricflow.test.fixtures.sql_clients.adapter_backed_ddl_client import AdapterBackedDDLSqlClient
  from metricflow.test.fixtures.sql_clients.common_client import SqlDialect
  from metricflow.test.fixtures.sql_clients.ddl_sql_client import SqlClientWithDDLMethods
label_desc: Use image node_id 1 for calling a global function with example usage: __configure_test_env_from_url(url, password, schema) and returns: parsed_url