Skip to content

Polars Converter

PolarsConverter turns a YadsSpec into a pl.Schema so lazy or eager pipelines can validate columns before collecting data. It honors the same include/exclude filters as other converters and exposes overrides for unsupported logical types.

import yads
from yads.converters import PolarsConverter, PolarsConverterConfig
from pprint import pprint

spec = yads.from_yaml("docs/src/specs/submissions.yaml")

converter = PolarsConverter(PolarsConverterConfig(mode="coerce"))
schema = converter.convert(spec)
pprint(dict(schema))
{'completion_percent': Decimal(precision=5, scale=2),
 'submission_id': Int64,
 'submitted_at': Datetime(time_unit='ns', time_zone='UTC'),
 'time_taken_seconds': Int32}

Info

Install one of the supported versions of Polars to use this converter with uv add 'yads[polars]'

PolarsConverter

Bases: BaseConverter[Any]

Convert a yads YadsSpec into a polars.Schema.

The converter maps each yads column to a polars.Field and assembles a polars.Schema. Complex types such as arrays and structs are recursively converted.

In "raise" mode, incompatible types raise UnsupportedFeatureError. In "coerce" mode, the converter attempts to coerce to a compatible target with warnings. If a logical type is unsupported by Polars, it is mapped to the configured fallback type.

Notes
  • Polars strings are variable-length; any String.length hint is ignored in the resulting Polars schema.
  • Float(bits=16) is not supported and coerces to Float32.
  • Tensor is converted to pl.Array with multi-dimensional shape support.
  • Map, UUID, JSON, Geometry, Geography, and Variant are not supported and coerce to the fallback type.
  • Interval is not supported and coerces to the fallback type (Polars Duration only supports subsecond units).
  • TimestampLTZ loses local timezone semantics and coerces to Datetime without timezone.
Source code in src/yads/converters/polars_converter.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
class PolarsConverter(BaseConverter[Any]):
    """Convert a yads `YadsSpec` into a `polars.Schema`.

    The converter maps each yads column to a `polars.Field` and assembles a
    `polars.Schema`. Complex types such as arrays and structs are
    recursively converted.

    In "raise" mode, incompatible types raise `UnsupportedFeatureError`.
    In "coerce" mode, the converter attempts to coerce to a compatible target
    with warnings. If a logical type is unsupported by Polars, it is mapped to
    the configured fallback type.

    Notes:
        - Polars strings are variable-length; any `String.length` hint is
          ignored in the resulting Polars schema.
        - `Float(bits=16)` is not supported and coerces to Float32.
        - `Tensor` is converted to `pl.Array` with multi-dimensional shape support.
        - `Map`, `UUID`, `JSON`, `Geometry`, `Geography`, and `Variant`
          are not supported and coerce to the fallback type.
        - `Interval` is not supported and coerces to the fallback type (Polars
          Duration only supports subsecond units).
        - `TimestampLTZ` loses local timezone semantics and coerces to Datetime
          without timezone.
    """

    def __init__(self, config: PolarsConverterConfig | None = None) -> None:
        """Initialize the PolarsConverter.

        Args:
            config: Configuration object. If None, uses default PolarsConverterConfig.
        """
        self.config: PolarsConverterConfig = config or PolarsConverterConfig()
        super().__init__(self.config)

    @requires_dependency("polars", min_version="1.0.0", import_name="polars")
    def convert(
        self,
        spec: yspec.YadsSpec,
        *,
        mode: Literal["raise", "coerce"] | None = None,
    ) -> pl.Schema:
        """Convert a yads `YadsSpec` into a `polars.Schema`.

        Args:
            spec: The yads spec as a `YadsSpec` object.
            mode: Optional conversion mode override for this call. When not
                provided, the converter's configured mode is used. If provided:
                - "raise": Raise on any unsupported features.
                - "coerce": Apply adjustments to produce a valid schema and emit warnings.

        Returns:
            A `polars.Schema` with fields mapped from the spec columns.
        """
        import polars as pl  # type: ignore[import-untyped]

        fields: dict[str, pl.DataType] = {}
        with self.conversion_context(mode=mode):
            self._validate_column_filters(spec)
            for col in self._filter_columns(spec):
                with self.conversion_context(field=col.name):
                    field_result = self._convert_field_with_overrides(col)
                    fields[field_result.name] = field_result.dtype
        return pl.Schema(fields)

    # %% ---- Type conversion ---------------------------------------------------------
    @singledispatchmethod
    def _convert_type(self, yads_type: ytypes.YadsType) -> Any:
        # Fallback for currently unsupported:
        # - Geometry
        # - Geography
        # - Variant
        # - Interval
        # - JSON
        # - UUID
        return self.raise_or_coerce(yads_type)

    @_convert_type.register(ytypes.String)
    def _(self, yads_type: ytypes.String) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        # Polars strings are variable-length. Length hint is ignored.
        if yads_type.length is not None:
            self.raise_or_coerce(
                coerce_type=pl.String,
                error_msg=(
                    f"{yads_type} cannot be represented in Polars; "
                    f"length constraint will be lost for '{self._field_context}'."
                ),
            )
        return pl.String

    @_convert_type.register(ytypes.Integer)
    def _(self, yads_type: ytypes.Integer) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        bits = yads_type.bits or 32
        signed_map = {
            8: pl.Int8,
            16: pl.Int16,
            32: pl.Int32,
            64: pl.Int64,
        }
        unsigned_map = {
            8: pl.UInt8,
            16: pl.UInt16,
            32: pl.UInt32,
            64: pl.UInt64,
        }
        mapping = signed_map if yads_type.signed else unsigned_map
        try:
            return mapping[bits]
        except KeyError as e:
            raise UnsupportedFeatureError(
                f"Unsupported Integer bits: {bits}. Expected 8/16/32/64"
                f" for '{self._field_context}'."
            ) from e

    @_convert_type.register(ytypes.Float)
    def _(self, yads_type: ytypes.Float) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        bits = yads_type.bits or 32
        mapping = {32: pl.Float32, 64: pl.Float64}

        if bits == 16:
            return self.raise_or_coerce(yads_type, coerce_type=pl.Float32)

        try:
            return mapping[bits]
        except KeyError as e:
            raise UnsupportedFeatureError(
                f"Unsupported Float bits: {bits}. Expected 32/64"
                f" for '{self._field_context}'."
            ) from e

    @_convert_type.register(ytypes.Decimal)
    def _(self, yads_type: ytypes.Decimal) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        precision = yads_type.precision
        scale = yads_type.scale if yads_type.scale is not None else 0

        return pl.Decimal(precision=precision, scale=scale)

    @_convert_type.register(ytypes.Boolean)
    def _(self, yads_type: ytypes.Boolean) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        return pl.Boolean

    @_convert_type.register(ytypes.Binary)
    def _(self, yads_type: ytypes.Binary) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        # Polars binary is variable-length. Length hint is ignored.
        if yads_type.length is not None:
            self.raise_or_coerce(
                coerce_type=pl.Binary,
                error_msg=(
                    f"{yads_type} cannot be represented in Polars; "
                    f"length constraint will be lost for '{self._field_context}'."
                ),
            )
        return pl.Binary

    @_convert_type.register(ytypes.Date)
    def _(self, yads_type: ytypes.Date) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        # Polars has a single Date type. Ignore bits parameter.
        if yads_type.bits is not None:
            self.raise_or_coerce(
                coerce_type=pl.Date,
                error_msg=(
                    f"{yads_type} cannot be represented in Polars; "
                    f"bits constraint will be lost for '{self._field_context}'."
                ),
            )
        return pl.Date

    @_convert_type.register(ytypes.Time)
    def _(self, yads_type: ytypes.Time) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        # Polars Time indicates nanoseconds since midnight, only supports NS unit
        time_unit = self._to_pl_time_unit(yads_type.unit)

        if time_unit != "ns":
            return self.raise_or_coerce(
                error_msg=(
                    f"Polars Time only supports nanosecond precision (unit='ns')"
                    f" for '{self._field_context}'."
                ),
            )

        return pl.Time

    @_convert_type.register(ytypes.Timestamp)
    def _(self, yads_type: ytypes.Timestamp) -> Any:
        return self._build_datetime(yads_type.unit, time_zone=None)

    @_convert_type.register(ytypes.TimestampTZ)
    def _(self, yads_type: ytypes.TimestampTZ) -> Any:
        return self._build_datetime(yads_type.unit, time_zone=yads_type.tz)

    @_convert_type.register(ytypes.TimestampLTZ)
    def _(self, yads_type: ytypes.TimestampLTZ) -> Any:
        # Polars doesn't have explicit LTZ semantics, use None for timezone
        # This loses local timezone semantics
        return self.raise_or_coerce(
            coerce_type=self._build_datetime(yads_type.unit, time_zone=None),
            error_msg=(
                f"{yads_type} cannot be represented in Polars; "
                f"local timezone semantics will be lost for '{self._field_context}'."
            ),
        )

    @_convert_type.register(ytypes.TimestampNTZ)
    def _(self, yads_type: ytypes.TimestampNTZ) -> Any:
        return self._build_datetime(yads_type.unit, time_zone=None)

    @_convert_type.register(ytypes.Duration)
    def _(self, yads_type: ytypes.Duration) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        time_unit = self._to_pl_time_unit(yads_type.unit)

        # Polars Duration only supports ms, us, ns
        if time_unit == "s":
            return self.raise_or_coerce(
                error_msg=(
                    f"Polars Duration does not support 's' (second) time unit"
                    f" for '{self._field_context}'."
                ),
            )

        # Cast to Any to avoid type checker issues with Polars types
        return pl.Duration(time_unit=time_unit)  # type: ignore[call-arg,arg-type]

    @_convert_type.register(ytypes.Array)
    def _(self, yads_type: ytypes.Array) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        value_type = self._convert_type(yads_type.element)
        if yads_type.size is not None:
            # Fixed-size array - use 'shape' parameter (width is deprecated)
            return pl.Array(value_type, shape=yads_type.size)
        # Variable-length list
        return pl.List(value_type)

    @_convert_type.register(ytypes.Tensor)
    def _(self, yads_type: ytypes.Tensor) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        element_type = self._convert_type(yads_type.element)
        return pl.Array(element_type, shape=yads_type.shape)

    @_convert_type.register(ytypes.Struct)
    def _(self, yads_type: ytypes.Struct) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        fields = []
        for yads_field in yads_type.fields:
            with self.conversion_context(field=yads_field.name):
                field_type = self._convert_type(yads_field.type)
                fields.append(pl.Field(yads_field.name, field_type))
        return pl.Struct(fields)

    @_convert_type.register(ytypes.Map)
    def _(self, yads_type: ytypes.Map) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        # Polars doesn't have a native Map type
        # Coerce to Struct with key/value fields to preserve structure
        key_type = self._convert_type(yads_type.key)
        value_type = self._convert_type(yads_type.value)
        struct_type = pl.Struct(
            [pl.Field("key", key_type), pl.Field("value", value_type)]
        )

        return self.raise_or_coerce(yads_type, coerce_type=struct_type)

    @_convert_type.register(ytypes.Void)
    def _(self, yads_type: ytypes.Void) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        return pl.Null

    def _convert_field(self, field: yspec.Field) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        pl_type = self._convert_type(field.type)
        return pl.Field(field.name, pl_type)

    def _convert_field_default(self, field: yspec.Field) -> Any:
        return self._convert_field(field)

    # %% ---- Helpers -----------------------------------------------------------------
    @staticmethod
    def _to_pl_time_unit(unit: ytypes.TimeUnit | None) -> str:
        if unit is None:
            return "ns"
        return unit.value

    def _build_datetime(self, unit: ytypes.TimeUnit | None, time_zone: str | None) -> Any:
        import polars as pl  # type: ignore[import-untyped]

        time_unit = self._to_pl_time_unit(unit)

        # Polars Datetime only supports ms, us, ns (not s)
        if time_unit == "s":
            return self.raise_or_coerce(
                error_msg=(
                    f"Polars Datetime does not support 's' (second) time unit"
                    f" for '{self._field_context}'."
                ),
            )

        # Cast to Any to avoid type checker issues with Polars types
        return pl.Datetime(time_unit=time_unit, time_zone=time_zone)  # type: ignore[call-arg,arg-type]

__init__(config=None)

Initialize the PolarsConverter.

Parameters:

Name Type Description Default
config PolarsConverterConfig | None

Configuration object. If None, uses default PolarsConverterConfig.

None
Source code in src/yads/converters/polars_converter.py
110
111
112
113
114
115
116
117
def __init__(self, config: PolarsConverterConfig | None = None) -> None:
    """Initialize the PolarsConverter.

    Args:
        config: Configuration object. If None, uses default PolarsConverterConfig.
    """
    self.config: PolarsConverterConfig = config or PolarsConverterConfig()
    super().__init__(self.config)

conversion_context(*, mode=None, field=None)

Temporarily set conversion mode and field context.

This context manager centralizes handling of converter state used for warnings and coercions, ensuring that values are restored afterwards.

Parameters:

Name Type Description Default
mode Literal['raise', 'coerce'] | None

Optional override for the current conversion mode.

None
field str | None

Optional field name for contextual warnings.

None
Source code in src/yads/converters/base.py
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
@contextmanager
def conversion_context(
    self,
    *,
    mode: Literal["raise", "coerce"] | None = None,
    field: str | None = None,
) -> Generator[None, None, None]:
    """Temporarily set conversion mode and field context.

    This context manager centralizes handling of converter state used for
    warnings and coercions, ensuring that values are restored afterwards.

    Args:
        mode: Optional override for the current conversion mode.
        field: Optional field name for contextual warnings.
    """
    # Snapshot current state
    previous_config = self.config
    previous_field = self._current_field_name

    try:
        if mode is not None:
            if mode not in ("raise", "coerce"):
                raise ConverterConfigError("mode must be one of 'raise' or 'coerce'.")
            self.config = replace(self.config, mode=mode)
        if field is not None:
            self._current_field_name = field
        yield
    finally:
        # Restore prior state
        self.config = previous_config
        self._current_field_name = previous_field

convert(spec, *, mode=None)

Convert a yads YadsSpec into a polars.Schema.

Parameters:

Name Type Description Default
spec YadsSpec

The yads spec as a YadsSpec object.

required
mode Literal['raise', 'coerce'] | None

Optional conversion mode override for this call. When not provided, the converter's configured mode is used. If provided: - "raise": Raise on any unsupported features. - "coerce": Apply adjustments to produce a valid schema and emit warnings.

None

Returns:

Type Description
Schema

A polars.Schema with fields mapped from the spec columns.

Source code in src/yads/converters/polars_converter.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@requires_dependency("polars", min_version="1.0.0", import_name="polars")
def convert(
    self,
    spec: yspec.YadsSpec,
    *,
    mode: Literal["raise", "coerce"] | None = None,
) -> pl.Schema:
    """Convert a yads `YadsSpec` into a `polars.Schema`.

    Args:
        spec: The yads spec as a `YadsSpec` object.
        mode: Optional conversion mode override for this call. When not
            provided, the converter's configured mode is used. If provided:
            - "raise": Raise on any unsupported features.
            - "coerce": Apply adjustments to produce a valid schema and emit warnings.

    Returns:
        A `polars.Schema` with fields mapped from the spec columns.
    """
    import polars as pl  # type: ignore[import-untyped]

    fields: dict[str, pl.DataType] = {}
    with self.conversion_context(mode=mode):
        self._validate_column_filters(spec)
        for col in self._filter_columns(spec):
            with self.conversion_context(field=col.name):
                field_result = self._convert_field_with_overrides(col)
                fields[field_result.name] = field_result.dtype
    return pl.Schema(fields)

raise_or_coerce(yads_type=None, *, coerce_type=None, error_msg=None)

Handle raise or coerce mode for unsupported type features.

This public method provides a consistent way to handle unsupported types based on the converter's mode. It can be used within converters and in custom column override functions.

The method uses the template method pattern with several hook methods that subclasses can override to customize behavior.

Hook that subclasses can override
  • _format_type_for_display: Customize how types appear in warnings
  • _emit_warning: Customize warning emission
  • _get_fallback_type: Customize fallback type resolution
  • _generate_error_message: Customize error message generation

Parameters:

Name Type Description Default
yads_type Any | None

The yads type that is not supported. Can be None if error_msg is explicitly provided.

None
coerce_type Any | None

The type to coerce to in coerce mode. If None, uses the converter's configured fallback type.

None
error_msg str | None

Custom error message. If None, uses a default message based on the converter class name and yads_type. When providing a custom error_msg, yads_type can be None.

None

Returns:

Type Description
T

The coerced type in coerce mode.

Raises:

Type Description
UnsupportedFeatureError

In raise mode when the feature is not supported, or in coerce mode when fallback_type is None.

ValueError

If both yads_type and error_msg are None.

Source code in src/yads/converters/base.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
def raise_or_coerce(
    self,
    yads_type: Any | None = None,
    *,
    coerce_type: Any | None = None,
    error_msg: str | None = None,
) -> T:
    """Handle raise or coerce mode for unsupported type features.

    This public method provides a consistent way to handle unsupported types
    based on the converter's mode. It can be used within converters and in
    custom column override functions.

    The method uses the template method pattern with several hook methods
    that subclasses can override to customize behavior.

    Hook that subclasses can override:
        - `_format_type_for_display`: Customize how types appear in warnings
        - `_emit_warning`: Customize warning emission
        - `_get_fallback_type`: Customize fallback type resolution
        - `_generate_error_message`: Customize error message generation

    Args:
        yads_type: The yads type that is not supported. Can be None if
            error_msg is explicitly provided.
        coerce_type: The type to coerce to in coerce mode. If None, uses
            the converter's configured fallback type.
        error_msg: Custom error message. If None, uses a default message
            based on the converter class name and yads_type. When providing
            a custom error_msg, yads_type can be None.

    Returns:
        The coerced type in coerce mode.

    Raises:
        UnsupportedFeatureError: In raise mode when the feature is not supported,
            or in coerce mode when fallback_type is None.
        ValueError: If both yads_type and error_msg are None.
    """
    # Resolve error message once
    if error_msg is None:
        if yads_type is None:
            raise ValueError(
                "Either yads_type or error_msg must be provided to raise_or_coerce"
            )
        error_msg = self._generate_error_message(yads_type)

    # Resolve coerce_type (fallback to config if not provided)
    if coerce_type is None:
        try:
            coerce_type = self._get_fallback_type()
        except ValueError:
            # fallback_type is None - must raise even in coerce mode
            if self.config.mode == "coerce":
                error_msg = f"{error_msg} Specify a fallback_type to enable coercion of unsupported types."
            raise UnsupportedFeatureError(error_msg)

    # Handle based on mode
    if self.config.mode == "coerce":
        display_type = self._format_type_for_display(coerce_type)
        warning_msg = f"{error_msg} The data type will be coerced to {display_type}."
        self._emit_warning(warning_msg)
        return coerce_type
    else:
        raise UnsupportedFeatureError(error_msg)

PolarsConverterConfig dataclass

Bases: BaseConverterConfig[Any]

Configuration for PolarsConverter.

Parameters:

Name Type Description Default
mode Literal['raise', 'coerce']

Conversion mode. One of "raise" or "coerce". Inherited from BaseConverterConfig. Defaults to "coerce".

'coerce'
ignore_columns frozenset[str]

Column names to exclude from conversion. Inherited from BaseConverterConfig. Defaults to empty.

_empty_frozenset_str()
include_columns frozenset[str] | None

If provided, only these columns are included. Inherited from BaseConverterConfig. Defaults to None.

None
column_overrides Mapping[str, Callable[[Field, Any], Any]]

Mapping of column name to a callable that returns a custom Polars field conversion. Inherited from BaseConverterConfig. Defaults to empty mapping.

(lambda: MappingProxyType({}))()
fallback_type Any | None

Polars data type to use for unsupported types in coerce mode. Must be one of: pl.String, pl.Binary, or None. Defaults to None.

None
Source code in src/yads/converters/polars_converter.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@dataclass(frozen=True)
class PolarsConverterConfig(BaseConverterConfig[Any]):
    """Configuration for PolarsConverter.

    Args:
        mode: Conversion mode. One of "raise" or "coerce". Inherited from
            BaseConverterConfig. Defaults to "coerce".
        ignore_columns: Column names to exclude from conversion. Inherited from
            BaseConverterConfig. Defaults to empty.
        include_columns: If provided, only these columns are included. Inherited
            from BaseConverterConfig. Defaults to None.
        column_overrides: Mapping of column name to a callable that returns a
            custom Polars field conversion. Inherited from BaseConverterConfig.
            Defaults to empty mapping.
        fallback_type: Polars data type to use for unsupported types in coerce mode.
            Must be one of: pl.String, pl.Binary, or None.
            Defaults to None.
    """

    fallback_type: Any | None = None
    column_overrides: Mapping[str, Callable[[yspec.Field, Any], Any]] = field(
        default_factory=lambda: MappingProxyType({})
    )

    def __post_init__(self) -> None:
        """Validate configuration parameters."""
        super().__post_init__()

        # Validate fallback_type if provided
        if self.fallback_type is not None:
            import polars as pl  # type: ignore[import-untyped]

            valid_fallback_types = {pl.String, pl.Binary}
            if self.fallback_type not in valid_fallback_types:
                raise UnsupportedFeatureError(
                    f"fallback_type must be one of: pl.String, pl.Binary, or None. "
                    f"Got: {self.fallback_type}"
                )

__post_init__()

Validate configuration parameters.

Source code in src/yads/converters/polars_converter.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
def __post_init__(self) -> None:
    """Validate configuration parameters."""
    super().__post_init__()

    # Validate fallback_type if provided
    if self.fallback_type is not None:
        import polars as pl  # type: ignore[import-untyped]

        valid_fallback_types = {pl.String, pl.Binary}
        if self.fallback_type not in valid_fallback_types:
            raise UnsupportedFeatureError(
                f"fallback_type must be one of: pl.String, pl.Binary, or None. "
                f"Got: {self.fallback_type}"
            )