
    \
qi!                       d Z ddlmZ ddlZddlmZmZmZ 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 dd
lmZ ddlmZmZ erddlZddlZddlmZmZmZmZ ddlm Z   ed          de	j!        dfd(d            Z"	 d)ddddd*d'Z#dS )+z
orc compat    )annotationsN)TYPE_CHECKINGAnyLiteral)lib)import_optional_dependency)
set_module)check_dtype_backend)default_index)arrow_table_to_pandas)
get_handleis_fsspec_url)DtypeBackendFilePath
ReadBufferWriteBuffer)	DataFramepandaspathFilePath | ReadBuffer[bytes]columnslist[str] | Nonedtype_backendDtypeBackend | lib.NoDefault
filesystem=pyarrow.fs.FileSystem | fsspec.spec.AbstractFileSystem | Nonekwargsr   returnr   c                   t          d          }t          |           t          | dd          5 }|j        }t	          |           rV|Tt          d          }t          d          }		 |	j                            |           \  }}n# t          |j        f$ r Y nw xY w |j	        d
|||d|}
ddd           n# 1 swxY w Y   t          |
|	          S )a  
    Load an ORC object from the file path, returning a DataFrame.

    This method reads an ORC (Optimized Row Columnar) file into a pandas
    DataFrame using the `pyarrow.orc` library. ORC is a columnar storage format
    that provides efficient compression and fast retrieval for analytical workloads.
    It allows reading specific columns, handling different filesystem
    types (such as local storage, cloud storage via fsspec, or pyarrow filesystem),
    and supports different data type backends, including `numpy_nullable` and `pyarrow`.

    Parameters
    ----------
    path : str, path object, or file-like object
        String, path object (implementing ``os.PathLike[str]``), or file-like
        object implementing a binary ``read()`` function. The string could be a URL.
        Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is
        expected. A local file could be:
        ``file://localhost/path/to/table.orc``.
    columns : list, default None
        If not None, only these columns will be read from the file.
        Output always follows the ordering of the file and not the columns list.
        This mirrors the original behaviour of
        :external+pyarrow:py:meth:`pyarrow.orc.ORCFile.read`.
    dtype_backend : {'numpy_nullable', 'pyarrow'}
        Back-end data type applied to the resultant :class:`DataFrame`
        (still experimental). If not specified, the default behavior
        is to not use nullable data types. If specified, the behavior
        is as follows:

        * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`
        * ``"pyarrow"``: returns pyarrow-backed nullable
          :class:`ArrowDtype` :class:`DataFrame`

        .. versionadded:: 2.0

    filesystem : fsspec or pyarrow filesystem, default None
        Filesystem object to use when reading the orc file.

        .. versionadded:: 2.1.0

    **kwargs
        Any additional kwargs are passed to pyarrow.

    Returns
    -------
    DataFrame
        DataFrame based on the ORC file.

    See Also
    --------
    read_csv : Read a comma-separated values (csv) file into a pandas DataFrame.
    read_excel : Read an Excel file into a pandas DataFrame.
    read_spss : Read an SPSS file into a pandas DataFrame.
    read_sas : Load a SAS file into a pandas DataFrame.
    read_feather : Load a feather-format object into a pandas DataFrame.

    Notes
    -----
    Before using this function you should read the :ref:`user guide about ORC <io.orc>`
    and :ref:`install optional dependencies <install.warn_orc>`.

    If ``path`` is a URI scheme pointing to a local or remote file (e.g. "s3://"),
    a ``pyarrow.fs`` filesystem will be attempted to read the file. You can also pass a
    pyarrow or fsspec filesystem object into the filesystem keyword to override this
    behavior.

    Examples
    --------
    >>> result = pd.read_orc("example_pa.orc")  # doctest: +SKIP
    pyarrow.orcrbFis_textNpyarrowz
pyarrow.fs)sourcer   r   )r    )r   r
   r   handler   
FileSystemfrom_uri	TypeErrorArrowInvalid
read_tabler   )r   r   r   r   r   orchandlesr%   papa_fspa_tables              m/var/www/html/bestrading.cuttalo.com/services/ml-inference/venv/lib/python3.11/site-packages/pandas/io/orc.pyread_orcr3   '   sI   ` %]
3
3C&&&	D$	.	.	. 
' 	:#5+I66B.|<<E%*%5%>%>t%D%D"
FFr/    "3> 
7z
 
EK
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 !GGGGs5   7B;)BB;BB;BB;;B?B?r$   )engineindexengine_kwargsdf$FilePath | WriteBuffer[bytes] | Noner4   Literal['pyarrow']r5   bool | Noner6   dict[str, Any] | Nonebytes | Nonec                  || j         j        d         du}|i }| j                             t          t	          |                               st          d          | j         j        t          d          |dk    rt          d          t          d          }t          d          }|du }|rt          j	                    }|J t          |dd	
          5 }	  |j        |j                            | |          |j        fi | n)# t          |j        f$ r}	t#          d          |	d}	~	ww xY w	 ddd           n# 1 swxY w Y   |r0t%          |t          j	                  sJ |                                S dS )aM  
    Write a DataFrame to the ORC format.

    Parameters
    ----------
    df : DataFrame
        The dataframe to be written to ORC. Raises NotImplementedError
        if dtype of one or more columns is category, unsigned integers,
        intervals, periods or sparse.
    path : str, file-like object or None, default None
        If a string, it will be used as Root Directory path
        when writing a partitioned dataset. By file-like object,
        we refer to objects with a write() method, such as a file handle
        (e.g. via builtin open function). If path is None,
        a bytes object is returned.
    engine : str, default 'pyarrow'
        ORC library to use.
    index : bool, optional
        If ``True``, include the dataframe's index(es) in the file output. If
        ``False``, they will not be written to the file.
        If ``None``, similar to ``infer`` the dataframe's index(es)
        will be saved. However, instead of being saved as values,
        the RangeIndex will be stored as a range in the metadata so it
        doesn't require much space and is faster. Other indexes will
        be included as columns in the file output.
    engine_kwargs : dict[str, Any] or None, default None
        Additional keyword arguments passed to :func:`pyarrow.orc.write_table`.

    Returns
    -------
    bytes if no path argument is provided else None

    Raises
    ------
    NotImplementedError
        Dtype of one or more columns is category, unsigned integers, interval,
        period or sparse.
    ValueError
        engine is not pyarrow.

    Notes
    -----
    * Before using this function you should read the
      :ref:`user guide about ORC <io.orc>` and
      :ref:`install optional dependencies <install.warn_orc>`.
    * This function requires `pyarrow <https://arrow.apache.org/docs/python/>`_
      library.
    * For supported dtypes please refer to `supported ORC features in Arrow
      <https://arrow.apache.org/docs/cpp/orc.html#data-types>`__.
    * Currently timezones in datetime columns are not preserved when a
      dataframe is converted into ORC files.
    Nr   z{orc does not support serializing a non-default index for the index; you can .reset_index() to make the index into column(s)z9orc does not serialize index meta-data on a default indexr$   zengine must be 'pyarrow'r    wbFr"   )preserve_indexz6The dtype of one or more columns is not supported yet.)r5   namesequalsr   len
ValueErrornamer   ioBytesIOr   write_tableTablefrom_pandasr'   r*   ArrowNotImplementedErrorNotImplementedError
isinstancegetvalue)
r7   r   r4   r5   r6   r/   r-   was_noner.   es
             r2   to_orcrP      s   x }q!- 8??=R1122 
F
 
 	

 
x} TUUU3444	#I	.	.B
$]
3
3Ct|H z||	D$	.	.	. 
'		CO$$R$>>      
 267 	 	 	%H 	
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  $
+++++}}4s6   E.DED2D--D22EE	E)r   r   r   r   r   r   r   r   r   r   r   r   )N)r7   r   r   r8   r4   r9   r5   r:   r6   r;   r   r<   )$__doc__
__future__r   rE   typingr   r   r   pandas._libsr   pandas.compat._optionalr   pandas.util._decoratorsr	   pandas.util._validatorsr
   pandas.core.indexes.apir   pandas.io._utilr   pandas.io.commonr   r   fsspec
pyarrow.fsr$   pandas._typingr   r   r   r   pandas.core.framer   
no_defaultr3   rP   r&       r2   <module>ra      s     " " " " " " 				                > > > > > > . . . . . . 7 7 7 7 7 7 1 1 1 1 1 1 1 1 1 1 1 1       
  ,MMM            ,+++++ H !%25.PT	`H `H `H `H `HJ 26h "++/h h h h h h h hr`   