46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
|
|
"""数据规格和执行计划定义。
|
|||
|
|
|
|||
|
|
定义因子计算所需的数据规格和执行计划结构。
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
from dataclasses import dataclass, field
|
|||
|
|
from typing import Any, Dict, List, Optional, Set, Union
|
|||
|
|
|
|||
|
|
import polars as pl
|
|||
|
|
|
|||
|
|
|
|||
|
|
@dataclass
|
|||
|
|
class DataSpec:
|
|||
|
|
"""数据规格定义。
|
|||
|
|
|
|||
|
|
描述因子计算所需的数据表和字段。
|
|||
|
|
|
|||
|
|
Attributes:
|
|||
|
|
table: 数据表名称
|
|||
|
|
columns: 需要的字段列表
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
table: str
|
|||
|
|
columns: List[str]
|
|||
|
|
|
|||
|
|
|
|||
|
|
@dataclass
|
|||
|
|
class ExecutionPlan:
|
|||
|
|
"""执行计划。
|
|||
|
|
|
|||
|
|
包含完整的执行所需信息:数据源、转换逻辑、输出格式。
|
|||
|
|
|
|||
|
|
Attributes:
|
|||
|
|
data_specs: 数据规格列表
|
|||
|
|
polars_expr: Polars 表达式
|
|||
|
|
dependencies: 依赖的原始字段
|
|||
|
|
output_name: 输出因子名称
|
|||
|
|
factor_dependencies: 依赖的其他因子名称(用于分步执行)
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
data_specs: List[DataSpec]
|
|||
|
|
polars_expr: pl.Expr
|
|||
|
|
dependencies: Set[str]
|
|||
|
|
output_name: str
|
|||
|
|
factor_dependencies: Set[str] = field(default_factory=set)
|