
    h                    b    d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
 d dlmZ  G d de
      Zy)	    )annotations)AnyIteratorOptionalSequence)Document)
BaseLoader)MaxComputeAPIWrapperc                  j    e Zd ZdZddd	 	 	 	 	 	 	 ddZeddd	 	 	 	 	 	 	 	 	 	 	 	 	 d	d       Zd
dZy)MaxComputeLoaderz+Load from `Alibaba Cloud MaxCompute` table.N)page_content_columnsmetadata_columnsc               <    || _         || _        || _        || _        y)a  Initialize Alibaba Cloud MaxCompute document loader.

        Args:
            query: SQL query to execute.
            api_wrapper: MaxCompute API wrapper.
            page_content_columns: The columns to write into the `page_content` of the
                Document. If unspecified, all columns will be written to `page_content`.
            metadata_columns: The columns to write into the `metadata` of the Document.
                If unspecified, all columns not added to `page_content` will be written.
        N)queryapi_wrapperr   r   )selfr   r   r   r   s        n/var/www/html/eduruby.in/venv/lib/python3.12/site-packages/langchain_community/document_loaders/max_compute.py__init__zMaxComputeLoader.__init__   s#    $ 
&$8! 0    	access_idsecret_access_keyc               H    t        j                  ||||      } | ||fi |S )a  Convenience constructor that builds the MaxCompute API wrapper from
            given parameters.

        Args:
            query: SQL query to execute.
            endpoint: MaxCompute endpoint.
            project: A project is a basic organizational unit of MaxCompute, which is
                similar to a database.
            access_id: MaxCompute access ID. Should be passed in directly or set as the
                environment variable `MAX_COMPUTE_ACCESS_ID`.
            secret_access_key: MaxCompute secret access key. Should be passed in
                directly or set as the environment variable
                `MAX_COMPUTE_SECRET_ACCESS_KEY`.
        r   )r
   from_params)clsr   endpointprojectr   r   kwargsr   s           r   r   zMaxComputeLoader.from_params%   s2    2 +66gFW
 5+000r   c              #  >  K   | j                   j                  | j                        D ]  }| j                  r3|j                         D ci c]  \  }}|| j                  v s|| }}}n|}dj	                  d |j                         D              }| j
                  r3|j                         D ci c]  \  }}|| j
                  v s|| }}}n(|j                         D ci c]  \  }}||vs|| }}}t        ||        y c c}}w c c}}w c c}}w w)N
c              3  0   K   | ]  \  }}| d |   yw)z: N ).0kvs      r   	<genexpr>z-MaxComputeLoader.lazy_load.<locals>.<genexpr>K   s     $WTQs"QC[$Ws   )page_contentmetadata)r   r   r   itemsjoinr   r   )r   rowr$   r%   page_content_datar'   r(   s          r   	lazy_loadzMaxComputeLoader.lazy_loadC   s    ##))$**5 	IC((%(YY[%!QA9R9R4RAqD%! % %(!99$W=N=T=T=V$WWL$$-0YY[WTQAAVAV<VAqDWW-0YY[WTQAEV<VAqDWWxHH	I% XWs=   AD
D!D&AD1DDD$D1D6'D)r   strr   r
   r   Optional[Sequence[str]]r   r/   )r   r.   r   r.   r   r.   r   Optional[str]r   r0   r   r   returnr   )r1   zIterator[Document])__name__
__module____qualname____doc__r   classmethodr   r-   r"   r   r   r   r      s    5 9=4811 *1
 61 21.  $(+/11 1 	1 !1 )1 1 
1 1:Ir   r   N)
__future__r   typingr   r   r   r   langchain_core.documentsr   )langchain_community.document_loaders.baser	   )langchain_community.utilities.max_computer
   r   r"   r   r   <module>r<      s'    " 4 4 - @ JEIz EIr   