ง
    q-Ph   ใ                  ๓    d dl mZ d dlmZmZmZ erd dlmZ d dlm	Z	 dgZ
eddddฆ   ซ         Zeddฆ   ซ         ZddddZdS )้    )ฺannotations)ฺTYPE_CHECKINGฺLiteralฺoverload)ฺ	DataFrame)ฺ	LazyFrameฺsqlF)ฺeagerฺqueryฺstrr
   ๚Literal[False]ฺreturnr   c               ๓    d S ฉNฉ ฉr   r
   s     ๚T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/sql/functions.pyr	   r	      s    ุDGภC๓    ๚Literal[True]r   c               ๓    d S r   r   r   s     r   r	   r	      s    ุ;>ธ3r   ฺbool๚DataFrame | LazyFramec               ๓<    ddl m} |                     | |ฌฆ  ซ        S )uผ  
    Execute a SQL query against frames in the global namespace.

    .. versionadded:: 0.20.31

    Parameters
    ----------
    query
        SQL query to execute.
    eager
        Automatically collect the result and return a DataFrame instead of a LazyFrame.

    Notes
    -----
    * The Polars SQL engine can operate against Polars DataFrame, LazyFrame, and Series
      objects, as well as Pandas DataFrame and Series, PyArrow Table and RecordBatch.
    * Additional control over registration and execution behaviour is available
      with the :class:`SQLContext` object.

    See Also
    --------
    SQLContext

    Examples
    --------
    >>> lf1 = pl.LazyFrame({"a": [1, 2, 3], "b": [6, 7, 8], "c": ["z", "y", "x"]})
    >>> lf2 = pl.LazyFrame({"a": [3, 2, 1], "d": [125, -654, 888]})

    Query the LazyFrame using SQL:

    >>> lf1.sql("SELECT c, b FROM self WHERE a > 1").collect()
    shape: (2, 2)
    โโโโโโโฌโโโโโโ
    โ c   โ b   โ
    โ --- โ --- โ
    โ str โ i64 โ
    โโโโโโโชโโโโโโก
    โ y   โ 7   โ
    โ x   โ 8   โ
    โโโโโโโดโโโโโโ

    Join two LazyFrames:

    >>> pl.sql(
    ...     '''
    ...     SELECT lf1.*, d
    ...     FROM lf1
    ...     INNER JOIN lf2 USING (a)
    ...     WHERE a > 1 AND b < 8
    ...     '''
    ... ).collect()
    shape: (1, 4)
    โโโโโโโฌโโโโโโฌโโโโโโฌโโโโโโโ
    โ a   โ b   โ c   โ d    โ
    โ --- โ --- โ --- โ ---  โ
    โ i64 โ i64 โ str โ i64  โ
    โโโโโโโชโโโโโโชโโโโโโชโโโโโโโก
    โ 2   โ 7   โ y   โ -654 โ
    โโโโโโโดโโโโโโดโโโโโโดโโโโโโโ

    Apply SQL transforms and subsequently filter natively (you can freely mix SQL and
    native operations):

    >>> pl.sql(
    ...     query='''
    ...         SELECT
    ...             a,
    ...             (a % 2 == 0) AS a_is_even,
    ...             (b::float4 / 2) AS "b/2",
    ...             CONCAT_WS(':', c, c, c) AS c_c_c
    ...         FROM lf1
    ...         ORDER BY a
    ...     ''',
    ... ).filter(~pl.col("c_c_c").str.starts_with("x")).collect()
    shape: (2, 4)
    โโโโโโโฌโโโโโโโโโโโโฌโโโโโโฌโโโโโโโโ
    โ a   โ a_is_even โ b/2 โ c_c_c โ
    โ --- โ ---       โ --- โ ---   โ
    โ i64 โ bool      โ f32 โ str   โ
    โโโโโโโชโโโโโโโโโโโโชโโโโโโชโโโโโโโโก
    โ 1   โ false     โ 3.0 โ z:z:z โ
    โ 2   โ true      โ 3.5 โ y:y:y โ
    โโโโโโโดโโโโโโโโโโโโดโโโโโโดโโโโโโโโ

    Join polars LazyFrame with a pandas DataFrame and a pyarrow Table:

    >>> import pandas as pd
    >>> import pyarrow as pa
    >>> pl_frame = lf1
    >>> pd_frame = pd.DataFrame({"a": [2, 3, 4], "d": [-0.5, 0.0, 0.5]})
    >>> pa_table = pa.Table.from_arrays(
    ...     [pa.array([1, 2, 3]), pa.array(["x", "y", "z"])],
    ...     names=["a", "e"],
    ... )
    >>> pl.sql(
    ...     query='''
    ...         SELECT pl_frame.*, d, e
    ...         FROM pl_frame
    ...         JOIN pd_frame USING(a)
    ...         JOIN pa_table USING(a)
    ...     ''',
    ... ).collect()
    shape: (2, 5)
    โโโโโโโฌโโโโโโฌโโโโโโฌโโโโโโโฌโโโโโโ
    โ a   โ b   โ c   โ d    โ e   โ
    โ --- โ --- โ --- โ ---  โ --- โ
    โ i64 โ i64 โ str โ f64  โ str โ
    โโโโโโโชโโโโโโชโโโโโโชโโโโโโโชโโโโโโก
    โ 2   โ 7   โ y   โ -0.5 โ y   โ
    โ 3   โ 8   โ x   โ 0.0  โ z   โ
    โโโโโโโดโโโโโโดโโโโโโดโโโโโโโดโโโโโโ
    r   )ฺ
SQLContextr   )ฺ
polars.sqlr   ฺexecute_global)r   r
   r   s      r   r	   r	      s:    ๐b &ะ%ะ%ะ%ะ%ะ%เื$า$ุุ๐ %๑ ๔ ๐ r   N)r   r   r
   r   r   r   )r   r   r
   r   r   r   )r   r   r
   r   r   r   )ฺ
__future__r   ฺtypingr   r   r   ฺpolars.dataframer   ฺpolars.lazyframer   ฺ__all__r	   r   r   r   ๚<module>r"      sุ   ๐ุ "ะ "ะ "ะ "ะ "ะ "เ 3ะ 3ะ 3ะ 3ะ 3ะ 3ะ 3ะ 3ะ 3ะ 3เ๐ +ุ*ะ*ะ*ะ*ะ*ะ*ุ*ะ*ะ*ะ*ะ*ะ*๐ '๐ 
ุ/4ะ Gะ Gะ Gะ Gะ G๑ 
ุ G๐ 
ุ >ะ >ะ >๑ 
ุ >๐ &+๐ v๐ v๐ v๐ v๐ v๐ v๐ v๐ vr   