U
    -e                     @   s  d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZ	ej
jZejejeZejdpxejedZddgZdd Ze d	d
 Ze dd Zdd Zdd ZG dd dZejdddd Zejdddd Zdd Zdd Z dd Z!dd Z"d d! Z#d"d# Z$d$d% Z%d&d' Z&d(d) Z'd*d+ Z(d,d- Z)d.d/ Z*d0d1 Z+d2d3 Z,d4d5 Z-d6d7 Z.d8d9 Z/d:d; Z0d<d= Z1d>d? Z2d@dA Z3dBdC Z4dDdE Z5dS )F    )	lru_cacheNZARROW_GDB_SCRIPTz../../../cpp/gdb_arrow.pygdbz--nxc               	   C   s:   i } dD ],}zt j| | |< W q tk
r2   Y qX q| S )N)PATHLD_LIBRARY_PATH)osenvironKeyError)envvar r   W/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/pyarrow/tests/test_gdb.pyenvironment_for_gdb*   s    r   c                  C   sJ   z(t jtdg t dt jt jt jd} W n tk
r>   Y dS X | jdkS )Nz	--versionr   )r	   bufsizestdinstdoutstderrF)
subprocessrungdb_commandr   PIPESTDOUTFileNotFoundError
returncode)procr   r   r   is_gdb_available4   s     
r   c                  C   s   t d} | d k	std| S )Npython3z Couldn't find python3 executable)shutilwhichAssertionError)pathr   r   r   python_executableC   s    
r    c                   C   s   t  std d S )Nzgdb command unavailable)r   pytestskipr   r   r   r   skip_if_gdb_unavailableJ   s    r#   c                   C   s   t jtstd d S )Nzgdb script not found)r   r   exists
gdb_scriptr!   r"   r   r   r   r   skip_if_gdb_script_unavailableO   s    r&   c                   @   sT   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd ZdS )
GdbSessionNTc                 O   sB   t  }|| tjtt| |dtjtjd| _g | _d| _	d S )Nr   )r	   r   r   r       )
r   updater   Popenr   listr   r   last_stdoutlast_stdout_line)selfargsr	   Zgdb_envr   r   r   __init__X   s    
 zGdbSession.__init__c                 C   s   | j ds| j dkr| jjd}| jrHtjj	| tjj
  |d\}}}|r| j| j  | j||  || _ q |dkst|  j |7  _ q | j dk	rtdd| jd}g | _d| _ |S )zW
        Record output until the gdb prompt displays.  Return recorded output.
        s   (gdb) Ni      
r(   z#gdb session terminated unexpectedlyutf-8)r-   
startswithr   pollr   readverbosesysbufferwriteflush
rpartitionr,   appendr   IOErrorjoindecode)r.   blocksep	last_lineoutr   r   r   wait_until_readyc   s(    zGdbSession.wait_until_readyc                 C   sL   | dd }| jr.tjj| tjj  | jj| | jj  d S )Nr2   r1   )	encoder6   r7   r   r8   r9   r:   r   r   r.   liner   r   r   issue_command   s    zGdbSession.issue_commandc                 C   s   |  | |  S N)rH   rD   rF   r   r   r   run_command   s    
zGdbSession.run_commandc                 C   s:   |  d| }tdd|\}}|dks2t|| S )zT
        Ask gdb to print the value of an expression and return the result.
        zp z	^\$\d+ =     )rJ   resubnr   strip)r.   exprrC   nr   r   r   print_value   s    zGdbSession.print_valuec                 C   sr   |  d}dt| d }t||}|dkr@td|  t|d }|  d| }d| |ksntdS )	zJ
        Select the innermost frame with the given function name.
        z
info stackz(?mi)^#(\d+)\s+.* in z\bNz$Could not select frame for function rL   zframe zin )rJ   rM   escapesearchr!   Zfailintr   )r.   	func_namerC   patmZ	frame_numr   r   r   select_frame   s    
zGdbSession.select_framec                 C   s@   | j d k	r<| j j  | j j  | j   | j   d | _ d S rI   )r   r   closer   killwaitr.   r   r   r   r>      s    


zGdbSession.joinc                 C   s   |    d S rI   )r>   r]   r   r   r   __del__   s    zGdbSession.__del__)__name__
__module____qualname__r   r6   r0   rD   rH   rJ   rR   rY   r>   r^   r   r   r   r   r'   T   s   
r'   session)scopec                  c   s\   t   tdt } z:|   | d | d | d | d | V  W 5 |   X d S )Nz-qzset confirm offzset print array-indexes onzset width unlimitedzset charset UTF-8)r#   r'   r    r>   rD   rJ   )r   r   r   r   r      s    




c                 C   s   dt jjkrtd t  | dt  tj	dkr:dnd}t
j|}|rd| d| d|  d	}| d
| d}d|ksd|kst|| d | S )Ndebz%Arrow C++ debug symbols not availablezsource win32r   r   zset env  z>from pyarrow.lib import _gdb_test_session; _gdb_test_session()zrun -c ''zTrace/breakpoint trapzreceived signalzarrow::gdb::TestSession)paZcpp_build_infoZ
build_typer!   r"   r&   rJ   r%   r7   platformr   r   getr   rY   )r   Zlib_path_varZlib_pathcoderC   r   r   r   	gdb_arrow   s"    

rl   c                 C   s    |  d}|dst|d S )Nzshow versionz	GNU gdb ()rJ   r3   r   )r   rC   r   r   r   test_gdb_session   s    
rm   c                 C   s   |  d}|dkstd S )Nz42 + 1Z43)rR   r   )rl   sr   r   r   test_gdb_arrow   s    
ro   c                 C   s:   |  |}t|tjr*||s6t|n||ks6tdS )z/
    Check printing a stack-located value.
    N)rR   
isinstancerM   Patternmatchr   r   rP   expectedrn   r   r   r   check_stack_repr   s    
ru   c                 C   s0   |  d| }||kr,|d| s,tdS )zA
    Check printing a heap-located value, given its address.
    *rf   N)rR   endswithr   rs   r   r   r   check_heap_repr   s    rx   c                 C   sL   t | dd t | dd t | dd t | dd t | d	d
 t | dd d S )NZ	ok_statuszarrow::Status::OK()Zerror_statusz*arrow::Status::IOError("This is an error")Zerror_detail_statuszXarrow::Status::IOError("This is an error", detail=[custom-detail-id] "This is a detail")Z	ok_resultzarrow::Result<int>(42)Zerror_resultz>arrow::Result<int>(arrow::Status::IOError("This is an error"))Zerror_detail_resultzlarrow::Result<int>(arrow::Status::IOError("This is an error", detail=[custom-detail-id] "This is a detail"))ru   rl   r   r   r   test_status   s(       r{   c                 C   s4   t | dd t | dd t | dd t | dd d S )	NZbuffer_nullz"arrow::Buffer of size 0, read-onlyZ
buffer_abc)arrow::Buffer of size 3, read-only, "abc"Zbuffer_special_charsz=arrow::Buffer of size 12, read-only, "foo\"bar\000\r\n\t\037"Zbuffer_mutablez.arrow::MutableBuffer of size 3, mutable, "abc"ry   rz   r   r   r   test_buffer_stack  s     r}   c                 C   s   t | dd t | dd d S )NZheap_bufferr|   zheap_buffer_mutable.get()z'arrow::Buffer of size 3, mutable, "abc"rx   rz   r   r   r   test_buffer_heap  s    r   c                 C   s   d}t | dd t | dd| d t | dd| d t | d	d
 t | dd| d t | dd| d d}t | dd t | dd| d t | dd| d t | dd t | dd| d t | dd| d d S )NZ&98765432109876543210987654321098765432Zdecimal128_zerozarrow::Decimal128(0)Zdecimal128_poszarrow::Decimal128()Zdecimal128_negzarrow::Decimal128(-Zbasic_decimal128_zerozarrow::BasicDecimal128(0)Zbasic_decimal128_poszarrow::BasicDecimal128(Zbasic_decimal128_negzarrow::BasicDecimal128(-ZL9876543210987654321098765432109876543210987654321098765432109876543210987654Zdecimal256_zerozarrow::Decimal256(0)Zdecimal256_poszarrow::Decimal256(Zdecimal256_negzarrow::Decimal256(-Zbasic_decimal256_zerozarrow::BasicDecimal256(0)Zbasic_decimal256_poszarrow::BasicDecimal256(Zbasic_decimal256_negzarrow::BasicDecimal256(-ry   )rl   Zv128Zv256r   r   r   test_decimals  sD    







r   c                 C   s   t | dd t | dd d S )Nzempty_metadata.get()z!arrow::KeyValueMetadata of size 0zmetadata.get()zcarrow::KeyValueMetadata of size 2 = {["key_text"] = "some value", ["key_binary"] = "z\000\037\377"}r~   rz   r   r   r   test_metadata;  s     r   c                 C   s  t | dd t | dd t | dd t | dd t | d	d
 t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd  t | d!d" t | d#d$ t | d%d& t | d'd( t | d)d* t | d+d, t | d-d. t | d/d0 t | d1d2 t | d3d4 t | d5d6 t | d7d8 t | d9d: t | d;d< t | d=d> t | d?d@ t | dAdB t | dCdD t | dEdF t | dGdH d S )INZ	null_typearrow::null()Z	bool_typearrow::boolean()Zdate32_typezarrow::date32()Zdate64_typezarrow::date64()Ztime_type_sz&arrow::time32(arrow::TimeUnit::SECOND)Ztime_type_msz%arrow::time32(arrow::TimeUnit::MILLI)Ztime_type_usz%arrow::time64(arrow::TimeUnit::MICRO)Ztime_type_ns$arrow::time64(arrow::TimeUnit::NANO)Ztimestamp_type_sz)arrow::timestamp(arrow::TimeUnit::SECOND)Ztimestamp_type_ms_timezonez8arrow::timestamp(arrow::TimeUnit::MILLI, "Europe/Paris")Ztimestamp_type_usz(arrow::timestamp(arrow::TimeUnit::MICRO)Ztimestamp_type_ns_timezone7arrow::timestamp(arrow::TimeUnit::NANO, "Europe/Paris")Zday_time_interval_typezarrow::day_time_interval()Zmonth_interval_typezarrow::month_interval()Zmonth_day_nano_interval_typez arrow::month_day_nano_interval()Zduration_type_sz(arrow::duration(arrow::TimeUnit::SECOND)Zduration_type_nsz&arrow::duration(arrow::TimeUnit::NANO)Zdecimal128_typearrow::decimal128(16, 5)Zdecimal256_typezarrow::decimal256(42, 12)binary_typezarrow::binary()Zstring_typezarrow::utf8()Zlarge_binary_typezarrow::large_binary()Zlarge_string_typezarrow::large_utf8()Zfixed_size_binary_typezarrow::fixed_size_binary(10)Z	list_typearrow::list(arrow::uint8())Zlarge_list_type&arrow::large_list(arrow::large_utf8())Zfixed_size_list_type+arrow::fixed_size_list(arrow::float64(), 3)Zmap_type_unsorted=arrow::map(arrow::utf8(), arrow::binary(), keys_sorted=false)Zmap_type_sortedz<arrow::map(arrow::utf8(), arrow::binary(), keys_sorted=true)Zstruct_type_emptyzarrow::struct_({})Zstruct_typejarrow::struct_({arrow::field("ints", arrow::int8()), arrow::field("strs", arrow::utf8(), nullable=false)})Zsparse_union_typezarrow::sparse_union(fields={arrow::field("ints", arrow::int8()), arrow::field("strs", arrow::utf8(), nullable=false)}, type_codes={7, 42})Zdense_union_typezarrow::dense_union(fields={arrow::field("ints", arrow::int8()), arrow::field("strs", arrow::utf8(), nullable=false)}, type_codes={7, 42})Zdict_type_unordered?arrow::dictionary(arrow::int16(), arrow::utf8(), ordered=false)Zdict_type_orderedz>arrow::dictionary(arrow::int16(), arrow::utf8(), ordered=true)Z	uuid_typeUarrow::ExtensionType "extension<uuid>" with storage type arrow::fixed_size_binary(16)ry   rz   r   r   r   test_types_stackD  s              r   c                 C   s   t | dd t | dd t | dd t | dd t | d	d
 t | dd t | dd t | dd t | dd t | dd t | dd t | dd d S )NZheap_null_typer   Zheap_bool_typer   Zheap_time_type_nsr   Zheap_timestamp_type_ns_timezoner   Zheap_decimal128_typer   Zheap_list_typer   Zheap_large_list_typer   Zheap_fixed_size_list_typer   Zheap_map_typer   Zheap_struct_typer   Zheap_dict_typer   Zheap_uuid_typer   r~   rz   r   r   r   test_types_heap  sT         r   c                 C   s   t | dd t | dd d S )NZ	int_field$arrow::field("ints", arrow::int64())Zfloat_fieldz8arrow::field("floats", arrow::float32(), nullable=false)ry   rz   r   r   r   test_fields_stack  s     r   c                 C   s   t | dd d S )NZheap_int_fieldr   r~   rz   r   r   r   test_fields_heap  s    r   c                 C   s  t | dd t | dd t | dd t | dd t | d	d
 t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd  t | d!d" t | d#d$ t | d%d& t | d'd( t | d)d* t | d+d, t | d-d. t | d/d0 t | d1d2 t | d3d4 t | d5d6 t | d7d8 t | d9d: t | d;d< t | d=d> t | d?d@ t | dAdB t | dCdD t | dEdF t | dGdH t | dIdJ t | dKdL t | dMdN t | dOdP t | dQdR t | dSdT t | dUdV t | dWdX t | dYdZ t | d[d\ t | d]d^ t | d_d` t | dadb t | dcdd t | dedf t | dgdh t | didj t | dkdl t | dmdn t | dodp t | dqdr t | dsdt t | dudv t | dwdx t | dydz t | d{d| t | d}d~ t | dd t | dtd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dtd t | dd t | dtd t | dd t | dd d S )NZnull_scalararrow::NullScalarZbool_scalar"arrow::BooleanScalar of value trueZbool_scalar_nullz"arrow::BooleanScalar of null valueZint8_scalarzarrow::Int8Scalar of value -42Zuint8_scalarzarrow::UInt8Scalar of value 234Zint64_scalarz0arrow::Int64Scalar of value -9223372036854775808Zuint64_scalarz1arrow::UInt64Scalar of value 18446744073709551615Zhalf_float_scalarz,arrow::HalfFloatScalar of value -1.5 [48640]Zfloat_scalarz arrow::FloatScalar of value 1.25Zdouble_scalarz arrow::DoubleScalar of value 2.5Ztime_scalar_sz!arrow::Time32Scalar of value 100sZtime_scalar_msz#arrow::Time32Scalar of value 1000msZtime_scalar_usz$arrow::Time64Scalar of value 10000usZtime_scalar_nsz%arrow::Time64Scalar of value 100000nsZtime_scalar_nullz&arrow::Time64Scalar of null value [ns]Zduration_scalar_sz$arrow::DurationScalar of value -100sZduration_scalar_msz&arrow::DurationScalar of value -1000msZduration_scalar_usz'arrow::DurationScalar of value -10000usZduration_scalar_nsz(arrow::DurationScalar of value -100000nsZduration_scalar_nullz(arrow::DurationScalar of null value [ns]Ztimestamp_scalar_sz4arrow::TimestampScalar of value 12345s [no timezone]Ztimestamp_scalar_msz7arrow::TimestampScalar of value -123456ms [no timezone]Ztimestamp_scalar_usz7arrow::TimestampScalar of value 1234567us [no timezone]Ztimestamp_scalar_nsz9arrow::TimestampScalar of value -12345678ns [no timezone]Ztimestamp_scalar_nullz6arrow::TimestampScalar of null value [ns, no timezone]Ztimestamp_scalar_s_tzz7arrow::TimestampScalar of value 12345s ["Europe/Paris"]Ztimestamp_scalar_ms_tzz:arrow::TimestampScalar of value -123456ms ["Europe/Paris"]Ztimestamp_scalar_us_tzz:arrow::TimestampScalar of value 1234567us ["Europe/Paris"]Ztimestamp_scalar_ns_tzz<arrow::TimestampScalar of value -12345678ns ["Europe/Paris"]Ztimestamp_scalar_null_tzz9arrow::TimestampScalar of null value [ns, "Europe/Paris"]Zmonth_interval_scalarz'arrow::MonthIntervalScalar of value 23MZmonth_interval_scalar_nullz(arrow::MonthIntervalScalar of null valueZday_time_interval_scalarz/arrow::DayTimeIntervalScalar of value 23d-456msZday_time_interval_scalar_nullz*arrow::DayTimeIntervalScalar of null valueZmonth_day_nano_interval_scalarz6arrow::MonthDayNanoIntervalScalar of value 1M23d-456nsZ#month_day_nano_interval_scalar_nullz/arrow::MonthDayNanoIntervalScalar of null valueZdate32_scalarz-arrow::Date32Scalar of value 23d [1970-01-24]Zdate32_scalar_nullz!arrow::Date32Scalar of null valueZdate64_scalarz6arrow::Date64Scalar of value 3888000000ms [1970-02-15]Zdate64_scalar_nullz!arrow::Date64Scalar of null valueZdecimal128_scalar_nullz=arrow::Decimal128Scalar of null value [precision=10, scale=4]Zdecimal128_scalar_pos_scale_posAarrow::Decimal128Scalar of value 123.4567 [precision=10, scale=4]Zdecimal128_scalar_pos_scale_negzBarrow::Decimal128Scalar of value -123.4567 [precision=10, scale=4]Zdecimal128_scalar_neg_scale_poszFarrow::Decimal128Scalar of value 1.234567e+10 [precision=10, scale=-4]Zdecimal128_scalar_neg_scale_negzGarrow::Decimal128Scalar of value -1.234567e+10 [precision=10, scale=-4]Zdecimal256_scalar_nullz=arrow::Decimal256Scalar of null value [precision=50, scale=4]Zdecimal256_scalar_pos_scale_posharrow::Decimal256Scalar of value 123456789012345678901234567890123456789012.3456 [precision=50, scale=4]Zdecimal256_scalar_pos_scale_negziarrow::Decimal256Scalar of value -123456789012345678901234567890123456789012.3456 [precision=50, scale=4]Zdecimal256_scalar_neg_scale_poszmarrow::Decimal256Scalar of value 1.234567890123456789012345678901234567890123456e+49 [precision=50, scale=-4]Zdecimal256_scalar_neg_scale_negznarrow::Decimal256Scalar of value -1.234567890123456789012345678901234567890123456e+49 [precision=50, scale=-4]Zbinary_scalar_nullz!arrow::BinaryScalar of null valueZbinary_scalar_unallocatedz*arrow::BinaryScalar of value <unallocated>Zbinary_scalar_emptyz'arrow::BinaryScalar of size 0, value ""Zbinary_scalar_abcz*arrow::BinaryScalar of size 3, value "abc"Zbinary_scalar_bytesz3arrow::BinaryScalar of size 3, value "\000\037\377"Zlarge_binary_scalar_abcz/arrow::LargeBinaryScalar of size 3, value "abc"Zstring_scalar_nullz!arrow::StringScalar of null valueZstring_scalar_unallocatedz*arrow::StringScalar of value <unallocated>Zstring_scalar_emptyz'arrow::StringScalar of size 0, value ""Zstring_scalar_heheu-   arrow::StringScalar of size 6, value "héhé"Zstring_scalar_invalid_charsz:arrow::StringScalar of size 11, value "abc\x00def\\xffghi"Zlarge_string_scalar_heheu2   arrow::LargeStringScalar of size 6, value "héhé"Zfixed_size_binary_scalarz3arrow::FixedSizeBinaryScalar of size 3, value "abc"Zfixed_size_binary_scalar_nullz=arrow::FixedSizeBinaryScalar of size 3, null with value "   "Zdict_scalarz_^arrow::DictionaryScalar of index arrow::Int8Scalar of value 42, dictionary arrow::StringArray Zdict_scalar_nullzjarrow::DictionaryScalar of type arrow::dictionary(arrow::int8(), arrow::utf8(), ordered=false), null valueZlist_scalarznarrow::ListScalar of value arrow::Int32Array of length 3, offset 0, null count 0 = {[0] = 4, [1] = 5, [2] = 6}Zlist_scalar_nullzAarrow::ListScalar of type arrow::list(arrow::int32()), null valueZlarge_list_scalarzsarrow::LargeListScalar of value arrow::Int32Array of length 3, offset 0, null count 0 = {[0] = 4, [1] = 5, [2] = 6}Zlarge_list_scalar_nullzLarrow::LargeListScalar of type arrow::large_list(arrow::int32()), null valueZfixed_size_list_scalarzwarrow::FixedSizeListScalar of value arrow::Int32Array of length 3, offset 0, null count 0 = {[0] = 4, [1] = 5, [2] = 6}Zfixed_size_list_scalar_nullzXarrow::FixedSizeListScalar of type arrow::fixed_size_list(arrow::int32(), 3), null valueZstruct_scalarz~arrow::StructScalar = {["ints"] = arrow::Int32Scalar of value 42, ["strs"] = arrow::StringScalar of size 9, value "some text"}Zstruct_scalar_nullzarrow::StructScalar of type arrow::struct_({arrow::field("ints", arrow::int32()), arrow::field("strs", arrow::utf8())}), null valueZsparse_union_scalarzMarrow::SparseUnionScalar of type code 7, value arrow::Int32Scalar of value 43Zsparse_union_scalar_nullzU^arrow::SparseUnionScalar of type arrow::sparse_union\(.*\), type code 7, null value$Zdense_union_scalarzLarrow::DenseUnionScalar of type code 7, value arrow::Int32Scalar of value 43Zdense_union_scalar_nullzS^arrow::DenseUnionScalar of type arrow::dense_union\(.*\), type code 7, null value$Zextension_scalarzyarrow::ExtensionScalar of type "extension<uuid>", value arrow::FixedSizeBinaryScalar of size 16, value "0123456789abcdef"Zextension_scalar_nullz<arrow::ExtensionScalar of type "extension<uuid>", null valueru   rM   compilerz   r   r   r   test_scalars_stack  s                                                         r   c                 C   sL   t | dd t | dd t | dd t | dd t | d	d
 t | dd d S )NZheap_null_scalarr   Zheap_bool_scalarr   Zheap_decimal128_scalarr   Zheap_decimal256_scalarr   Zheap_map_scalarz}arrow::MapScalar of type arrow::map(arrow::utf8(), arrow::int32(), keys_sorted=false), value length 2, offset 0, null count 0Zheap_map_scalar_nullzaarrow::MapScalar of type arrow::map(arrow::utf8(), arrow::int32(), keys_sorted=false), null valuer~   rz   r   r   r   test_scalars_heap  s0        r   c                 C   s   t | dd d S )NZint32_array_datazuarrow::ArrayData of type arrow::int32(), length 4, offset 0, null count 1 = {[0] = -5, [1] = 6, [2] = null, [3] = 42}ry   rz   r   r   r   test_array_data  s
     r   c                 C   s   t | dd t | dd d S )NZint32_arrayaarrow::Int32Array of length 4, offset 0, null count 1 = {[0] = -5, [1] = 6, [2] = null, [3] = 42}Z
list_arrayVarrow::ListArray of type arrow::list(arrow::int64()), length 3, offset 0, null count 1ry   rz   r   r   r   test_arrays_stack  s      r   c                 C   s  t | dd t | dd t | dd t | dd t | d	d
 t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd t | dd  t | d!d" t | d#d$ t | d%d& t | d'd( t | d)d* t | d+d, t | d-d. t | d/d0 t | d1d2 t | d3d4 t | d5d6 t | d7d8 t | d9d: t | d;d< t | d=d> t | d?d@ t | dAdB t | dCdD t | dEdF t | dGdH t | dIdJ t | dKdL t | dMdN t | dOdP d S )QNZheap_null_arrayz4arrow::NullArray of length 2, offset 0, null count 2Zheap_int32_arrayr   Zheap_int32_array_no_nullsz^arrow::Int32Array of length 4, offset 0, null count 0 = {[0] = -5, [1] = 6, [2] = 3, [3] = 42}Zheap_int32_array_sliced_1_9zarrow::Int32Array of length 9, offset 1, unknown null count = {[0] = 2, [1] = -3, [2] = 4, [3] = null, [4] = -5, [5] = 6, [6] = -7, [7] = 8, [8] = null}Zheap_int32_array_sliced_2_6zzarrow::Int32Array of length 6, offset 2, unknown null count = {[0] = -3, [1] = 4, [2] = null, [3] = -5, [4] = 6, [5] = -7}Zheap_int32_array_sliced_8_4zharrow::Int32Array of length 4, offset 8, unknown null count = {[0] = 8, [1] = null, [2] = -9, [3] = -10}Zheap_int32_array_sliced_emptyz;arrow::Int32Array of length 0, offset 6, unknown null countZheap_double_arrayzQarrow::DoubleArray of length 2, offset 0, null count 1 = {[0] = -1.5, [1] = null}Zheap_float16_arrayzSarrow::HalfFloatArray of length 2, offset 0, null count 0 = {[0] = 0.0, [1] = -1.5}Zheap_bool_arraya!  arrow::BooleanArray of length 18, offset 0, null count 6 = {[0] = false, [1] = false, [2] = true, [3] = true, [4] = null, [5] = null, [6] = false, [7] = false, [8] = true, [9] = true, [10] = null, [11] = null, [12] = false, [13] = false, [14] = true, [15] = true, [16] = null, [17] = null}Zheap_bool_array_sliced_1_9zarrow::BooleanArray of length 9, offset 1, unknown null count = {[0] = false, [1] = true, [2] = true, [3] = null, [4] = null, [5] = false, [6] = false, [7] = true, [8] = true}Zheap_bool_array_sliced_2_6zarrow::BooleanArray of length 6, offset 2, unknown null count = {[0] = true, [1] = true, [2] = null, [3] = null, [4] = false, [5] = false}Zheap_bool_array_sliced_emptyz=arrow::BooleanArray of length 0, offset 6, unknown null countZheap_date32_arrayzarrow::Date32Array of length 6, offset 0, null count 1 = {[0] = 0d [1970-01-01], [1] = null, [2] = 18336d [2020-03-15], [3] = -9004d [1945-05-08], [4] = -719162d [0001-01-01], [5] = -719163d [year <= 0]}Zheap_date64_arrayzarrow::Date64Array of length 5, offset 0, null count 0 = {[0] = 1584230400000ms [2020-03-15], [1] = -777945600000ms [1945-05-08], [2] = -62135596800000ms [0001-01-01], [3] = -62135683200000ms [year <= 0], [4] = 123ms [non-multiple of 86400000]}Zheap_time32_array_szarrow::Time32Array of type arrow::time32(arrow::TimeUnit::SECOND), length 3, offset 0, null count 1 = {[0] = null, [1] = -123s, [2] = 456s}Zheap_time32_array_mszarrow::Time32Array of type arrow::time32(arrow::TimeUnit::MILLI), length 3, offset 0, null count 1 = {[0] = null, [1] = -123ms, [2] = 456ms}Zheap_time64_array_uszarrow::Time64Array of type arrow::time64(arrow::TimeUnit::MICRO), length 3, offset 0, null count 1 = {[0] = null, [1] = -123us, [2] = 456us}Zheap_time64_array_nszarrow::Time64Array of type arrow::time64(arrow::TimeUnit::NANO), length 3, offset 0, null count 1 = {[0] = null, [1] = -123ns, [2] = 456ns}Zheap_month_interval_arrayzearrow::MonthIntervalArray of length 3, offset 0, null count 1 = {[0] = 123M, [1] = -456M, [2] = null}Zheap_day_time_interval_arrayz^arrow::DayTimeIntervalArray of length 2, offset 0, null count 1 = {[0] = 1d-600ms, [1] = null}Z"heap_month_day_nano_interval_arrayzharrow::MonthDayNanoIntervalArray of length 2, offset 0, null count 1 = {[0] = 1M-600d5000ns, [1] = null}Zheap_duration_array_szarrow::DurationArray of type arrow::duration(arrow::TimeUnit::SECOND), length 2, offset 0, null count 1 = {[0] = null, [1] = -1234567890123456789s}Zheap_duration_array_nszarrow::DurationArray of type arrow::duration(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {[0] = null, [1] = -1234567890123456789ns}Zheap_timestamp_array_szarrow::TimestampArray of type arrow::timestamp(arrow::TimeUnit::SECOND), length 4, offset 0, null count 1 = {[0] = null, [1] = 0s [1970-01-01 00:00:00], [2] = -2203932304s [1900-02-28 12:34:56], [3] = 63730281600s [3989-07-14 00:00:00]}Zheap_timestamp_array_mszarrow::TimestampArray of type arrow::timestamp(arrow::TimeUnit::MILLI), length 3, offset 0, null count 1 = {[0] = null, [1] = -2203932303877ms [1900-02-28 12:34:56.123], [2] = 63730281600789ms [3989-07-14 00:00:00.789]}Zheap_timestamp_array_uszarrow::TimestampArray of type arrow::timestamp(arrow::TimeUnit::MICRO), length 3, offset 0, null count 1 = {[0] = null, [1] = -2203932303345679us [1900-02-28 12:34:56.654321], [2] = 63730281600456789us [3989-07-14 00:00:00.456789]}Zheap_timestamp_array_nszarrow::TimestampArray of type arrow::timestamp(arrow::TimeUnit::NANO), length 2, offset 0, null count 1 = {[0] = null, [1] = -2203932303012345679ns [1900-02-28 12:34:56.987654321]}Zheap_decimal128_arrayzarrow::Decimal128Array of type arrow::decimal128(30, 6), length 3, offset 0, null count 1 = {[0] = null, [1] = -1234567890123456789.012345, [2] = 1234567890123456789.012345}Zheap_decimal256_arrayzarrow::Decimal256Array of type arrow::decimal256(50, 6), length 2, offset 0, null count 1 = {[0] = null, [1] = -123456789012345678901234567890123456789.012345}Zheap_decimal128_array_slicedzarrow::Decimal128Array of type arrow::decimal128(30, 6), length 1, offset 1, unknown null count = {[0] = -1234567890123456789.012345}Zheap_fixed_size_binary_arrayzarrow::FixedSizeBinaryArray of type arrow::fixed_size_binary(3), length 3, offset 0, null count 1 = {[0] = null, [1] = "abc", [2] = "\000\037\377"}Z'heap_fixed_size_binary_array_zero_widthzzarrow::FixedSizeBinaryArray of type arrow::fixed_size_binary(0), length 2, offset 0, null count 1 = {[0] = null, [1] = ""}Z#heap_fixed_size_binary_array_slicedzwarrow::FixedSizeBinaryArray of type arrow::fixed_size_binary(3), length 1, offset 1, unknown null count = {[0] = "abc"}Zheap_binary_arrayziarrow::BinaryArray of length 3, offset 0, null count 1 = {[0] = null, [1] = "abcd", [2] = "\000\037\377"}Zheap_large_binary_arrayznarrow::LargeBinaryArray of length 3, offset 0, null count 1 = {[0] = null, [1] = "abcd", [2] = "\000\037\377"}Zheap_string_arrayuq   arrow::StringArray of length 3, offset 0, null count 1 = {[0] = null, [1] = "héhé", [2] = "invalid \\xff char"}Zheap_large_string_arrayuv   arrow::LargeStringArray of length 3, offset 0, null count 1 = {[0] = null, [1] = "héhé", [2] = "invalid \\xff char"}Zheap_binary_array_slicedzMarrow::BinaryArray of length 1, offset 1, unknown null count = {[0] = "abcd"}Zheap_list_arrayr   r~   rz   r   r   r   test_arrays_heap   s                                           r   c                 C   s(   t | dd t | dd t | dd d S )NZschema_emptyzarrow::Schema with 0 fieldsZschema_non_emptyzRarrow::Schema with 2 fields = {["ints"] = arrow::int8(), ["strs"] = arrow::utf8()}Zschema_with_metadatazgarrow::Schema with 2 fields and 2 metadata items = {["ints"] = arrow::int8(), ["strs"] = arrow::utf8()}r~   rz   r   r   r   test_schema  s      r   c                 C   s   t | dd d S )NZchunked_arrayzarrow::ChunkedArray of type arrow::int32(), length 5, null count 1 with 2 chunks = {[0] = length 2, offset 0, null count 0, [1] = length 3, offset 0, null count 1}ry   rz   r   r   r   test_chunked_array  s
     r   c                 C   sL   d}d}| d| }t | d| t | d| | d| }t | d| d S )Nz)arrow::RecordBatch with 2 columns, 3 rowsz{["ints"] = arrow::ArrayData of type arrow::int32(), length 3, offset 0, null count 0 = {[0] = 1, [1] = 2, [2] = 3}, ["strs"] = arrow::ArrayData of type arrow::utf8(), length 3, offset 0, null count 1 = {[0] = "abc", [1] = null, [2] = "def"}}z = batchzbatch.get()z, 3 metadata items = Zbatch_with_metadatar~   )rl   Zexpected_prefixZexpected_suffixrt   r   r   r   test_record_batch  s    r   c                 C   s    d}t | d| t | d| d S )Na  arrow::Table with 2 columns, 5 rows = {["ints"] = arrow::ChunkedArray of type arrow::int32(), length 5, null count 0 with 2 chunks = {[0] = length 3, offset 0, null count 0, [1] = length 2, offset 0, null count 0}, ["strs"] = arrow::ChunkedArray of type arrow::utf8(), length 5, null count 1 with 3 chunks = {[0] = length 2, offset 0, null count 1, [1] = length 1, offset 0, null count 0, [2] = length 2, offset 0, null count 0}}tableztable.get()r~   )rl   Zexpected_tabler   r   r   
test_table  s    r   c                 C   sd   t | dd t | dd t | dtd t | dtd t | d	td
 t | dtd d S )NZempty_datumzarrow::Datum (empty)Zscalar_datumz8arrow::Datum of value arrow::BooleanScalar of null valueZarray_datumz0^arrow::Datum of value arrow::ArrayData of type Zchunked_array_datumz3^arrow::Datum of value arrow::ChunkedArray of type Zbatch_datumzA^arrow::Datum of value arrow::RecordBatch with 2 columns, 3 rows Ztable_datumz;^arrow::Datum of value arrow::Table with 2 columns, 5 rows r   rz   r   r   r   
test_datum  s4         r   )6	functoolsr   r   rM   r   r   r7   r!   Zpyarrowrh   markr   Z
pytestmarkr   dirnameabspath__file__herer   rj   r>   r%   r   r   r   r    r#   r&   r'   Zfixturerl   rm   ro   ru   rx   r{   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   sf   


^




	\&   Q