
    Pi                     "   d Z ddlZddlZddlZddlZddlZddlmZ	 ddl
mZ ej        j        Z ej        d          Z ej        d          Z ej        d          Z ej        dg d          Zej        d	             Z G d
 d          ZdS )z
Tests for the Apache Iceberg format.

Tests in this file use a simple Iceberg catalog based on SQLite, with the same
data used for Parquet tests (``pandas/tests/io/data/parquet/simple.parquet``).
    N)read_iceberg	pyicebergzpyiceberg.catalogzpyarrow.parquetCatalognameuri	warehousec           	   #      K   d| d}d| }t          | d          r| j        nd }t                              |pdd||          }|                    d           t
                              t          j        t                    j
        d	z  d
z  dz            }|                    d|j                  }|                    |           |t          j                                        dz  }t          |dd          5 }	|	                    d| d| d|            d d d            n# 1 swxY w Y   t#          j        t                     t'          |pd||          V  ||                                 d S d S )Nz
sqlite:///z/catalog.sqlitezfile://paramdefaultsql)typer   r	   nsdataparquetzsimple.parquetns.my_table)schemaz.pyiceberg.yamlwzutf-8)encodingzcatalog:
  z:
    type: sql
    uri: z
    warehouse: r   )hasattrr   pyiceberg_catalogload_catalogcreate_namespacepq
read_tablepathlibPath__file__parentcreate_tabler   appendhomeopenwrite	importlibreloadr   unlink)
requesttmp_pathr   r	   catalog_namecatalogdftableconfig_pathfs
             p/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/tests/io/test_iceberg.pyr+   r+      s      1x
0
0
0C$($$I$+GW$=$=G7==4L,,!		 -  G T"""	X%.:=MM
 
B   ry AAE	LLl'')),==+sW555 	GG   	 
     	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	*+++
|0ycY
O
O
OOOO  s   D,,D03D0c                       e Zd Zd Zej                            dddgd          d             Zd Zd	 Z	d
 Z
d Zej                            dddgd          d             Zd Zd ZdS )TestIcebergc                     t          j        g dg dd          }t          dd|j        i          }t	          j        ||           d S )N         foor9   r9   ABr   r   catalog_propertiespd	DataFramer   r   tmassert_frame_equalselfr+   expectedresults       r0   	test_readzTestIceberg.test_readD   sk    <YY*** 
 
  %w{3
 
 
 	fh/////    r+   r   pandas_testsT)indirectc                     t          j        g dg dd          }t          d|j                  }t	          j        ||           d S )Nr4   r8   r:   r   r*   )r@   rA   r   r   rB   rC   rD   s       r0   test_read_by_catalog_namez%TestIceberg.test_read_by_catalog_nameQ   sf    <YY*** 
 
  
 
 
 	fh/////rI   c                     t          j        ddgddgd          }t          dd|j        id          }t	          j        ||           d S )	Nr6   r7   r9   r:   r   r   zA > 1)r>   
row_filterr?   rD   s       r0   test_read_with_row_filterz%TestIceberg.test_read_with_row_filter_   sl    <VU^ 
 
  %w{3
 
 

 	fh/////rI   c                 4   t          j        dg di          }t          dd|j        idgd          }t	          j        ||           t          j        t          d	          5  t          dd|j        idgd
           d d d            d S # 1 swxY w Y   d S )Nr;   r4   r   r   aF)r>   columnscase_sensitivez^Could not find column)matchT)	r@   rA   r   r   rB   rC   pytestraises
ValueErrorrD   s       r0   test_read_with_case_sensitivez)TestIceberg.test_read_with_case_sensitivem   s   <YYY
 

  %w{3E 	
 
 
 	fh///]:-EFFF 	 	$)7;#7#	   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   $BBBc                     t          j        ddgddgd          }t          dd|j        id          }t	          j        ||           d S )Nr5   r6   r9   r:   r   r   )r>   limitr?   rD   s       r0   test_read_with_limitz TestIceberg.test_read_with_limit   sl    <VU^ 
 
  %w{3
 
 

 	fh/////rI   c                     t          j        g dg dd          }|                    dd|j        i|j                   t          dd|j        i          }t          j        ||           d S )Nr4   r8   r:   ns.new_tabler   )r>   locationr=   r@   rA   
to_icebergr   r	   r   rB   rC   rE   r+   r,   rG   s       r0   
test_writezTestIceberg.test_write   s    \YY*** 
 
 	 %w{3& 	 	
 	
 	

  %w{3
 
 
 	fb)))))rI   c                     t          j        g dg dd          }|                    d|j                   t	          d|j                  }t          j        ||           d S )Nr4   r8   r:   r_   rM   )r@   rA   rb   r   r   rB   rC   rc   s       r0   test_write_by_catalog_namez&TestIceberg.test_write_by_catalog_name   s    \YY*** 
 
 	  	 	
 	
 	
  
 
 
 	fb)))))rI   c                 @   t          dd|j        i          }t          j        g dg dd          }t          j        ||gd          }|                    dd|j        i|j        d	           t          dd|j        i          }t          j        ||           d S )
Nr   r   r=   r4   r8   r:   T)ignore_indexr>   r`   r!   )	r   r   r@   rA   concatrb   r	   rB   rC   )rE   r+   originalnewrF   rG   s         r0   *test_write_existing_table_with_append_truez6TestIceberg.test_write_existing_table_with_append_true   s     %w{3
 
 
 lYY*** 
 
 9h_4@@@ %w{3&	 	 	
 	
 	
  %w{3
 
 
 	fh/////rI   c                     t          j        g dg dd          }|                    dd|j        i|j        d           t          dd|j        i          }t          j        ||           d S )	Nr4   r8   r:   r   r   Fri   r=   ra   rc   s       r0   +test_write_existing_table_with_append_falsez7TestIceberg.test_write_existing_table_with_append_false   s    \YY*** 
 
 	 %w{3&	 	 	
 	
 	
  %w{3
 
 
 	fb)))))rI   N)__name__
__module____qualname__rH   rW   markparametrizerN   rQ   rZ   r]   rd   rf   rm   ro    rI   r0   r2   r2   C   s        0 0 0 [YN(CdSS0 0 TS00 0 0  ,0 0 0* * *$ [YN(CdSS* * TS*"0 0 00* * * * *rI   r2   )__doc__collectionsr%   r   rW   pandasr@   pandas._testing_testingrB   pandas.io.icebergr   rs   
single_cpu
pytestmarkimportorskipr   r   r   
namedtupler   fixturer+   r2   ru   rI   r0   <module>r      s#                        * * * * * *[#
F,,	'F'(;<< V*++
 +
 ,H,H,H
I
I # # #L[* [* [* [* [* [* [* [* [* [*rI   