Skip to content

Frozen dataclass StatementProperties #163

Description

Make a frozen dataclass for statement properties which holds typesafe fields, possibly type-converted at construction time from convienent types (say, for timedelta -> string representation).

Something like:

@dataclass(frozen=True, kw_only=True)
class StatementProperties:
    """Typed, validated view over a curated subset of Flink SET options.

    Unset fields (None) are omitted entirely; only explicitly set options are emitted, so this
    never fights the driver-owned overlay (catalog/database/snapshot.mode) or pins a server default.
    An `extra` dict is the escape hatch for options this class does not yet model.
    """
    snapshot_write_mode: SnapshotWriteMode | None = None
    state_ttl: timedelta | None = None
    scan_startup_mode: ScanStartupMode | None = None
    local_time_zone: str | None = None
    extra: PropertiesDict = field(default_factory=dict)

    def to_properties_dict(self) -> PropertiesDict:
        props: PropertiesDict = dict(self.extra)
        if self.snapshot_write_mode is not None:
            props[SNAPSHOT_WRITE_MODE] = self.snapshot_write_mode.value
        if self.state_ttl is not None:
            props[STATE_TTL] = _to_flink_duration(self.state_ttl)  # timedelta -> "3600 s"
        # ...
        return props

_resolve_properties() would notice if it was passed one of these, and if so, then would downgrade to PropertiesDict via .to_properties_dict() then continue to validate as currently done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions