o
    i                     @  s   U d dl mZ d dlmZmZ d dlmZ er#d dlmZ d dlm	Z	 ed Z
ded< ed	 Zded
< daded< G dd dZdS )    )annotations)TYPE_CHECKINGLiteral)issue_unstable_warning)
Collection)	TypeAlias)upcastdowncastr   FloatCastOption)nanosecond-downcastconvert-timezoneDatetimeCastOptionNzScanCastOptions | None_DEFAULT_CAST_OPTIONS_ICEBERGc                   @  sH   e Zd ZdZdddddddddddZedddZedddZdS )ScanCastOptionszOptions for scanning files.ZforbidraiseFinteger_cast
float_castdatetime_castmissing_struct_fieldsextra_struct_fieldscategorical_to_string_internal_callr   Literal['upcast', 'forbid']r   ALiteral['forbid'] | FloatCastOption | Collection[FloatCastOption]r   GLiteral['forbid'] | DatetimeCastOption | Collection[DatetimeCastOption]r   Literal['insert', 'raise']r   Literal['ignore', 'raise']r   Literal['allow', 'forbid']r   boolreturnNonec                C  s4   |st d || _|| _|| _|| _|| _|| _dS )a  
        Common configuration for scanning files.

        .. warning::
                This functionality is considered **unstable**. It may be changed
                at any point without it being considered a breaking change.

        Parameters
        ----------
        integer_cast
            Configuration for casting from integer types:

            * `upcast`: Allow lossless casting to wider integer types.
            * `forbid`: Raises an error if dtypes do not match.

        float_cast
            Configuration for casting from float types:

            * `upcast`: Allow casting to higher precision float types.
            * `downcast`: Allow casting to lower precision float types.
            * `forbid`: Raises an error if dtypes do not match.

        datetime_cast
            Configuration for casting from datetime types:

            * `nanosecond-downcast`: Allow nanosecond precision datetime to be             downcasted to any lower precision. This has a similar effect to             PyArrow's `coerce_int96_timestamp_unit`.
            * `convert-timezone`: Allow casting to a different timezone.
            * `forbid`: Raises an error if dtypes do not match.

        missing_struct_fields
            Configuration for behavior when struct fields defined in the schema
            are missing from the data:

            * `insert`: Inserts the missing fields.
            * `raise`: Raises an error.

        extra_struct_fields
            Configuration for behavior when extra struct fields outside of the
            defined schema are encountered in the data:

            * `ignore`: Silently ignores.
            * `raise`: Raises an error.

        categorical_to_string
            Configuration for behavior when reading in a column whose expected
            type is string, but type in the file is categorical.

            * `allow`: Categorical is casted to string.
            * `forbid`: Raises an error.

        z'ScanCastOptions is considered unstable.N)r   r   r   r   r   r   r   )selfr   r   r   r   r   r   r    r#   Z/home/app/Keep/.python/lib/python3.10/site-packages/polars/io/scan_options/cast_options.py__init__   s   D
zScanCastOptions.__init__c                   C  s
   t ddS )NT)r   )r   r#   r#   r#   r$   _defaultd   s   
zScanCastOptions._defaultc              	   C  s*   t du rtdddgddgdddd	d
a t S )z
        Default options suitable for Iceberg / Deltalake.

        This in general has all casting options enabled. Note: do not modify the
        returned config object, it is a cached global object.
        Nr   r	   r   r   insertignoreZallowTr   )r   r   )clsr#   r#   r$   _default_icebergh   s   

z ScanCastOptions._default_icebergN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   )r    r   )	__name__
__module____qualname____doc__r%   staticmethodr&   classmethodr*   r#   r#   r#   r$   r      s    Or   )
__future__r   typingr   r   Zpolars._utils.unstabler   collections.abcr   r   r
   __annotations__r   r   r   r#   r#   r#   r$   <module>   s    