Ë
    èlÖi$'  ã                   ó¦  — d dl Z d dlmZmZ d dlmZmZ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mZ d dlmZ d dlmZmZ d dlm Z m!Z! dee"   fd„Z# G d„ de"«      Z$dedee"ef   fd„Z%e G d„ de!«      «       Z&e G d„ de!«      «       Z'e G d„ de«      «       Z(e G d„ de(«      «       Z)dZ*e G d„ de(«      «       Z+y)é    N)Ú	dataclassÚfield)ÚAnyÚDictÚListÚOptionalÚUnion)ÚPattern)Ú	Annotated)Úhooks)ÚDocs)ÚModelHookType)Úvalidate_color)Ú
BaseConfigÚCompareBehaviorÚMergeBehavior)ÚOnConfigurationChangeOption)ÚMetadataÚShowBehavior)ÚValidationErrorÚdbtClassMixinÚreturnc                  ó   — g S ©N© r   ó    úf/var/www/html/strategist-ai/venv_dbt/lib/python3.12/site-packages/dbt/artifacts/resources/v1/config.pyÚlist_strr      s   € Ø€Ir   c                   ó   — e Zd Zy)ÚSeverityN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r    r       s   „ Ør   r    Úmetasc                  ó:   — i }| D ]  }|j                  |«      }Œ |S r   )Úmeta)r$   ÚexistingÚms      r   r$   r$      s)   € Ø!€HØò $ˆØ—6‘6˜(Ó#‰ð$à€Or   c                   ó*   — e Zd ZU dZeed<   dZeed<   y)ÚContractConfigFÚenforcedTÚalias_typesN)r!   r"   r#   r+   ÚboolÚ__annotations__r,   r   r   r   r*   r*   !   s   … à€HˆdÓØ€K�Ôr   r*   c                   ó:   — e Zd ZU eed<   dZeed<   dZee	   ed<   y)ÚHookÚsqlTÚtransactionNÚindex)
r!   r"   r#   Ústrr.   r2   r-   r3   r   Úintr   r   r   r0   r0   '   s   … à	ƒHØ€K�ÓØ€Eˆ8�C‰=Ôr   r0   c                   ó>  — e Zd ZU dZeed<    edej                  j                  «       ¬«      Z
ee   ed<    edej                  j                  «       ¬«      Zee   ed<    edej                  j                  «       ¬«      Zee   ed<    ee eej$                  ej(                  ej                  «      ¬«      Zeee   ef   ed	<    eeej2                  j                  «       ¬«      Z	eeef   ed
<    edej                  j                  «       ¬«      Zee   ed<   y)ÚNodeAndTestConfigTÚenabledN©ÚdefaultÚmetadataÚaliasÚschemaÚdatabase©Údefault_factoryr;   Útagsr&   Úgroup)r!   r"   r#   r8   r-   r.   r   r   ÚExcluder&   r<   r   r4   r=   r>   r   r$   r   ÚHider   ÚAppendrA   r	   r   ÚdictÚUpdater   r   rB   r   r   r   r7   r7   .   s-  … à€GˆTÓñ !ØØ ×(Ñ(×-Ñ-Ó/ô€Eˆ8�C‰=ó ñ "ØØ ×(Ñ(×-Ñ-Ó/ô€FˆH�S‰Mó ñ $ØØ ×(Ñ(×-Ñ-Ó/ô€Hˆh�s‰mó ñ #(Ø Ù�|×(Ñ(¨-×*>Ñ*>À×@WÑ@WÓXô#€Dˆ%��S‘	˜3�Ñ
ó ñ !ØØ×%Ñ%×*Ñ*Ó,ô€Dˆ$ˆs�Cˆx‰.ó ñ !ØØ ×(Ñ(×-Ñ-Ó/ô€Eˆ8�C‰=ô r   r7   c                   óª  ‡ — e Zd ZU dZeed<   dZee   ed<   dZe	ed<   dZ
e	ed<   dZe	ed<    ee¬	«      Zeee	f   ed
<    eeej$                  ddœ¬«      Zee   ed<    eeej$                  ddœ¬«      Zee   ed<    eeej.                  j1                  «       ¬«      Zeee	f   ed<    eeej.                  j1                  «       ¬«      Zeee	f   ed<   dZee   ed<   dZeeee   df   ed<   dZee   ed<    ee jB                  ¬	«      Z"e ed<    eeejF                  j1                  «       ¬«      Z$eee	f   ed<    eeej$                  j1                  «       ¬«      Z%ee   ed<    ee&ej.                  j1                  «       ¬«      Z'e&ed<    ee(ej.                  j1                  «       ¬«      Z)e(ed<   dZ*e	ed<   dZ+e	ed<   d„ Z,e-ˆ fd„«       Z.ˆ xZ/S ) Ú
NodeConfigÚviewÚmaterializedNÚincremental_strategyÚ
batch_sizeé   ÚlookbackÚbegin)r@   Úpersist_docsz	post-hook)Úmerger<   r?   Ú	post_hookzpre-hookÚpre_hookÚquotingÚcolumn_typesÚfull_refreshÚ
unique_keyÚignoreÚon_schema_changeÚon_configuration_changeÚgrantsÚpackagesÚdocsÚcontractÚ
event_timeÚconcurrent_batchesc                 ó,  — | j                   j                  r0| j                   j                  }t        |«      st        d|› d�«      ‚| j                  j
                  r8| j                  dk(  r(| j                  dvrt        d| j                  › d�«      ‚y y y )Nz(Invalid color name for docs.node_color: z=. It is neither a valid HTML color name nor a valid HEX code.Úincremental)Úappend_new_columnsÚfailz$Invalid value for on_schema_change: zw. Models materialized as incremental with contracts enabled must set on_schema_change to 'append_new_columns' or 'fail')r^   Ú
node_colorr   r   r_   r+   rK   rZ   )Úselfrf   s     r   Ú__post_init__zNodeConfig.__post_init__ƒ   s«   € à�9‰9×ÒØŸ™×-Ñ-ˆJÜ! *Ô-Ü%Ø>¸z¸lð KRð Róð ð �M‰M×"Ò"Ø×!Ñ! ]Ò2Ø×%Ñ%Ð-KÑKä!Ø6°t×7LÑ7LÐ6Mð NEð Eóð ð Lð 3ð #r   c                 ó¢   •— t         ‰| �  |«      }t        D ]0  }||v sŒ||   D �cg c]  }t        j                  |«      ‘Œ c}||<   Œ2 |S c c}w r   )ÚsuperÚ__pre_deserialize__r   r   Úget_hook_dict)ÚclsÚdataÚkeyÚhÚ	__class__s       €r   rk   zNodeConfig.__pre_deserialize__˜   sZ   ø€ ä‰wÑ*¨4Ó0ˆÜ ò 	HˆCØ�dŠ{Ø=AÀ#¹YÖG¸œU×0Ñ0°Õ3ÒG��S’	ð	Hð ˆùò Hs   ¦A)0r!   r"   r#   rK   r4   r.   rL   r   rM   r   rO   rP   r   rF   rQ   r   Úlistr   rE   rS   r   r0   rT   rG   r&   rU   rV   rW   r-   rX   r	   rZ   r   r:   r[   ÚDictKeyAppendr\   r]   r   r^   r*   r_   r`   ra   rh   Úclassmethodrk   Ú__classcell__©rq   s   @r   rI   rI   M   s3  ø… ð €L�#ÓØ*.Ð˜( 3™-Ó.Ø€J�ÓØ€HˆcÓØ€Eˆ3ÓÙ#(¸Ô#>€L�$�s˜C�x‘.Ó>Ù!ØØ(×/Ñ/¸+ÑFô€Iˆt�D‰zó ñ !ØØ(×/Ñ/¸*ÑEô€Hˆd�4‰jó ñ $ØØ×%Ñ%×*Ñ*Ó,ô€GˆT�#�s�(‰^ó ñ $)ØØ×%Ñ%×*Ñ*Ó,ô$€L�$�s˜C�x‘.ó ð $(€L�(˜4‘.Ó'ð /3€J��c˜4 ™9 dÐ*Ñ+Ó2Ø&.Ð�h˜s‘mÓ.Ù;@Ø3×;Ñ;ô<ÐÐ8ó ñ #Ø }×'BÑ'B×'GÑ'GÓ'Iô€FˆD��c�‰Nó ñ  ØØ×%Ñ%×*Ñ*Ó,ô€Hˆd�3‰ió ñ ØØ×%Ñ%×*Ñ*Ó,ô€Dˆ$ó ñ  %Ø&Ø×%Ñ%×*Ñ*Ó,ô €Hˆnó ð €J�ÓØ"Ð˜Ó"òð* óó ôr   rI   z)^([Ww][Aa][Rr][Nn]|[Ee][Rr][Rr][Oo][Rr])$c                   óv  ‡ — e Zd ZU dZ edej                  j                  «       ¬«      Ze	e
   ed<   dZe
ed<    ed«      Zee ee«      f   ed<   d	Ze	e   ed
<   d	Ze	e
   ed<   d	Ze	e
   ed<   d	Ze	e   ed<   dZe
ed<   dZe
ed<   dZe
ed<   ˆ fd„Zedee
ef   dee
ef   defd„«       Zeˆ fd„«       Z ˆ xZ!S )Ú
TestConfigFÚdbt_test__auditr9   r=   ÚtestrK   ÚERRORÚseverityNÚstore_failuresÚstore_failures_asÚwhereÚlimitzcount(*)Ú	fail_calcz!= 0Úwarn_ifÚerror_ifc                 óÂ   •— t         ‰| �  «        ddddœ}ddddœ}| j                  €|| j                     | _        | S |j	                  | j                  d«      | _        | S )a|  
        The presence of a setting for `store_failures_as` overrides any existing setting for `store_failures`,
        regardless of level of granularity. If `store_failures_as` is not set, then `store_failures` takes effect.
        At the time of implementation, `store_failures = True` would always create a table; the user could not
        configure this. Hence, if `store_failures = True` and `store_failures_as` is not specified, then it
        should be set to "table" to mimic the existing functionality.

        A side effect of this overriding functionality is that `store_failures_as="view"` at the project
        level cannot be turned off at the model level without setting both `store_failures_as` and
        `store_failures`. The former would cascade down and override `store_failures=False`. The proposal
        is to include "ephemeral" as a value for `store_failures_as`, which effectively sets
        `store_failures=False`.

        The exception handling for this is tricky. If we raise an exception here, the entire run fails at
        parse time. We would rather well-formed models run successfully, leaving only exceptions to be rerun
        if necessary. Hence, the exception needs to be raised in the test materialization. In order to do so,
        we need to make sure that we go down the `store_failures = True` route with the invalid setting for
        `store_failures_as`. This results in the `.get()` defaulted to `True` below, instead of a normal
        dictionary lookup as is done in the `if` block. Refer to the test materialization for the
        exception that is raise as a result of an invalid value.

        The intention of this block is to behave as if `store_failures_as` is the only setting,
        but still allow for backwards compatibility for `store_failures`.
        See https://github.com/dbt-labs/dbt-core/issues/6914 for more information.
        ÚtableÚ	ephemeralN)TFNFT)r†   r…   rJ   )rj   Úfinalize_and_validater~   r}   Úget)rg   Úget_store_failures_as_mapÚget_store_failures_maprq   s      €r   r‡   z TestConfig.finalize_and_validate¸   s�   ø€ ô4 	‰Ñ%Ô'ð
 ØØñ%
Ð!ð ØØñ"
Ðð ×!Ñ!Ð)Ø%>¸t×?RÑ?RÑ%SˆDÔ"ð ˆð #9×"<Ñ"<¸T×=SÑ=SÐUYÓ"ZˆDÔàˆr   Ú
unrenderedÚotherr   c                 óª   — g d¢}t        «       }| j                  «       D ]2  \  }}|}|j                  |«       ||v sŒ| j                  |||«      rŒ2 y y)z@This is like __eq__, except it explicitly checks certain fields.)r|   r   r€   r�   r‚   rƒ   r}   r~   FT)ÚsetÚ_get_fieldsÚaddÚcompare_key)rm   r‹   rŒ   Ú	modifiersÚseenÚ_Útarget_namero   s           r   Úsame_contentszTestConfig.same_contentsë   s\   € ò	
ˆ	ô ‹uˆØ!Ÿo™oÓ/ò 	!‰NˆAˆ{ØˆCØ�H‰H�SŒMØ�iÒØ—‘ z°5¸#Õ>Ù ð	!ð r   c                 ó6  •— |j                  d«      rGt        j                  t        |j                  d«      «      st	        d|j                  d«      › d�«      ‚t
        ‰| �  |«       |j                  d«      r |j                  d«      dk7  rt	        d«      ‚y y )Nr|   z0Severity must be either 'warn' or 'error'. Got 'ú'rK   rz   z/A test must have a materialized value of 'test')rˆ   ÚreÚmatchÚSEVERITY_PATTERNr   rj   Úvalidate)rm   rn   rq   s     €r   rœ   zTestConfig.validate  sŠ   ø€ à�8‰8�JÔ¬¯©Ô1AÀ4Ç8Á8ÈJÓCWÔ(XÜ!ØBÀ4Ç8Á8ÈJÓCWÐBXÐXYÐZóð ô 	‰Ñ˜Ôà�8‰8�NÔ#¨¯©°Ó(@ÀFÒ(JÜ!Ð"SÓTÐTð )KÐ#r   )"r!   r"   r#   Ú__test__r   r   rC   r&   r=   r   r4   r.   rK   r    r|   r   r
   r›   r}   r-   r~   r   r€   r5   r�   r‚   rƒ   r‡   rt   r   r   r–   rœ   ru   rv   s   @r   rx   rx   ¤   s  ø… à€Hñ "Ø!Ø ×(Ñ(×-Ñ-Ó/ô€FˆH�S‰Mó ð €L�#Óá?GÈÓ?P€Hˆi˜¡'Ð*:Ó";Ð;Ñ<ÓPØ%)€N�H˜T‘NÓ)Ø'+Ð�x ‘}Ó+Ø€Eˆ8�C‰=ÓØ€Eˆ8�C‰=ÓØ€IˆsÓØ€GˆSÓØ€HˆcÓô1ðf ð t¨C°¨H¡~ð ¸dÀ3ÈÀ8¹nð ÐQUò ó ðð, ó	Uó ô	Ur   rx   ),r™   Údataclassesr   r   Útypingr   r   r   r   r	   Ú mashumaro.jsonschema.annotationsr
   Útyping_extensionsr   Údbtr   Údbt.artifacts.resources.baser   Údbt.artifacts.resources.typesr   Údbt.artifacts.utils.validationr   Ú dbt_common.contracts.config.baser   r   r   Ú+dbt_common.contracts.config.materializationr   Ú$dbt_common.contracts.config.metadatar   r   Údbt_common.dataclass_schemar   r   r4   r   r    r$   r*   r0   r7   rI   r›   rx   r   r   r   ú<module>rª      s  ðÛ 	ß (ß 3Õ 3å 4Ý 'å Ý -Ý 7Ý 9ß WÑ WÝ Sß Gß Fð�$�s‘)ó ô	ˆsô 	ð�(ð ˜t C¨ H™~ó ð ô�]ó ó ðð
 ô ˆ=ó  ó ð ð ô˜
ó ó ðð< ôPÐ"ó Pó ðPðf @Ð ð ôgUÐ"ó gUó ñgUr   