Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tests/core/engine_adapter/integration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

import hashlib
import os
import pathlib
import secrets
import sys
import typing as t
import time
Expand All @@ -20,7 +22,7 @@
from sqlmesh.core.engine_adapter import SparkEngineAdapter, TrinoEngineAdapter, AthenaEngineAdapter
from sqlmesh.core.engine_adapter.shared import DataObject
from sqlmesh.core.model.definition import SqlModel, load_sql_based_model
from sqlmesh.utils import random_id
from sqlmesh.utils import ALPHANUMERIC, random_id
from sqlmesh.utils.date import to_ds
from sqlmesh.utils.pydantic import PydanticModel
from tests.utils.pandas import compare_dataframes
Expand Down Expand Up @@ -205,7 +207,13 @@ def __init__(
self.mark = mark
self.gateway = gateway
self._columns_to_types = columns_to_types
self.test_id = random_id(short=True)
# The id is appended to schema names, so it has to keep concurrent test params apart
# while staying short: temp table names built from these schemas are already close to
# Postgres's 63 character identifier limit. A tag derived from the param guarantees two
# params never share a schema, and the random part separates concurrent runs and retries.
param_tag = hashlib.sha1(mark.encode()).hexdigest()[:3]
random_part = "".join(secrets.choice(ALPHANUMERIC) for _ in range(5))
self.test_id = f"{param_tag}{random_part}"
self._context: t.Optional[Context] = None
self.is_remote = is_remote
self._schemas: t.List[
Expand Down
Loading