multi_demand_pool_di.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from __future__ import annotations
  2. from datetime import datetime
  3. from sqlalchemy import BigInteger, Float, Index, String, Text, func
  4. from sqlalchemy.orm import Mapped, mapped_column
  5. from supply_infra.db.base import Base
  6. class MultiDemandPoolDi(Base):
  7. """策略需求天级表 — 从 ODPS dwd_multi_demand_pool_di 同步。"""
  8. __tablename__ = "multi_demand_pool_di"
  9. __table_args__ = (
  10. Index("idx_biz_dt", "biz_dt"),
  11. Index("idx_strategy_demand", "strategy", "demand_id"),
  12. )
  13. id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
  14. strategy: Mapped[str] = mapped_column(String(128), nullable=False, comment="策略")
  15. demand_id: Mapped[str] = mapped_column(String(128), nullable=False, comment="需求id")
  16. demand_name: Mapped[str] = mapped_column(String(256), nullable=False, comment="需求名称")
  17. weight: Mapped[float | None] = mapped_column(Float, nullable=True, comment="权重")
  18. type: Mapped[str | None] = mapped_column(String(64), nullable=True, comment="需求类型")
  19. video_count: Mapped[int | None] = mapped_column(BigInteger, nullable=True, comment="视频数量")
  20. video_list: Mapped[str | None] = mapped_column(Text, nullable=True, comment="视频列表")
  21. extend: Mapped[str | None] = mapped_column(Text, nullable=True, comment="拓展字段")
  22. real_rov_7d: Mapped[float | None] = mapped_column(
  23. Float, nullable=True, comment="近7日ROV相对全局diff(rov_diff)"
  24. )
  25. real_vov_7d: Mapped[float | None] = mapped_column(
  26. Float, nullable=True, comment="近7日VOV相对全局diff(vov_diff)"
  27. )
  28. biz_dt: Mapped[str] = mapped_column(String(32), nullable=False, comment="业务日期")
  29. create_time: Mapped[datetime] = mapped_column(
  30. nullable=False,
  31. server_default=func.now(),
  32. comment="创建时间",
  33. )
  34. update_time: Mapped[datetime] = mapped_column(
  35. nullable=False,
  36. server_default=func.now(),
  37. onupdate=func.now(),
  38. comment="更新时间",
  39. )