
    [i                    8   d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	 d dl
mZ d dlmZ erd dlmZ d dlmZ 	 d d	lZ ej.                         Z eej3                  d            Z G d de	ej6                           ZddZdgZy	# e$ rZd
Z ee      ed	Z[ww xY w)    )annotations)TYPE_CHECKINGLiteral)DeferredTimeZonenarwhals_to_native_dtype)	LazyFrame)from_native)Version)CompliantLazyFrameAny)
IntoSchemaNzY`narwhals.sql` requires DuckDB to be installed.

Hint: run `pip install -U narwhals[sql]`z;select value from duckdb_settings() where name = 'TimeZone'c                  >     e Zd ZdZ	 	 	 	 	 	 d fdZddddZ xZS )SQLTablez/A LazyFrame with an additional `to_sql` method.c                (    t         |   ||       y )Nlevel)super__init__)selfdfr   	__class__s      ]/var/www/html/userprofiledev.eatanceapp.com/venv/lib/python3.12/site-packages/narwhals/sql.pyr   zSQLTable.__init__    s     	5)    F)prettyc                   | j                         j                         }|s|S 	 ddl}|j                  |dd      S # t        $ r}d}t	        |      |d}~ww xY w)a4  Convert to SQL query.

        Arguments:
            pretty: Whether to pretty-print SQL query. If `True`, requires `sqlparse`
                to be installed.

        Examples:
            >>> import narwhals as nw
            >>> from narwhals.sql import table
            >>> schema = {"date": nw.Date, "price": nw.Int64, "symbol": nw.String}
            >>> assets = table("assets", schema)
            >>> result = assets.filter(nw.col("price") > 100)
            >>> print(result.to_sql())
            SELECT * FROM main.assets WHERE (price > 100)
        r   Nzr`SQLTable.to_sql` with `pretty=True`requires `sqlparse` to be installed.

Hint: run `pip install -U narwhals[sql]`Tupper)reindentkeyword_case)	to_native	sql_querysqlparseImportErrorModuleNotFoundErrorformat)r   r   r   r    _excmsgs         r   to_sqlzSQLTable.to_sql%   sl      NN$..0		5 y4gNN  	5; 
 &c*4	5s   < 	AAA)r   r   r   z&Literal['full', 'interchange', 'lazy']returnNone)r   boolr'   str)__name__
__module____qualname____doc__r   r&   __classcell__)r   s   @r   r   r      s4    9*'*0V*	*
 (- O Or   r   c           
        |j                         D ci c]%  \  }}|t        |t        j                  t              ' }}}dj                  d |j                         D              }t        j                  d|  d| d       t        t        j                  |             }t        |j                  |j                        S c c}}w )uP  Generate standalone LazyFrame which you can use to generate SQL.

    Note that this requires DuckDB to be installed.

    Parameters:
        name: Table name.
        schema: Table schema.

    Examples:
        >>> import narwhals as nw
        >>> from narwhals.sql import table
        >>> schema = {"date": nw.Date, "price": nw.List(nw.Int64), "symbol": nw.String}
        >>> table("t", schema)
        ┌────────────────────────────┐
        |     Narwhals LazyFrame     |
        |----------------------------|
        |┌──────┬─────────┬─────────┐|
        |│ date │  price  │ symbol  │|
        |│ date │ int64[] │ varchar │|
        |├──────┴─────────┴─────────┤|
        |│          0 rows          │|
        |└──────────────────────────┘|
        └────────────────────────────┘
    z, c              3  2   K   | ]  \  }}d | d|   yw)"z" N ).0coldtypes      r   	<genexpr>ztable.<locals>.<genexpr>a   s$     S<Rjc53%r%)<Rs   z
        CREATE TABLE "z"
        (z);
        r   )itemsr   r
   MAINTZjoinCONNsqlr	   tabler   _compliant_frame_level)nameschemar5   r6   column_mappingdtypeslfs          r   r>   r>   D   s    6 !,,.(JC 	%eW\\2>>(   YYSN<P<P<RSSFHH f 

 	  
TZZ%	&BB''ryy99s   *Cr>   )rA   r*   rB   r   r'   r   )
__future__r   typingr   r   narwhals._duckdb.utilsr   r   narwhals.dataframer   narwhals.translater	   narwhals.utilsr
   narwhals._compliant.typingr   narwhals.typingr   duckdbr!   r$   r%   r"   connectr<   r=   r:   DuckDBPyRelationr   r>   __all__r3   r   r   <module>rR      s    " ) M ( * "@*- v~~HHJK
$Oy001 $ON#:L )u  -	3  c
",-s   B B	BB