Skip to content

Commit e42766d

Browse files
suryaiyer95claude
andcommitted
refactor: move data-diff orchestration to altimate-core-internal
- Delete `altimate_engine/sql/data_diff.py` — all Python orchestration now lives in `altimate_core.data_diff` (altimate-core-internal repo) - Delete `tests/test_data_diff.py` — tests moved to altimate-core-internal - Update `server.py` to import from `altimate_core.data_diff` with inline `_executor` and `_resolve_dialect` callbacks - Add try/catch on import with install instructions - Expand data-diff agent prompt with Cascade/Recon/Profile details Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 80c1ff3 commit e42766d

4 files changed

Lines changed: 246 additions & 1411 deletions

File tree

packages/altimate-engine/src/altimate_engine/server.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,42 @@ def dispatch(request: JsonRpcRequest) -> JsonRpcResponse:
954954
)
955955
result = LocalTestResult(**raw)
956956
elif method == "data_diff.run":
957-
from altimate_engine.sql.data_diff import run_data_diff
957+
try:
958+
from altimate_core.data_diff import run_data_diff
959+
except ImportError:
960+
return JsonRpcResponse(
961+
result={
962+
"success": False,
963+
"error": "altimate-core not installed. Install with: pip install altimate-core",
964+
},
965+
id=request.id,
966+
)
967+
968+
_DIALECT_MAP = {
969+
"snowflake": "snowflake", "duckdb": "duckdb",
970+
"postgres": "postgres", "postgresql": "postgres",
971+
"bigquery": "bigquery", "mysql": "mysql",
972+
"clickhouse": "clickhouse", "databricks": "databricks",
973+
"redshift": "redshift",
974+
}
975+
976+
def _resolve_dialect(wh_name: str) -> str:
977+
try:
978+
conn = ConnectionRegistry.get(wh_name)
979+
return _DIALECT_MAP.get(getattr(conn, "type", "").lower(), "generic")
980+
except Exception:
981+
return "generic"
982+
983+
def _executor(sql: str, warehouse: str):
984+
result = execute_sql(SqlExecuteParams(sql=sql, warehouse=warehouse, limit=100_000))
985+
if result.columns and result.columns[0] == "error":
986+
error_msg = result.rows[0][0] if result.rows else "Unknown SQL error"
987+
raise RuntimeError(error_msg)
988+
rows = []
989+
if result.row_count > 0:
990+
for row in result.rows:
991+
rows.append([str(v) if v is not None else None for v in row])
992+
return rows
958993

959994
raw = run_data_diff(
960995
source_table=params.get("source_table", ""),
@@ -973,6 +1008,8 @@ def dispatch(request: JsonRpcRequest) -> JsonRpcResponse:
9731008
source_schema=params.get("source_schema"),
9741009
target_database=params.get("target_database"),
9751010
target_schema=params.get("target_schema"),
1011+
executor=_executor,
1012+
dialect_resolver=_resolve_dialect,
9761013
)
9771014
return JsonRpcResponse(result=raw, id=request.id)
9781015
elif method == "ping":

packages/altimate-engine/src/altimate_engine/sql/data_diff.py

Lines changed: 0 additions & 237 deletions
This file was deleted.

0 commit comments

Comments
 (0)