o
    bi                     @   sT   zd dl Z W n ey   dZ Y nw dddefddZ	ddddedd	fd
dZdS )    Ncazpyarrow.ChunkedArrayreturnc                 C   s   t | jtjS )zfWhether the provided Arrow Table column is an extension array, using an Arrow
    extension type.
    )
isinstancetypepyarrowExtensionType)r    r   R/home/ubuntu/.local/lib/python3.10/site-packages/ray/air/util/transform_pyarrow.py_is_column_extension_type   s   r
   Fensure_copyzpyarrow.Arrayc                 C   s   ddl m}m} t| std| }| jdkr"tjg | jj	d}n&t
| j|r/|| j|S |s=t| jdkr=| jd S tdd | jD }| j | j|S )a  Concatenate chunks of an extension column into a contiguous array.

    This concatenation is required for creating copies and for .take() to work on
    extension arrays.
    See https://issues.apache.org/jira/browse/ARROW-16503.

    Args:
        ca: The chunked array representing the extension column to be concatenated.
        ensure_copy: Skip copying when ensure_copy is False and there is exactly 1 chunk.
    r   )ArrowTensorArray get_arrow_extension_tensor_typesz,Chunked array isn't an extension array: {ca})r      c                 S   s   g | ]}|j qS r   )storage).0cr   r   r	   
<listcomp>.   s    z1_concatenate_extension_column.<locals>.<listcomp>)$ray.air.util.tensor_extensions.arrowr   r   r
   
ValueError
num_chunksr   arrayr   storage_typer   _concat_same_typechunkslenconcat_arrays__arrow_ext_class__from_storage)r   r   r   r   tensor_extension_typesr   r   r   r	   _concatenate_extension_column   s   

r   )F)r   ImportErrorboolr
   r   r   r   r   r	   <module>   s    