# This file was auto-generated by the framework. You can add data models or change the existing ones

from moose_lib import Key, OlapTable, OlapConfig, StringToEnumMixin, ClickHouseEngines
from moose_lib.blocks import MergeTreeEngine
from datetime import datetime
from typing import Optional, Annotated, Any
from pydantic import BaseModel, BeforeValidator
from enum import IntEnum, auto


class Baz(StringToEnumMixin, IntEnum):
    QUX = auto()
    QUUX = auto()


class FooModel(BaseModel):
    primary_key: Key[str]
    timestamp: float
    baz: Baz
    optional_text: Optional[str] = None


class BarModel(BaseModel):
    primary_key: Key[str]
    utc_timestamp: datetime
    baz: Baz
    has_text: bool
    text_length: int

class BarAggregated(BaseModel):
    day_of_month: int
    total_rows: int
    rows_with_text: int
    total_text_length: int
    max_text_length: int

FooTable = OlapTable[FooModel]("Foo", OlapConfig(
    engine=MergeTreeEngine()
))

BarTable = OlapTable[BarModel]("Bar", OlapConfig(
    engine=MergeTreeEngine()
))

BarAggregatedTable = OlapTable[BarAggregated]("BarAggregated", OlapConfig(
    engine=MergeTreeEngine(),
    order_by_fields=["day_of_month"]  
))
