from __future__ import annotations from dataclasses import dataclass, asdict from typing import List, Dict, Any @dataclass(frozen=True) class CanonicalPlan: projection: List[str] predicates: List[str] estimated_cost: float def to_dict(self) -> Dict[str, Any]: return asdict(self) @staticmethod def from_dict(d: Dict[str, Any]) -> "CanonicalPlan": return CanonicalPlan( projection=list(d.get("projection", [])), predicates=list(d.get("predicates", [])), estimated_cost=float(d.get("estimated_cost", 0.0)), )