
    .i%                     8   d dl mZ d dlmZ d dlmZ d dlmZ  ed      	 dddddddddd	ed
edz  de	eef   dz  de
e   dz  dedz  dededz  dedz  de	eef   dz  defd       Z	 ddddddded	ed
edz  de	eef   dz  dedz  dede	eef   dz  ddfdZy)    )Any)import_optional_dependency)
set_module)	DataFramepandasNT)catalog_propertiescolumns
row_filtercase_sensitivesnapshot_idlimitscan_propertiestable_identifiercatalog_namer   r	   r
   r   r   r   r   returnc                   t        d      }	t        d      }
|i } |	j                  |fi |}|j                  |       }||
j                         }|d}nt	        |      }|i }|j                  ||||||      }|j                         S )a  
    Read an Apache Iceberg table into a pandas DataFrame.

    .. versionadded:: 3.0.0

    .. warning::

       read_iceberg is experimental and may change without warning.

    Parameters
    ----------
    table_identifier : str
        Table identifier.
    catalog_name : str, optional
        The name of the catalog.
    catalog_properties : dict of {str: str}, optional
        The properties that are used next to the catalog configuration.
    columns : list of str, optional
        A list of strings representing the column names to return in the output
        dataframe.
    row_filter : str, optional
        A string that describes the desired rows.
    case_sensitive : bool, default True
        If True column matching is case sensitive.
    snapshot_id : int, optional
        Snapshot ID to time travel to. By default the table will be scanned as of the
        current snapshot ID.
    limit : int, optional
        An integer representing the number of rows to return in the scan result.
        By default all matching rows will be fetched.
    scan_properties : dict of {str: obj}, optional
        Additional Table properties as a dictionary of string key value pairs to use
        for this scan.

    Returns
    -------
    DataFrame
        DataFrame based on the Iceberg table.

    See Also
    --------
    read_parquet : Read a Parquet file.

    Examples
    --------
    >>> df = pd.read_iceberg(
    ...     table_identifier="my_table",
    ...     catalog_name="my_catalog",
    ...     catalog_properties={"s3.secret-access-key": "my-secret"},
    ...     row_filter="trip_distance >= 10.0",
    ...     columns=["VendorID", "tpep_pickup_datetime"],
    ... )  # doctest: +SKIP
    pyiceberg.catalogzpyiceberg.expressions)*)r
   selected_fieldsr   r   optionsr   )r   load_catalog
load_table
AlwaysTruetuplescan	to_pandas)r   r   r   r	   r
   r   r   r   r   pyiceberg_catalogpyiceberg_expressionscatalogtabler   results                  O/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/io/iceberg.pyread_icebergr#      s    D 33FG67NO!,,,\P=OPG/0E*557
 .ZZ'%  F     F)r   locationappendsnapshot_propertiesdfr%   r&   r'   c                *   t        d      }t        d      }|i } |j                  |fi |}	|j                  j                  |       }
|	j	                  ||
j
                  |      }|i }|r|j                  |
|       y|j                  |
|       y)a  
    Write a DataFrame to an Apache Iceberg table.

    .. versionadded:: 3.0.0

    Parameters
    ----------
    table_identifier : str
        Table identifier.
    catalog_name : str, optional
        The name of the catalog.
    catalog_properties : dict of {str: str}, optional
        The properties that are used next to the catalog configuration.
    location : str, optional
        Location for the table.
    append : bool, default False
        If ``True``, append data to the table, instead of replacing the content.
    snapshot_properties : dict of {str: str}, optional
        Custom properties to be added to the snapshot summary

    See Also
    --------
    read_iceberg : Read an Apache Iceberg table.
    DataFrame.to_parquet : Write a DataFrame in Parquet format.
    pyarrowr   N)
identifierschemar%   )r'   )r   r   Tablefrom_pandascreate_table_if_not_existsr,   r&   	overwrite)r(   r   r   r   r%   r&   r'   par   r   arrow_tabler    s               r"   
to_icebergr3   f   s    F 
$I	.B23FG!,,,\P=OPG((&&r*K..#!! / E " [6IJ9LMr$   )N)typingr   pandas.compat._optionalr   pandas.util._decoratorsr   r   r   strdictlistboolintr#   r3    r$   r"   <module>r=      s   ? .  H  $W 15 $!"-1WW*W S#X-	W
 #YW d
W W tW :W #s(^d*W W Wz  $5N
 15155N5N5N *5N
 S#X-5N Dj5N 5N c3h$.5N 
5Nr$   