
    'h                       S SK Jr  S SKrS SKrS SKJr  S SKJrJr  S SK	J
r  S SKJr  \(       a  S SKJr  S SKJr  S SKJrJrJr  S SKJr  \" 5       S	S	S
.         SS jj5       r\" 5       SS.       SS jj5       rg)    )annotationsN)Iterator)TYPE_CHECKINGCallable)unstable)r   )	DataFrameExpr	LazyFrame)
SchemaDictF)validate_schemais_purec               j   ^            SU 4S jjn[         R                  R                  UUSUUS9$ )a   
Register your IO plugin and initialize a LazyFrame.

See the `user guide <https://docs.pola.rs/user-guide/plugins/io_plugins>`_
for more information about plugins.

.. warning::
    This functionality is considered **unstable**. It may be changed
    at any point without it being considered a breaking change.


Parameters
----------
io_source
    Function that accepts the following arguments:
        with_columns
            Columns that are projected. The reader must
            project these columns if applied
        predicate
            Polars expression. The reader must filter
            their rows accordingly.
        n_rows
            Materialize only n rows from the source.
            The reader can stop when `n_rows` are read.
        batch_size
            A hint of the ideal batch size the reader's
            generator must produce.

    The function should return a an iterator/generator
    that produces DataFrames.
schema
    Schema or function that when called produces the schema that the reader
    will produce before projection pushdown.
validate_schema
    Whether the engine should validate if the batches generated match
    the given schema. It's an implementation error if this isn't
    the case and can lead to bugs that are hard to solve.

Returns
-------
LazyFrame
c                   > SnS nU(       a    [         R                  R                  U5      nT" XX#5      U4$ ! [         aK  n[        R
                  R                  S5      (       a  [        SU 3[        R                  S9  Sn S nAN[S nAff = f)NTPOLARS_VERBOSEzMfailed parsing IO plugin expression

filter will be handled on Polars' side: )fileF)
plr	   deserialize	Exceptionosenvirongetprintsysstderr)with_columns	predicaten_rows
batch_sizeparsed_predicate_successparsed_predicatee	io_sources          dC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\polars/io/plugins.pywrap register_io_source.<locals>.wrapH   s     $( 1#%77#6#6y#A  F
#$ 	$  1::>>"233ijkilm ZZ ,1(1s   8 
BABBF)schemascan_fnpyarrowr   r   )
r   list[str] | Noner   zbytes | Noner   
int | Noner   r*   returnz tuple[Iterator[DataFrame], bool])r   r
   _scan_python_function)r"   r&   r   r   r$   s   `    r#   register_io_sourcer-      sd    j$&$$ $ 	$
 
*$. <<--' .      T)r   c               <   ^            SU 4S jjn[        X1US9$ )u  
Deferred execution.

Takes a function that produces a `DataFrame` but defers execution until the
`LazyFrame` is collected.

Parameters
----------
function
    Function that takes no arguments and produces a `DataFrame`.
schema
    Schema of the `DataFrame` the deferred function will return.
    The caller must ensure this schema is correct.
validate_schema
    Whether the engine should validate if the batches generated match
    the given schema. It's an implementation error if this isn't
    the case and can lead to bugs that are hard to solve.

Examples
--------
Delay DataFrame execution until query is executed.

>>> import numpy as np
>>> np.random.seed(0)
>>> lf = pl.defer(
...     lambda: pl.DataFrame({"a": np.random.randn(3)}), schema={"a": pl.Float64}
... )
>>> lf.collect()
shape: (3, 1)
┌──────────┐
│ a        │
│ ---      │
│ f64      │
╞══════════╡
│ 1.764052 │
│ 0.400157 │
│ 0.978738 │
└──────────┘

 Run an eager source in Polars Cloud

>>> (
...     pl.defer(
...         lambda: pl.read_database("select * from tbl"),
...         schema={"a": pl.Float64, "b": pl.Boolean},
...     )
...     .filter("b")
...     .sum("a")
...     .remote()
...     .collect()
... )  # doctest: +SKIP


c              3     >#    T" 5       R                  5       nU b  UR                  U 5      nUb  UR                  U5      nUb  UR                  U5      nUR	                  5       v   g 7f)N)lazyselectfilterlimitcollect)r   r   r   r   lffunctions        r#   source_defer.<locals>.source   s^      Z__#<(B 9%B&!Bjjls   A%A()r"   r&   r   )
r   r)   r   zExpr | Noner   r*   r   r*   r+   zIterator[DataFrame])r-   )r7   r&   r   r8   s   `   r#   _deferr:   h   sK    |&  	
 
  r.   )
r"   zVCallable[[list[str] | None, Expr | None, int | None, int | None], Iterator[DataFrame]]r&   z%Callable[[], SchemaDict] | SchemaDictr   boolr   r;   r+   r
   )r7   zCallable[[], DataFrame]r&   z%SchemaDict | Callable[[], SchemaDict]r   r;   r+   r
   )
__future__r   r   r   collections.abcr   typingr   r   polars._reexport	_reexportr   polars._utils.unstabler   polarsr   r	   r
   polars._typingr   r-   r:    r.   r#   <module>rE      s    " 	 
 $ *  +(11) 
 "QQ
 2Q Q Q Q Qh 

 !	N%N 2N 	N
 N Nr.   