§
    Ò¬¸j]4  ã            	      óô   — d dl mZ d dlZd dlZd dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ er,d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZmZ d dlmZ d dlmZ dddddddddœd)d%„Zdddddddd&œd*d(„ZdS )+é    )ÚannotationsN)ÚTYPE_CHECKINGÚAny)Úissue_deprecation_warning)Úwrap_ldf)ÚNoPickleOption)ÚDeltaDataset)Údatetime)ÚPath)ÚLiteral©Ú
DeltaTable)Ú	DataFrameÚ	LazyFrame)ÚStorageOptionsDict)ÚCredentialProviderFunctionÚautoF)ÚversionÚcolumnsÚrechunkÚstorage_optionsÚcredential_providerÚdelta_table_optionsÚuse_pyarrowÚpyarrow_optionsÚsourceústr | Path | DeltaTabler   úint | str | datetime | Noner   úlist[str] | Noner   úbool | Noner   úStorageOptionsDict | Noner   ú3CredentialProviderFunction | Literal['auto'] | Noner   údict[str, Any] | Noner   Úboolr   Úreturnr   c          	     óà   — |�t          dd¬¦  «         nd}t          | ||||||¬¦  «        }	|�|	                     |¦  «        }	|	                     ¦   «         }
|r|
                     ¦   «         }
|
S )a‹  
    Reads into a DataFrame from a Delta lake table.

    Parameters
    ----------
    source
        DeltaTable or a Path or URI to the root of the Delta lake table.

        Note: For Local filesystem, absolute and relative paths are supported but
        for the supported object storages - GCS, Azure and S3 full URI must be provided.
    version
        Numerical version or timestamp version of the Delta lake table.

        Note: If `version` is not provided, the latest version of delta lake
        table is read.
    columns
        Columns to select. Accepts a list of column names.
    rechunk
        Make sure that all columns are contiguous in memory by
        aggregating the chunks into a single array.

        .. deprecated:: 1.43.2
            Call rechunk on the returned DataFrame.
    storage_options
        Extra options for the storage backends supported by `deltalake`.
        For cloud storages, this may include configurations for authentication etc.

        More info is available `here
        <https://delta-io.github.io/delta-rs/usage/loading-table/>`__.
    credential_provider
        Provide a function that can be called to provide cloud storage
        credentials. The function is expected to return a dictionary of
        credential keys along with an optional credential expiry time.

        .. warning::
            This functionality is considered **unstable**. It may be changed
            at any point without it being considered a breaking change.
    delta_table_options
        Additional keyword arguments while reading a Delta lake Table.
    use_pyarrow
        Flag to enable pyarrow dataset reads.
    pyarrow_options
        Keyword arguments while converting a Delta lake Table to pyarrow table.

    Returns
    -------
    DataFrame

    Examples
    --------
    Reads a Delta table from local filesystem.
    Note: Since version is not provided, the latest version of the delta table is read.

    >>> table_path = "/path/to/delta-table/"
    >>> pl.read_delta(table_path)  # doctest: +SKIP

    Reads a specific version of the Delta table from local filesystem.
    Note: This will fail if the provided version of the delta table does not exist.

    >>> pl.read_delta(table_path, version=1)  # doctest: +SKIP

    Time travel a delta table from local filesystem using a timestamp version.

    >>> pl.read_delta(
    ...     table_path, version=datetime(2020, 1, 1, tzinfo=timezone.utc)
    ... )  # doctest: +SKIP

    Reads a Delta table from AWS S3.
    See a list of supported storage options for S3 `here
    <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html#variants>`__.

    >>> table_path = "s3://bucket/path/to/delta-table/"
    >>> storage_options = {
    ...     "AWS_ACCESS_KEY_ID": "THE_AWS_ACCESS_KEY_ID",
    ...     "AWS_SECRET_ACCESS_KEY": "THE_AWS_SECRET_ACCESS_KEY",
    ... }
    >>> pl.read_delta(table_path, storage_options=storage_options)  # doctest: +SKIP

    Reads a Delta table from Google Cloud storage (GCS).
    See a list of supported storage options for GCS `here
    <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html#variants>`__.

    >>> table_path = "gs://bucket/path/to/delta-table/"
    >>> storage_options = {"SERVICE_ACCOUNT": "SERVICE_ACCOUNT_JSON_ABSOLUTE_PATH"}
    >>> pl.read_delta(table_path, storage_options=storage_options)  # doctest: +SKIP

    Reads a Delta table from Azure.

    Following type of table paths are supported,

    * az://<container>/<path>
    * adl://<container>/<path>
    * abfs://<container>/<path>

    See a list of supported storage options for Azure `here
    <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html#variants>`__.

    >>> table_path = "az://container/path/to/delta-table/"
    >>> storage_options = {
    ...     "AZURE_STORAGE_ACCOUNT_NAME": "AZURE_STORAGE_ACCOUNT_NAME",
    ...     "AZURE_STORAGE_ACCOUNT_KEY": "AZURE_STORAGE_ACCOUNT_KEY",
    ... }
    >>> pl.read_delta(table_path, storage_options=storage_options)  # doctest: +SKIP

    Reads a Delta table with additional delta specific options. In the below example,
    `without_files` option is used which loads the table without file tracking
    information.

    >>> table_path = "/path/to/delta-table/"
    >>> delta_table_options = {"without_files": True}
    >>> pl.read_delta(
    ...     table_path, delta_table_options=delta_table_options
    ... )  # doctest: +SKIP
    Nza`rechunk` parameter on read_delta() will be removed. Consider calling df.rechunk() on the result.ú1.43.2©r   F)r   r   r   r   r   r   r   )r   Ú
scan_deltaÚselectÚ_collect_eagerr   )r   r   r   r   r   r   r   r   r   ÚlfÚrets              úi/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/polars/io/delta/functions.pyÚ
read_deltar/      s¥   € ð| ÐÝ!ð*ð ð		
ñ 	
ô 	
ð 	
ð 	
ð ˆå	ØØØ'Ø/Ø/ØØ'ð
ñ 
ô 
€Bð ÐØ�YŠY�wÑÔˆà
×
Ò
Ñ
Ô
€Càð Ø�kŠk‰mŒmˆà€Jó    )r   r   r   r   r   r   r   r   c               óð  — ddl m} ddlm}	 d}
t          j                             d¦  «        �ddlm} t          | |¦  «        r| }
|
€ |	|| |d¦  «        }n|�|dk    rd	}t          |¦  «        ‚d}~|�t          d
d¬¦  «         |
�|
j        €|�i |
j        pi ¥|pi ¥}t          t          |
¦  «        |
€t          | ¦  «        nd|||||||¬¦	  «	        }t!          |                     |¦  «        ¦  «        S )aÒ  
    Lazily read from a Delta lake table.

    Parameters
    ----------
    source
        DeltaTable or a Path or URI to the root of the Delta lake table.

        Note: For Local filesystem, absolute and relative paths are supported but
        for the supported object storages - GCS, Azure and S3 full URI must be provided.
    version
        Numerical version or timestamp version of the Delta lake table.

        Note: If `version` is not provided, the latest version of delta lake
        table is read.
    storage_options
        Extra options for the storage backends supported by `deltalake`.
        For cloud storages, this may include configurations for authentication etc.

        More info is available `here
        <https://delta-io.github.io/delta-rs/usage/loading-table/>`__.
    credential_provider
        Provide a function that can be called to provide cloud storage
        credentials. The function is expected to return a dictionary of
        credential keys along with an optional credential expiry time.

        .. warning::
            This functionality is considered **unstable**. It may be changed
            at any point without it being considered a breaking change.
    delta_table_options
        Additional keyword arguments while reading a Delta lake Table.
    use_pyarrow
        Flag to enable pyarrow dataset reads.
    pyarrow_options
        Keyword arguments while converting a Delta lake Table to pyarrow table.
        Use this parameter when filtering on partitioned columns or to read
        from a 'fsspec' supported filesystem.
    rechunk
        Make sure that all columns are contiguous in memory by
        aggregating the chunks into a single array.

        .. deprecated:: 1.43.2
            Collect into a DataFrame first, then call rechunk on the returned DataFrame.

    Returns
    -------
    LazyFrame

    Examples
    --------
    Creates a scan for a Delta table from local filesystem.
    Note: Since version is not provided, the latest version of the delta table is read.

    >>> table_path = "/path/to/delta-table/"
    >>> pl.scan_delta(table_path).collect()  # doctest: +SKIP

    Creates a scan for a specific version of the Delta table from local filesystem.
    Note: This will fail if the provided version of the delta table does not exist.

    >>> pl.scan_delta(table_path, version=1).collect()  # doctest: +SKIP

    Time travel a delta table from local filesystem using a timestamp version.

    >>> pl.scan_delta(
    ...     table_path, version=datetime(2020, 1, 1, tzinfo=timezone.utc)
    ... ).collect()  # doctest: +SKIP

    Creates a scan for a Delta table from AWS S3.
    See a list of supported storage options for S3 `here
    <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html#variants>`__.

    >>> table_path = "s3://bucket/path/to/delta-table/"
    >>> storage_options = {
    ...     "AWS_REGION": "eu-central-1",
    ...     "AWS_ACCESS_KEY_ID": "THE_AWS_ACCESS_KEY_ID",
    ...     "AWS_SECRET_ACCESS_KEY": "THE_AWS_SECRET_ACCESS_KEY",
    ... }
    >>> pl.scan_delta(
    ...     table_path, storage_options=storage_options
    ... ).collect()  # doctest: +SKIP

    Creates a scan for a Delta table from Google Cloud storage (GCS).
    See a list of supported storage options for GCS `here
    <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html#variants>`__.

    >>> table_path = "gs://bucket/path/to/delta-table/"
    >>> storage_options = {"SERVICE_ACCOUNT": "SERVICE_ACCOUNT_JSON_ABSOLUTE_PATH"}
    >>> pl.scan_delta(
    ...     table_path, storage_options=storage_options
    ... ).collect()  # doctest: +SKIP

    Creates a scan for a Delta table from Azure.
    Supported options for Azure are available `here
    <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html#variants>`__.

    Following type of table paths are supported,

    * az://<container>/<path>
    * adl://<container>/<path>
    * abfs[s]://<container>/<path>

    >>> table_path = "az://container/path/to/delta-table/"
    >>> storage_options = {
    ...     "AZURE_STORAGE_ACCOUNT_NAME": "AZURE_STORAGE_ACCOUNT_NAME",
    ...     "AZURE_STORAGE_ACCOUNT_KEY": "AZURE_STORAGE_ACCOUNT_KEY",
    ... }
    >>> pl.scan_delta(
    ...     table_path, storage_options=storage_options
    ... ).collect()  # doctest: +SKIP

    Creates a scan for a Delta table with additional delta specific options.
    In the below example, `without_files` option is used which loads the table without
    file tracking information.

    >>> table_path = "/path/to/delta-table/"
    >>> delta_table_options = {"without_files": True}
    >>> pl.scan_delta(
    ...     table_path, delta_table_options=delta_table_options
    ... ).collect()  # doctest: +SKIP
    r   )ÚPyLazyFrame)Ú!_init_credential_provider_builderNÚ	deltalaker   r)   r   z?cannot use credential_provider when passing a DeltaTable objectz�`rechunk` parameter on scan_delta() will be removed. Consider first collecting the scan to a DataFrame, then calling df.rechunk() on the result.r'   r(   )	Útable_Ú
table_uri_r   r   Úcredential_provider_builderr   r   r   r   )Úpolars._plrr2   Ú,polars.io.cloud.credential_provider._builderr3   Ú	importlibÚutilÚ	find_specr4   r   Ú
isinstanceÚ
ValueErrorr   Ú_storage_optionsr	   r   Ústrr   Únew_from_dataset_object)r   r   r   r   r   r   r   r   r2   r3   Útabler   r7   ÚmsgÚdatasets                  r.   r)   r)   µ   s’  € ðF (Ð'Ð'Ð'Ð'Ð'ðð ð ð ð ð ð  $€Eå„~×Ò Ñ,Ô,Ð8Ø(Ð(Ð(Ð(Ð(Ð(å�f˜jÑ)Ô)ð 	ØˆEà€}Ø&GÐ&GØ ¨¸,ñ'
ô '
Ð#Ð#ð 
Ð	(Ð-@ÀFÒ-JÐ-JØOˆÝ˜‰oŒoÐà&*Ð#ààÐÝ!ð*ð ð		
ñ 	
ô 	
ð 	
ð ÐØÔÐ*¨oÐ.Ið
ØÔ%Ð+¨ð
àÐ$ "ð
ˆõ
 Ý˜eÑ$Ô$Ø"' -•3�v‘;”;�;°TØØ'Ø$?Ø/ØØ'Øð
ñ 
ô 
€Gõ �K×7Ò7¸Ñ@Ô@ÑAÔAÐAr0   )r   r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r$   r   r#   r%   r   )r   r   r   r   r   r!   r   r"   r   r#   r   r$   r   r#   r   r    r%   r   )Ú
__future__r   r:   Úimportlib.utilÚtypingr   r   Úpolars._utils.deprecationr   Úpolars._utils.wrapr   Úpolars.io.cloud._utilsr   Úpolars.io.delta._datasetr	   r
   Úpathlibr   r   r4   r   Úpolarsr   r   Úpolars._typingr   Úpolars.io.cloudr   r/   r)   © r0   r.   ú<module>rQ      s©  ðØ "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1àð 	;Ø!Ð!Ð!Ð!Ð!Ð!ØÐÐÐÐÐØÐÐÐÐÐà$Ð$Ð$Ð$Ð$Ð$à+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Ø1Ð1Ð1Ð1Ð1Ð1Ø:Ð:Ð:Ð:Ð:Ð:ð ,0Ø $ØØ15ØOUØ15ØØ-1ðZð Zð Zð Zð Zð Zð@ ,0Ø15ØOUØ15ØØ-1ØðxBð xBð xBð xBð xBð xBð xBð xBr0   