File tree Expand file tree Collapse file tree
tests/core/engine_adapter/integration Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import hashlib
34import os
45import pathlib
6+ import secrets
57import sys
68import typing as t
79import time
2022from sqlmesh .core .engine_adapter import SparkEngineAdapter , TrinoEngineAdapter , AthenaEngineAdapter
2123from sqlmesh .core .engine_adapter .shared import DataObject
2224from sqlmesh .core .model .definition import SqlModel , load_sql_based_model
23- from sqlmesh .utils import random_id
25+ from sqlmesh .utils import ALPHANUMERIC , random_id
2426from sqlmesh .utils .date import to_ds
2527from sqlmesh .utils .pydantic import PydanticModel
2628from tests .utils .pandas import compare_dataframes
@@ -205,7 +207,13 @@ def __init__(
205207 self .mark = mark
206208 self .gateway = gateway
207209 self ._columns_to_types = columns_to_types
208- self .test_id = random_id (short = True )
210+ # The id is appended to schema names, so it has to keep concurrent test params apart
211+ # while staying short: temp table names built from these schemas are already close to
212+ # Postgres's 63 character identifier limit. A tag derived from the param guarantees two
213+ # params never share a schema, and the random part separates concurrent runs and retries.
214+ param_tag = hashlib .sha1 (mark .encode ()).hexdigest ()[:3 ]
215+ random_part = "" .join (secrets .choice (ALPHANUMERIC ) for _ in range (5 ))
216+ self .test_id = f"{ param_tag } { random_part } "
209217 self ._context : t .Optional [Context ] = None
210218 self .is_remote = is_remote
211219 self ._schemas : t .List [
You can’t perform that action at this time.
0 commit comments