From b8b276b825d91aee87f4c725a1e97986d4807da3 Mon Sep 17 00:00:00 2001 From: bmtcril Date: Mon, 29 Jan 2024 17:33:06 +0000 Subject: [PATCH] docs: update docs for 04939b536dcead002762a8255d621482df30aaa8 --- catalog.json | 2 +- .../models/base/xapi_events_all_parsed.sql | 22 +++++++++--------- .../models/completion/completion_events.sql | 2 +- .../models/enrollment/enrollment_events.sql | 2 +- .../aspects/models/forum/forum_events.sql | 2 +- .../aspects/models/grading/grading_events.sql | 2 +- .../models/navigation/navigation_events.sql | 6 ++--- .../models/problems/problem_events.sql | 10 ++++---- .../models/video/video_playback_events.sql | 2 +- .../models/video/video_transcript_events.sql | 4 ++-- graph.gpickle | Bin 53465 -> 53051 bytes graph_summary.json | 2 +- manifest.json | 2 +- partial_parse.msgpack | Bin 701798 -> 701676 bytes run_results.json | 2 +- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/catalog.json b/catalog.json index 841c194c..8db1d0f4 100644 --- a/catalog.json +++ b/catalog.json @@ -1 +1 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "1.7.0", "generated_at": "2024-01-12T21:21:42.744492Z", "invocation_id": "a795bd6c-4581-43fe-b9ab-e6fb93378742", "env": {}}, "nodes": {}, "sources": {}, "errors": null} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "1.7.0", "generated_at": "2024-01-29T17:33:05.561716Z", "invocation_id": "23109c69-1db3-40c3-b53f-036608b155d3", "env": {}}, "nodes": {}, "sources": {}, "errors": null} \ No newline at end of file diff --git a/compiled/aspects/models/base/xapi_events_all_parsed.sql b/compiled/aspects/models/base/xapi_events_all_parsed.sql index 7fd91426..d1d551b8 100644 --- a/compiled/aspects/models/base/xapi_events_all_parsed.sql +++ b/compiled/aspects/models/base/xapi_events_all_parsed.sql @@ -2,34 +2,34 @@ SELECT event_id as event_id, - JSON_VALUE(event_str, '$.verb.id') as verb_id, + JSON_VALUE(event::String, '$.verb.id') as verb_id, COALESCE( - NULLIF(JSON_VALUE(event_str, '$.actor.account.name'), ''), - NULLIF(JSON_VALUE(event_str, '$.actor.mbox'), ''), - JSON_VALUE(event_str, '$.actor.mbox_sha1sum') + NULLIF(JSON_VALUE(event::String, '$.actor.account.name'), ''), + NULLIF(JSON_VALUE(event::String, '$.actor.mbox'), ''), + JSON_VALUE(event::String, '$.actor.mbox_sha1sum') ) as actor_id, - JSON_VALUE(event_str, '$.object.id') as object_id, + JSON_VALUE(event::String, '$.object.id') as object_id, -- If the contextActivities parent is a course, use that. It can be a "course" -- type, or a "cmi.interaction" type for multiple question problem submissions. -- Otherwise use the object id for the course id. multiIf( -- If the contextActivities parent is a course, use that JSON_VALUE( - event_str, + event::String, '$.context.contextActivities.parent[0].definition.type' ) = 'http://adlnet.gov/expapi/activities/course', - JSON_VALUE(event_str, '$.context.contextActivities.parent[0].id'), + JSON_VALUE(event::String, '$.context.contextActivities.parent[0].id'), -- Else if the contextActivities parent is a GroupActivity, it's a multi -- question problem and we use the grouping id JSON_VALUE( - event_str, + event::String, '$.context.contextActivities.parent[0].objectType' ) in ('Activity', 'GroupActivity'), - JSON_VALUE(event_str, '$.context.contextActivities.grouping[0].id'), + JSON_VALUE(event::String, '$.context.contextActivities.grouping[0].id'), -- Otherwise use the object id - JSON_VALUE(event_str, '$.object.id') + JSON_VALUE(event::String, '$.object.id') ) as course_id, coalesce(get_org_from_course_url(course_id), '') as org, emission_time as emission_time, - event_str as event_str + event::String as event FROM `xapi`.`xapi_events_all` \ No newline at end of file diff --git a/compiled/aspects/models/completion/completion_events.sql b/compiled/aspects/models/completion/completion_events.sql index f48593af..a57dd2cc 100644 --- a/compiled/aspects/models/completion/completion_events.sql +++ b/compiled/aspects/models/completion/completion_events.sql @@ -8,6 +8,6 @@ SELECT splitByString('/', course_id)[-1] AS course_key, org, verb_id, - JSON_VALUE(event_str, '$.result.extensions."https://w3id.org/xapi/cmi5/result/extensions/progress"') AS progress_percent + JSON_VALUE(event, '$.result.extensions."https://w3id.org/xapi/cmi5/result/extensions/progress"') AS progress_percent FROM `xapi`.`xapi_events_all_parsed` WHERE verb_id = 'http://adlnet.gov/expapi/verbs/progressed' \ No newline at end of file diff --git a/compiled/aspects/models/enrollment/enrollment_events.sql b/compiled/aspects/models/enrollment/enrollment_events.sql index 054dbe16..395a6a38 100644 --- a/compiled/aspects/models/enrollment/enrollment_events.sql +++ b/compiled/aspects/models/enrollment/enrollment_events.sql @@ -8,7 +8,7 @@ SELECT splitByString('/', course_id)[-1] AS course_key, org, verb_id, - JSON_VALUE(event_str, '$.object.definition.extensions."https://w3id.org/xapi/acrossx/extensions/type"') AS enrollment_mode + JSON_VALUE(event, '$.object.definition.extensions."https://w3id.org/xapi/acrossx/extensions/type"') AS enrollment_mode FROM `xapi`.`xapi_events_all_parsed` WHERE verb_id IN ( 'http://adlnet.gov/expapi/verbs/registered', diff --git a/compiled/aspects/models/forum/forum_events.sql b/compiled/aspects/models/forum/forum_events.sql index a4383469..d38517a5 100644 --- a/compiled/aspects/models/forum/forum_events.sql +++ b/compiled/aspects/models/forum/forum_events.sql @@ -9,4 +9,4 @@ SELECT actor_id, verb_id FROM `xapi`.`xapi_events_all_parsed` -WHERE JSON_VALUE(event_str, '$.object.definition.type') = 'http://id.tincanapi.com/activitytype/discussion' \ No newline at end of file +WHERE JSON_VALUE(event, '$.object.definition.type') = 'http://id.tincanapi.com/activitytype/discussion' \ No newline at end of file diff --git a/compiled/aspects/models/grading/grading_events.sql b/compiled/aspects/models/grading/grading_events.sql index d8c2b812..c36c2d69 100644 --- a/compiled/aspects/models/grading/grading_events.sql +++ b/compiled/aspects/models/grading/grading_events.sql @@ -9,6 +9,6 @@ SELECT splitByString('/', course_id)[-1] AS course_key, org, verb_id, - JSONExtractFloat(event_str, 'result', 'score', 'scaled') AS scaled_score + JSONExtractFloat(event, 'result', 'score', 'scaled') AS scaled_score FROM `xapi`.`xapi_events_all_parsed` WHERE verb_id IN ('http://id.tincanapi.com/verb/earned', 'https://w3id.org/xapi/acrossx/verbs/evaluated') \ No newline at end of file diff --git a/compiled/aspects/models/navigation/navigation_events.sql b/compiled/aspects/models/navigation/navigation_events.sql index 144f63a4..eec1f125 100644 --- a/compiled/aspects/models/navigation/navigation_events.sql +++ b/compiled/aspects/models/navigation/navigation_events.sql @@ -8,7 +8,7 @@ SELECT splitByString('/', course_id)[-1] AS course_key, org, verb_id, - JSONExtractString(event_str, 'object', 'definition', 'type') AS object_type, + JSONExtractString(event, 'object', 'definition', 'type') AS object_type, -- clicking a link and selecting a module outline have no starting-position field if ( object_type in ( @@ -17,12 +17,12 @@ SELECT ), 0, JSONExtractInt( - event_str, + event, 'context', 'extensions', 'http://id.tincanapi.com/extension/starting-position' ) ) AS starting_position, JSONExtractString( - event_str, + event, 'context', 'extensions', 'http://id.tincanapi.com/extension/ending-point' ) AS ending_point FROM diff --git a/compiled/aspects/models/problems/problem_events.sql b/compiled/aspects/models/problems/problem_events.sql index 95b404d3..e839d18e 100644 --- a/compiled/aspects/models/problems/problem_events.sql +++ b/compiled/aspects/models/problems/problem_events.sql @@ -8,17 +8,17 @@ SELECT splitByString('/', course_id)[-1] AS course_key, org, verb_id, - JSON_VALUE(event_str, '$.result.response') as responses, - JSON_VALUE(event_str, '$.result.score.scaled') as scaled_score, + JSON_VALUE(event, '$.result.response') as responses, + JSON_VALUE(event, '$.result.score.scaled') as scaled_score, if( verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated', - cast(JSON_VALUE(event_str, '$.result.success') as Bool), + cast(JSON_VALUE(event, '$.result.success') as Bool), false ) as success, - JSON_VALUE(event_str, '$.object.definition.interactionType') as interaction_type, + JSON_VALUE(event, '$.object.definition.interactionType') as interaction_type, if( verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated', - cast(JSON_VALUE(event_str, '$.object.definition.extensions."http://id.tincanapi.com/extension/attempt-id"') as Int16), + cast(JSON_VALUE(event, '$.object.definition.extensions."http://id.tincanapi.com/extension/attempt-id"') as Int16), 0 ) as attempts FROM diff --git a/compiled/aspects/models/video/video_playback_events.sql b/compiled/aspects/models/video/video_playback_events.sql index 060c9379..908c28a1 100644 --- a/compiled/aspects/models/video/video_playback_events.sql +++ b/compiled/aspects/models/video/video_playback_events.sql @@ -8,6 +8,6 @@ SELECT splitByString('/', course_id)[-1] AS course_key, org, verb_id, - ceil(CAST(coalesce(nullIf(JSON_VALUE(event_str, '$.result.extensions."https://w3id.org/xapi/video/extensions/time"'), ''), nullIf(JSON_VALUE(event_str, '$.result.extensions."https://w3id.org/xapi/video/extensions/time-from"'), ''), '0.0'), 'Decimal32(2)')) AS video_position + ceil(CAST(coalesce(nullIf(JSON_VALUE(event, '$.result.extensions."https://w3id.org/xapi/video/extensions/time"'), ''), nullIf(JSON_VALUE(event, '$.result.extensions."https://w3id.org/xapi/video/extensions/time-from"'), ''), '0.0'), 'Decimal32(2)')) AS video_position FROM `xapi`.`xapi_events_all_parsed` WHERE (verb_id IN ('http://adlnet.gov/expapi/verbs/completed', 'http://adlnet.gov/expapi/verbs/initialized', 'http://adlnet.gov/expapi/verbs/terminated', 'https://w3id.org/xapi/video/verbs/paused', 'https://w3id.org/xapi/video/verbs/played', 'https://w3id.org/xapi/video/verbs/seeked')) AND (object_id LIKE '%video+block%') \ No newline at end of file diff --git a/compiled/aspects/models/video/video_transcript_events.sql b/compiled/aspects/models/video/video_transcript_events.sql index d56a4ea3..e3c1bdf9 100644 --- a/compiled/aspects/models/video/video_transcript_events.sql +++ b/compiled/aspects/models/video/video_transcript_events.sql @@ -7,8 +7,8 @@ SELECT splitByString('/', course_id)[-1] AS course_key, splitByString('/xblock/', object_id)[2] as video_id, actor_id, - JSONExtractBool(event_str, 'result','extensions','https://w3id.org/xapi/video/extensions/cc-enabled') as cc_enabled + JSONExtractBool(event, 'result','extensions','https://w3id.org/xapi/video/extensions/cc-enabled') as cc_enabled FROM `xapi`.`xapi_events_all_parsed` WHERE verb_id IN ('http://adlnet.gov/expapi/verbs/interacted') - AND JSONHas(event_str, 'result', 'extensions', 'https://w3id.org/xapi/video/extensions/cc-enabled') \ No newline at end of file + AND JSONHas(event, 'result', 'extensions', 'https://w3id.org/xapi/video/extensions/cc-enabled') \ No newline at end of file diff --git a/graph.gpickle b/graph.gpickle index 3727a5e987d7d7e55a43044513308f20c5e67bb3..cec4a94bbb07b974a05d52451de919be68ab9fe7 100644 GIT binary patch delta 13712 zcmd5@d3aP+mbYH25|Th5gzSN=K(Pd>UhOPRP$M7)f&_>H39nwg;^mrDg;WYf#E9(@ z#^-uUKA~+eGitz|`4BR;YbzouixHfj>94yp(xx3hyQf{C(QdzXn{)4bwWbWTOq}_H zy1DnBd*8X|{LXUEd;F#+<;6WIhT9Aen@$}x9Od9+ZhLy$7Y*~9MhBIdu+&fvkEE2R zTq|cm4WA3|q)at7$R%>UJaK)JPtw-As*^0o3xNiM^tT&|KU@!w>5C6wuB>efM> zzDg&+*wi9W^ck>8p9A~#S+En^6Z#5xRzDuT(WmCuZVSoI^&xpNwpVut=!F`7va z521{16FQ}i7JS;xk|(5O$99`Hw@5c4Njs#E`XF6Nm3$jpd{PMBD=LAt<3_{udlzLX zne81dZ9>PE<{P9fA=rHHl&&Kvo1@(UWt2zqN*x`z?GCCSW5ToKrx_zB<+tQh@@ctW zemf{@BAWQex0G?B-{)=F*enXIt<9bmu`@)uKagxyol>;nCZWA$!>kRGuLEY>H*SnF zszbQ3Swy*p8sCTPlIQ!rxX-BTt9l?+2RDvc2+E|=(MnptAM6mNKxlmkMrRo(7qkgt zhkuq3XqUv!z^si@XR~%>K{5DnFGhJ?*3?2FD8EkGd2@$+tUD+lmrqbM1m*K^Th=sP z4?LB%io=e6?6j_4`LFUmN}DA=C8HkQqQmCp9d;Y<6$P7Dvb#+#3vZWfqFeOvc9YBM zvhxm?)njtH-ICR2c3bUsv&Cughz_$u@+Q|K6U;#reBXK|r$L2ZUf-~!ZV4P6yTJAg zB6SK*K8OEakYAKvl7At;jDH`-aZOu8&U2EgSugi1^I+!qd0ip-6d9|#?6M$34mAN2 zZh#1iZ15kdmZK^nSxB!fll$3fCB5Ar=&Y9g{u@x}#DD}SN=@sf_g*3YI!?*a9rAD| zbqkVmx=0V6&3z<2yxmNw$v46+d3~|dHjwk{<47jKK>ms-iK*cJ?C=g{LZD3A zEcrU&biwSZcjfox|3c~iVLi&hi1s*E66F8Jfsd#FKA~f0VOe2GfqV`J(}&^>Zgmzx z=#JS4wxf5f=Bjj1eQ=}eM>`28@i19(~Ed=IVw#_RrM2fpYjfR z(yUMd06Q|&8c?CG`F5;SWu=4Kt)zPgY z&N~>3VI`wo=oIB<{FOtnX@3s9a(BL-0vkR_D=-DZNHteqN0Evlr!eez5=FitBoFje zbid1GYN|%^ELf;a&<6zh571RrIU`QrRL@2XOM9ebt_7Y=F&%X8p4ru_Wc!58EgOZ-7Qe5V z`HeU$R%%QR(JV=J(QdK0Og5LzW%jtN7Kc^vnj9v(MRZtgHj{)&fZgeFT1|F`+bjyA zQ?fXCr;X=5!^V-hERcL3FCeqH!O8vb@J}$CIR)o_vOSZDT+s)EEgm>kmJ9bkx}ZxP z8-?yd>ZC3rqESLEoGFa`6{lAvHNd=k3^m1vN<9=Qf2P<8r)lxv9D{C8MFJ(F{z>JC z#H~@%HcK7u<`z##eT0rnbUyLqnSM9H+(Gq!>XOt8EXfXZ3LTv^Vii0*j?3g=`on^O zaR&E3JcS$2!NNVOHPFUAEY5SOprsyb{?7bWLqqZJs3cC2LE7|__pphC-MP(QCWhT) z)OAp|cM`_h(FTmQ&-G1xY_qPfr{{VdeEW~R@YFvIULND;rMrafjf{^FeIF3#Cph05Khm7<4LeJ81AW~)2RH+R9QbzG9YfJZ<0(0Y z%46~JyBx6Lkm`U}9HI_bKGewV;NZw1bim{udYEY5q|`WV4yS|n*qvUx+hw-81gAr= zd#!e_$0gX^qT9qN(nFhm@)$M|Pf+$glktV9W3F4GzpcF${dXir(X^+r zkLw#>(y4>P;!V(2I}1Mh`A_Fwf_Gr4?l+IqRCm@BtGPZ7?s{TIB+ZSo5Emff^b;fE z7<&8#aLbc^%|m}wRs_4!$7#NSrmPY8$A_DUZ-}Q!?i-S&zI9WJb?-x0@4VQ2c>mOi zd4Hse)JhVnsj}t2nmQx4%|on?_7c;KOy z4hI+I!hr?@q?XP{3|(1zJy((fkCj&Idf{McQC$9fzH~%Tb9Y&dhM41J<(dXhBeOK` z7$NXzfh7)aO1hSxL=u|iDap_i0r3T~5~ZZ6ks1=zBx#0PB~u}}Hr6tdBrfF@lN0^@ zhvPJVzrLah{r&9~ztT;Lph3=3Mtl7o!M1Q}9KKXdh)+4xOBMV>;lz@mxS+fTi4P@! zrMS}c9(lZ6AQvimaIUZbJ}j)_d?_%dr~*Sl2bEH6D6mLYT885#w_r9qOfKH+bn)o& z-4?suB6;j4kHzkAdPEV+a-wKlEpxO+UFCn@A`q z-}gphQkaaoPRWg2fMe9bqJV^e*t)f>FTW(4gPD_7*2HMHJL=0-6{zdJ8u@fPKVuW^J1A4uSagY zNm)!-X>)sQR+ri7F`Ib7A&sb(XlZRVnCz=lu(U>F_WE!oZfN%Yw5q5>s-h0YDym}K zibO>vqppJ=*@{yJ8V~nnm*nWcZ~qkBj@K?dXD?(q`}wNLsF1?RS8+$FLMn@Tl}whj zZ|o3g)ilO-V9(?c@vu)Xp8!`)>HcASYiTslMjhb$5eLZPbTa=-Xs}kDWb&{b-Hpa> zm2yZFC+Bc3LaAghA;(@hFVo{ZTwyG?s(i-LU(lt){l-aLh8_+WYc*+ph0l9v+9YnA z9?GUE7a91EO`B?p5B&2+Z`K0;gox9ig-R79EasO^{~%4v>c{eh92UxkiT1nE4u*Pl zII(dlf-z5S;HvddzbY5D%emRTWHuE_)Q3Z_T-)`(Un#p#c|2T8syI+8|5{H=h|tq8mdN&wKG@g&<*UbJ$!Khs%MlDg@Cg zSS1T@7Vx@b=6TU-=Xr~HWZfmb-((BT+Wlr2U)e^Fb&B|D(@%WZM1or7+qWnB%4F1a zQ0OkkN=La`={W0Ntb=(T7i{r_AX{pH7U@Z-dSGhb9Ir!n=^nHk-q~0L_jab~LeO;c z6x7t6H#c(IRZV?%b3Q`%$MKqilCA%j(5=kd5{B;J)-r@Hcgw$rjdt+IO}Pn3#VQbH zVX(JhYRPvLe#p=8eDFpCeQ|cSp^5t$J^O4-&Tm^)lo4aGkFOe$$l+YQQuA|Hprwsq zMy@@DU9mFOl;jOiwGO?x+1E@ee=q4&)aMsL_Dx0bqq%A8KNz0!g5Ey5XL^SeX!rX9 z7_YU!qldvYTVlCxYAobF)5Dg=@NMSB#&YgUJ)CK@7}cAiVTrHPY>$>_ljQoO!&sgW z7~a~i1%}daU;y2!JUt5uJFjyaRz)2nI>b6W@-VIu-z%;}3RY}1qW}BO3K0CRO+d&k z^bsz{z#QWdUm3#gRbOe`op6kQL~z&R|IrWhP9-h zP^mF{@s{d#Sxg?g)#SzUgV$pnS+vUf%ch6?z@kpRa($wdH+nwSUrGQW3g**-BJNaM^0^a|84*n}HU3W?4a8peR{B zA}0Fua`A^T(WG&LnxyK}lN)E$%&3K`l*w&1N=Xe?rHnJ(WtS2sF3xrrp3`i1^NI?z z-CZkg3BN@uYnYdp#9Y^hjPUbC#`0k=Sy!fF;&^5ewb}H=*K=2n_SM4NuH9-FA;{DsDE)ynxgNN0-YiF=NDJ%+8=sp8eXV6;`IV^ zUaC!1YXMOA{G^lvBmlnWZ`F0ft1so2#+T*77x?LC<})M>^nL!)ExI&~QFvub@w6nb zzVQac!hie?2tIjsqk#mF8Cdt6sM`&PpEDzOk0x-(Jzsmd${l{XNw(72$ah<8HMteX z$Q|_OPWp2f{kfa|bkm<5?5|VrPp*o7!rDvT#3h#~j@b#SRX2@%9;9FHvC_;GTAE2zH>^H#^bFClW6>VnEb8RKnfmFP#as(_Sy z_7QMkR>Fs5FnA;fKZ!<&yz{b~BhSLQW5xOxa2F6?F=eUyv3g$*et%76d*T&0%C`D& z8#kDWwb+~t@{uOoc_`cx`0CZNb>V_6IZlO`AlP$s?9y;%9wJz}X+*H|CV4f%s>1_H zH>^0h4&FXIwX0%U**27Itd!rtI^Pf}qhBV!#ZAco{zy#RN0Ba>xT$!^86;E2$I4i% zO_TTNE_7{BsqKWXjw~@giz6&NDWiP;&Sqb*wKYVj%yCeaIK7kL=Xh8O9Uf`kyDU+X2jCZPTH;`u)QVyK>k})P+=d!*^pNBX ztT;A3jmZcv$?v>ge-YB5moX-tI@tM!1toOijfLr1C>gngOwj~2Qxge6I|cnT`|X2C;PIVBxIeSTXgAlFk6(N8$H zg-9PO@-y&l!_dB!PElLOsd$PKgeMMClv2Vy__sGFL5&&h=@gtOHthgLc7KjA6=Xq`N=+pr?Wyef!7$VG z%1u|R(?+tJZB9~ApSZ~s)&#>x(}bfQG(gmoYO>OL0r~{GRNF|EoW`@dZC7Mp#n2oG zieiY=;&ZUmPX8+e)fUA9!hq_VYEC{+Rv`sbrJPO{(Z4m-;1|K94*T*RvJ#tMSVeL@ zSwe@ml4WdI)je*sI<1SYR@I{7jBG#>^-Cx(BUS-|#A~n{){zmnyc+ws<#I|-iAW2h zSM^0%si!kki=>Uss0ziM8nLS>6#u8dd2$`=tD2=dFU3BtUx5u%JMrURK~0$&n*yC= z<+>o7R3VF-U60*>rfH^FvXzafz|>Z|!>hZ~ydq9K&6x|NNnU}Z=qU34TEbkF)9R_^f~ delta 14290 zcmc&*dwdjCmbN?TJjjEDB!na#@*<%L5c>TFzxF5!^r0 zb?ertTlb#x-S3=x?#;<3qCR>mO4X@)^u70ws?ICZ#CWcqYw^^(J#GGVehr_@&w{d; z(eR$~{usV-*`|tOSP)gISPDOlnyy*KtNCg^w+`jTh|zY&&H4GId@aZ4dR;G9L%2!BNry z8`t^8#Ae3BwKd?o_i_%u7!6;?{t50cD4+S5WRS=BGE^&(jCU{|rrxu*mGg@+i#=@( zEvx;!8TE#`^YV?7cw<1Ezs!FKS1PijrNV^liKGye7vpHx>Kh!g8omg7amxJc(P8qu zS8Cr2&lP?$KJ1Z~^p1ZM|K8r>7Du!)9+t1iU)~Rgii(ztaSqPOwYA~swo=o|s(hgN zZ83#)wKyAA*RxDhQ@x{s^yfcjB8^$P`wV$->n+=jRHm_ zRg4g0-KcMtbNhFeq{ErHBVj^GD(sq@q2QoBNmHz9L3y{o4praDS94ze9Wt7CxAO08 z@$wh>_la7(a4u;)L?us99DvEm)hZ!damy{RA$fwYOHgBxKO$-11^$RwZqwQ9CWf=I ztU<50GFlsFWDTs|Y%^;e7K7PoGC7TAvyL<9b#{x>!rB>~!D@3l&3c<%Yc`qCU;!W` z@reO2@W;f|P&m}LH*g*PQT%b#$}j4Op@b;xiKvI~Q}s|gGR<(Z&d-kRNlPB*wS8+@8t2%hiZ#7A9gnkqUOC6h&XF?TCd3_aB4i)E}Y=VS#7VKS+i1qh?5jgfy*Gn3+~V3*BOxOCeQl z9&G|^2CE{kPJ)yS4g4~rJMd^@uzD;QG8anKV&?W#BAw5;^Mf=Alg3Oj{vfDG_hRq| z#~Md3bvV34ek8{TDN^+)ybz0}(_0PfP09h^7rt{fi>vtdacdI zm@SN6t9R&)CdTPtoK`Jo)az{4{%|N+UB(?Rp-g{WFr#pRCr7GP6eO^4$z3W69Ju(* zltE$Uz=29IbCME;8Hc4Hq*l-TdEb!g|II~WMu1n+oUS%+b3L`HdzGKRR@S@YjQ0n3Ig;<$JwGSqFlr*q!A#A`w!9co+2fpI z+qpJ-&^HOk!vtYZPT|Nfr^EjRZe38EDREYSbRO8hiy#E)qhrB1#kKA|3oa|hM_7?h z7866E;Fm25k1Q&(^kY7>WY<@6!3jr zQFfP@;AB`&Jq?81{*cKG)|JC==Zh=%%;YZ%yNCjVp~4MXH9rgm7(%vq8a!)ztaS?% z+COuy^)i8B(yD#es4Z&MRvZ{jpkToZypaRgPB6!#Dxk}RYu;a981 zVLT%wlV$?r5(u6oiAZEYDKl1?ql7t3Wg_A|_KqeO<1y&{@Ho~ND&ZH5s16%dB)kOs zcx?o{{&v3vFEKs9Dj|j?oYH;P{=3+O5X8YDAxlLWV`s^n!a?9w&3D4prFrV!0HeW* zFb#(eBWnwgJan~lmD7~qt1UqnQ9)GF!yaO}o$$TQV&d#(i%D;Fa5^*2bE8#{)hxs5 zbXu#EHE9hPyXdW))nGKBkWFv2IvK6eWY+!&E+Uo^yjTO5JTu_=Wn-?xQB>n_B}cK8 zl&GVq!BWss@R`+pJBt3_TqI@&OqxN!hkC#d;-{Y~6gln}G8luX-wHA=kMx^E&* z+cRWnq0`o;Gg^$S(V*2@9af#qXmDDrHly9au{NtoXJwoggVt`bnplU$s5h9jETd&j z22RK7%&gXExBqz4b{ z*ucC6ZvU95Yqcx8JNG9lrP+D)*_m+h*#dggef8NtDpuaKxk?!tcD&U1Zo6Y^V?JE(j0DHr#Ve;_eU*Sa2{Sng(KT9KK(f5;og4xPtro1vNCh zkTY{|Mz6zV{8vQX{gFD{yM8>px}KztzFfaj$wtAajTx|FLpCBJd3{zw2(!cP4VAUS zyqxpW1X7u3fTM@fVg5$*u;WAW)_I%MDLZf;hk5ITo5rU6G_rEzrb))#5tTt}4iu<= zvnfaUOcW$I&;r*H4-JREt-fm z;fBv9${zm6mLl}aaf&ai#Fc=U#+xzws{l6I!#KZ61sput4sz8b-0aCnQOAg}iUYk^~wELyP zJMBxPLSDy#Kq0gHox{8_Q!34A{P{GqoHYgepHvJ2HkdbVpv+``1avS#~`DOtU< zM1>N^qF~O>@k%Bd+&gV#rFe9wR>?=hZ+BMZ;bSg3q=7!@I?}1X@ty3{i-Qp#+E;Sw zr{R;B;k^V$*w+L5)j3Lgbp z?!B2fJJ*wu^w2X@-uwSHI~y}Ur&>}hf~5QM(W{l+_d$5xDR%wJTZf_&fkkEXk)uxB zoel4fnSyG#Hl{{-I2x+6NUZx{R(fcx`?IX!pJ>+X`-+DY>xON0YQm%00rG-EPC?qo z#FWAOgK&Z@;g97MDX&DszvWCDI4?L$U0NmuqP;e9>E4|?K%pD&xJ`mG>`{~4!U^@i zD|_uJ9E}+r8V8cj~S0W*V)&WvdXmSqeUE2B4=OpM-W)LSuM zXt|E)!hn9}I`%7r8%c7OuoAu=Q5lFXnD~;&HE4t(BK9xSRDn<gmLq&ncPCELw{+DC73Aql$99P$X^OCgX>VA~cp6+SVXkqte)wnX-}QSIVr(9V zhZQ&vZYlMI=Y6bE#TeXQ9qb%~Fh>QSR;Y=4A*BiGd9)PbN%~z-;0qyQ{1?WfwTyy`hINBsVKW$^%zgtaPbBEMEb zFj+MY(Q~S#R{1c2PbN$mpW*8gQ+v=Or@=!(B$jh#oyBCuV-7Z_o+X4}#Jy!ZZYbc! zg2kw{vpPM?SQ(v#VUS`>7Om6bFfulih1D9gn8O;7Ix22tn=?oqa_&m4SsF{%8RA&@ zWYSo8R6|Yly=FN^V?t#pR&EGVp_uD^E+-rW(yZ_$^TC5Ykuag#pAy)@H$uZ35(pCe z!DL8>1Xoaul=w2SW(m*1qouVZ!gGh|pgkx$bOie(ci5Xh4`5@`BJVj;qRjg&mV(T? z@gr~F%-jE)A?uLBWpP8#383W&xyM}!~I4eBbx+R$N z3)u+%PhyCx@j{D;xsW7!qZ>@V@k*6=;}7kjhZA&*~>y6egYnz zSrk_$No|DFOeS2M=^i+yTRkh1hBu8JBh&D6vq)cdYGz-oD?Eq%)ptQ zwq3VVWM2c{E1%8pJ<2>>Ck(cEEiI>oToesoJHlr#;j-f%><&ynzBuWLkdbA>)t7S8 z$e^B#7}PJ1_bjB7gii7_c<70?C9KCfVJrFh3HkX)@*|QTGH_vApd=^72Uo#g$|M!k zdU549d2)Vh_y4@?R)mFFO((`q9nu1tWDLTU;1%zNJ+BtRcW0+T^r>>-UdzuA6IfT1 zx4EUhg~0$B&$Hkl55SJsHYo0a(dU|TPv95=7>JcmAozthu@*H3Po69HNhlDbTU;#| zVISeg^_(Zg)G>Mers}Q$4M)BbT;8sCK0=iksJ;ddoEHs0(BrD|IZ3+E`8BF|Ks-U& z*;$2wBXgHfI$WE=1^g;G0JP&Qo+^JmJxxqvJRXMSIY&J?N~sZ&;6kmRcyk_TH%b|w2aSKcu!VKQ<-yg^`xa@619~vKY2E(N{a!Udl?>&iolqGx) zsc)7het`p}lie%c0S~@zfU>vZtYuc6#m;dKgWis(UNpks>L=Mls{T#{{jG0R`2LG1 zP%Xs9_NnqDtR^Za*PEhp1Mw|GBh8JYvwBp{^alB$D#sjT6pka1&C-HT&?` zBPyHPg|y)HiqZ9qLm=?yaBxv|* zp^8kSPGJ#Vyt3)|cwsKyx&wwF|9>K^q&1RF$eH8Ccuxgp&`E1#3=zW#0R diff --git a/graph_summary.json b/graph_summary.json index 7f97161b..db85866d 100644 --- a/graph_summary.json +++ b/graph_summary.json @@ -1 +1 @@ -{"_invocation_id": "a795bd6c-4581-43fe-b9ab-e6fb93378742", "linked": {"0": {"name": "source.aspects.xapi.xapi_events_all", "type": "source", "succ": [4]}, "1": {"name": "source.aspects.event_sink.course_block_names", "type": "source", "succ": [3, 7, 22]}, "2": {"name": "source.aspects.event_sink.course_names", "type": "source", "succ": [3, 6, 7, 18, 22]}, "3": {"name": "model.aspects.dim_course_blocks", "type": "model", "succ": [9, 12, 13, 15, 20]}, "4": {"name": "model.aspects.xapi_events_all_parsed", "type": "model", "succ": [5, 8, 11, 10, 14, 19, 21, 23]}, "5": {"name": "model.aspects.forum_events", "type": "model", "succ": [6]}, "6": {"name": "model.aspects.fact_forum_interactions", "type": "model"}, "7": {"name": "model.aspects.fact_grades", "type": "model", "succ": [26]}, "8": {"name": "model.aspects.grading_events", "type": "model", "succ": [7]}, "9": {"name": "model.aspects.fact_video_plays", "type": "model"}, "10": {"name": "model.aspects.video_playback_events", "type": "model", "succ": [9]}, "11": {"name": "model.aspects.video_transcript_events", "type": "model", "succ": [12]}, "12": {"name": "model.aspects.fact_transcript_usage", "type": "model"}, "13": {"name": "model.aspects.fact_problem_responses", "type": "model", "succ": [17]}, "14": {"name": "model.aspects.problem_events", "type": "model", "succ": [13, 15]}, "15": {"name": "model.aspects.int_problem_hints", "type": "model", "succ": [16]}, "16": {"name": "model.aspects.fact_learner_problem_summary", "type": "model", "succ": [24, 27, 28]}, "17": {"name": "model.aspects.int_problem_results", "type": "model", "succ": [16, 25]}, "18": {"name": "model.aspects.fact_enrollments", "type": "model", "succ": [29]}, "19": {"name": "model.aspects.enrollment_events", "type": "model", "succ": [18]}, "20": {"name": "model.aspects.fact_navigation", "type": "model"}, "21": {"name": "model.aspects.navigation_events", "type": "model", "succ": [20]}, "22": {"name": "model.aspects.fact_completions", "type": "model"}, "23": {"name": "model.aspects.completion_events", "type": "model", "succ": [22]}, "24": {"name": "test.aspects.learner_problem_summary_uniqueness", "type": "test"}, "25": {"name": "test.aspects.problem_results_uniqueness", "type": "test"}, "26": {"name": "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f", "type": "test"}, "27": {"name": "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da", "type": "test"}, "28": {"name": "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b", "type": "test"}, "29": {"name": "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4", "type": "test"}}} \ No newline at end of file +{"_invocation_id": "23109c69-1db3-40c3-b53f-036608b155d3", "linked": {"0": {"name": "source.aspects.xapi.xapi_events_all", "type": "source", "succ": [4]}, "1": {"name": "source.aspects.event_sink.course_block_names", "type": "source", "succ": [6, 10, 14]}, "2": {"name": "source.aspects.event_sink.course_names", "type": "source", "succ": [5, 6, 10, 11, 14]}, "3": {"name": "model.aspects.enrollment_events", "type": "model", "succ": [5]}, "4": {"name": "model.aspects.xapi_events_all_parsed", "type": "model", "succ": [3, 7, 9, 12, 13, 16, 21, 23]}, "5": {"name": "model.aspects.fact_enrollments", "type": "model", "succ": [26]}, "6": {"name": "model.aspects.dim_course_blocks", "type": "model", "succ": [8, 15, 18, 20, 22]}, "7": {"name": "model.aspects.navigation_events", "type": "model", "succ": [8]}, "8": {"name": "model.aspects.fact_navigation", "type": "model"}, "9": {"name": "model.aspects.completion_events", "type": "model", "succ": [10]}, "10": {"name": "model.aspects.fact_completions", "type": "model"}, "11": {"name": "model.aspects.fact_forum_interactions", "type": "model"}, "12": {"name": "model.aspects.forum_events", "type": "model", "succ": [11]}, "13": {"name": "model.aspects.grading_events", "type": "model", "succ": [14]}, "14": {"name": "model.aspects.fact_grades", "type": "model", "succ": [27]}, "15": {"name": "model.aspects.int_problem_hints", "type": "model", "succ": [19]}, "16": {"name": "model.aspects.problem_events", "type": "model", "succ": [15, 18]}, "17": {"name": "model.aspects.int_problem_results", "type": "model", "succ": [19, 24]}, "18": {"name": "model.aspects.fact_problem_responses", "type": "model", "succ": [17]}, "19": {"name": "model.aspects.fact_learner_problem_summary", "type": "model", "succ": [25, 28, 29]}, "20": {"name": "model.aspects.fact_video_plays", "type": "model"}, "21": {"name": "model.aspects.video_playback_events", "type": "model", "succ": [20]}, "22": {"name": "model.aspects.fact_transcript_usage", "type": "model"}, "23": {"name": "model.aspects.video_transcript_events", "type": "model", "succ": [22]}, "24": {"name": "test.aspects.problem_results_uniqueness", "type": "test"}, "25": {"name": "test.aspects.learner_problem_summary_uniqueness", "type": "test"}, "26": {"name": "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4", "type": "test"}, "27": {"name": "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f", "type": "test"}, "28": {"name": "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da", "type": "test"}, "29": {"name": "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b", "type": "test"}}} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 141bd1d1..bff4a100 100644 --- a/manifest.json +++ b/manifest.json @@ -1 +1 @@ -{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v11.json", "dbt_version": "1.7.0", "generated_at": "2024-01-12T21:21:40.064276Z", "invocation_id": "a795bd6c-4581-43fe-b9ab-e6fb93378742", "env": {}, "project_name": "aspects", "project_id": "9074d4992d118978696669561f06dfcc", "user_id": "855d6434-9551-424d-b076-63760deab710", "send_anonymous_usage_stats": true, "adapter_type": "clickhouse"}, "nodes": {"model.aspects.dim_course_blocks": {"database": "", "schema": "xapi", "name": "dim_course_blocks", "resource_type": "model", "package_name": "aspects", "path": "base/dim_course_blocks.sql", "original_file_path": "models/base/dim_course_blocks.sql", "unique_id": "model.aspects.dim_course_blocks", "fqn": ["aspects", "base", "dim_course_blocks"], "alias": "dim_course_blocks", "checksum": {"name": "sha256", "checksum": "82ae5386fcd742cd5b4a90c135161d8c0fb8ca5577e0689ca229d7869d5d047c"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "A denormalized table of course block information", "columns": {"org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "block_id": {"name": "block_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "block_name": {"name": "block_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "display_name_with_location": {"name": "display_name_with_location", "description": "The block's display name with section, subsection, and unit prepended to the name. This provides additional context when looking at block names and can help data consumers understand which block they are analyzing", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/base/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094501.975451, "relation_name": "`xapi`.`dim_course_blocks`", "raw_code": "select\n courses.org as org,\n courses.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n blocks.location as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as display_name_with_location\nfrom\n {{ source('event_sink', 'course_block_names') }} blocks\n join {{ source('event_sink', 'course_names')}} courses\n on blocks.course_key = courses.course_key\nsettings join_algorithm='direct'", "language": "sql", "refs": [], "sources": [["event_sink", "course_names"], ["event_sink", "course_block_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_names", "source.aspects.event_sink.course_block_names"]}, "compiled_path": "target/compiled/aspects/models/base/dim_course_blocks.sql", "compiled": true, "compiled_code": "select\n courses.org as org,\n courses.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n blocks.location as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as display_name_with_location\nfrom\n `event_sink`.`course_block_names` blocks\n join `event_sink`.`course_names` courses\n on blocks.course_key = courses.course_key\nsettings join_algorithm='direct'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.xapi_events_all_parsed": {"database": "", "schema": "xapi", "name": "xapi_events_all_parsed", "resource_type": "model", "package_name": "aspects", "path": "base/xapi_events_all_parsed.sql", "original_file_path": "models/base/xapi_events_all_parsed.sql", "unique_id": "model.aspects.xapi_events_all_parsed", "fqn": ["aspects", "base", "xapi_events_all_parsed"], "alias": "xapi_events_all_parsed", "checksum": {"name": "sha256", "checksum": "919b5ae9cc3228a09e4c3c26960d736f55f4661e321b7f7cba1389ff629b0655"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_id, verb_id, actor_id, emission_time, event_id)", "primary_key": "(org, course_id, verb_id, actor_id, emission_time, event_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_id, verb_id, actor_id, emission_time, event_id)", "order_by": "(org, course_id, verb_id, actor_id, emission_time, event_id)", "post-hook": ["OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL"]}, "created_at": 1705094501.6027014, "relation_name": "`xapi`.`xapi_events_all_parsed`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_id, verb_id, actor_id, emission_time, event_id)',\n order_by='(org, course_id, verb_id, actor_id, emission_time, event_id)',\n post_hook='OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL'\n ) }}\n\nSELECT\n event_id as event_id,\n JSON_VALUE(event_str, '$.verb.id') as verb_id,\n COALESCE(\n NULLIF(JSON_VALUE(event_str, '$.actor.account.name'), ''),\n NULLIF(JSON_VALUE(event_str, '$.actor.mbox'), ''),\n JSON_VALUE(event_str, '$.actor.mbox_sha1sum')\n ) as actor_id,\n JSON_VALUE(event_str, '$.object.id') as object_id,\n -- If the contextActivities parent is a course, use that. It can be a \"course\"\n -- type, or a \"cmi.interaction\" type for multiple question problem submissions.\n -- Otherwise use the object id for the course id.\n multiIf(\n -- If the contextActivities parent is a course, use that\n JSON_VALUE(\n event_str,\n '$.context.contextActivities.parent[0].definition.type'\n ) = 'http://adlnet.gov/expapi/activities/course',\n JSON_VALUE(event_str, '$.context.contextActivities.parent[0].id'),\n -- Else if the contextActivities parent is a GroupActivity, it's a multi\n -- question problem and we use the grouping id\n JSON_VALUE(\n event_str,\n '$.context.contextActivities.parent[0].objectType'\n ) in ('Activity', 'GroupActivity'),\n JSON_VALUE(event_str, '$.context.contextActivities.grouping[0].id'),\n -- Otherwise use the object id\n JSON_VALUE(event_str, '$.object.id')\n ) as course_id,\n coalesce(get_org_from_course_url(course_id), '') as org,\n emission_time as emission_time,\n event_str as event_str\nFROM {{ source('xapi', 'xapi_events_all') }}", "language": "sql", "refs": [], "sources": [["xapi", "xapi_events_all"]], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine", "macro.aspects.on_cluster"], "nodes": ["source.aspects.xapi.xapi_events_all"]}, "compiled_path": "target/compiled/aspects/models/base/xapi_events_all_parsed.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id as event_id,\n JSON_VALUE(event_str, '$.verb.id') as verb_id,\n COALESCE(\n NULLIF(JSON_VALUE(event_str, '$.actor.account.name'), ''),\n NULLIF(JSON_VALUE(event_str, '$.actor.mbox'), ''),\n JSON_VALUE(event_str, '$.actor.mbox_sha1sum')\n ) as actor_id,\n JSON_VALUE(event_str, '$.object.id') as object_id,\n -- If the contextActivities parent is a course, use that. It can be a \"course\"\n -- type, or a \"cmi.interaction\" type for multiple question problem submissions.\n -- Otherwise use the object id for the course id.\n multiIf(\n -- If the contextActivities parent is a course, use that\n JSON_VALUE(\n event_str,\n '$.context.contextActivities.parent[0].definition.type'\n ) = 'http://adlnet.gov/expapi/activities/course',\n JSON_VALUE(event_str, '$.context.contextActivities.parent[0].id'),\n -- Else if the contextActivities parent is a GroupActivity, it's a multi\n -- question problem and we use the grouping id\n JSON_VALUE(\n event_str,\n '$.context.contextActivities.parent[0].objectType'\n ) in ('Activity', 'GroupActivity'),\n JSON_VALUE(event_str, '$.context.contextActivities.grouping[0].id'),\n -- Otherwise use the object id\n JSON_VALUE(event_str, '$.object.id')\n ) as course_id,\n coalesce(get_org_from_course_url(course_id), '') as org,\n emission_time as emission_time,\n event_str as event_str\nFROM `xapi`.`xapi_events_all`", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.forum_events": {"database": "", "schema": "xapi", "name": "forum_events", "resource_type": "model", "package_name": "aspects", "path": "forum/forum_events.sql", "original_file_path": "models/forum/forum_events.sql", "unique_id": "model.aspects.forum_events", "fqn": ["aspects", "forum", "forum_events"], "alias": "forum_events", "checksum": {"name": "sha256", "checksum": "c09e6d2d052729709d8d6ac6d5d340f3c31b2099a67a202d245afdaf80e42198"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)"}, "created_at": 1705094501.6135073, "relation_name": "`xapi`.`forum_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)'\n ) }}\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n object_id,\n actor_id,\n verb_id\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE JSON_VALUE(event_str, '$.object.definition.type') = 'http://id.tincanapi.com/activitytype/discussion'", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/forum/forum_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n object_id,\n actor_id,\n verb_id\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE JSON_VALUE(event_str, '$.object.definition.type') = 'http://id.tincanapi.com/activitytype/discussion'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_forum_interactions": {"database": "", "schema": "xapi", "name": "fact_forum_interactions", "resource_type": "model", "package_name": "aspects", "path": "forum/fact_forum_interactions.sql", "original_file_path": "models/forum/fact_forum_interactions.sql", "unique_id": "model.aspects.fact_forum_interactions", "fqn": ["aspects", "forum", "fact_forum_interactions"], "alias": "fact_forum_interactions", "checksum": {"name": "sha256", "checksum": "64122e4345ea67b2f12cae9c50211fb8fe952b5069b84f420ae6620d72e584a4"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record per forum interaction", "columns": {"event_id": {"name": "event_id", "description": "", "meta": {}, "data_type": "UUID", "constraints": [], "quote": null, "tags": []}, "emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": "DateTime64(3)", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "object_id": {"name": "object_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "verb_id": {"name": "verb_id", "description": "", "meta": {}, "data_type": "LowCardinality(String)", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/forum/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094501.9788575, "relation_name": "`xapi`.`fact_forum_interactions`", "raw_code": "select\n forum.event_id as event_id,\n forum.emission_time as emission_time,\n forum.org as org,\n forum.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n forum.object_id as object_id,\n forum.actor_id as actor_id,\n forum.verb_id as verb_id\nfrom\n {{ ref('forum_events') }} forum\n join {{ source('event_sink', 'course_names') }} courses\n on (forum.course_key = courses.course_key)", "language": "sql", "refs": [{"name": "forum_events", "package": null, "version": null}], "sources": [["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_names", "model.aspects.forum_events"]}, "compiled_path": "target/compiled/aspects/models/forum/fact_forum_interactions.sql", "compiled": true, "compiled_code": "select\n forum.event_id as event_id,\n forum.emission_time as emission_time,\n forum.org as org,\n forum.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n forum.object_id as object_id,\n forum.actor_id as actor_id,\n forum.verb_id as verb_id\nfrom\n `xapi`.`forum_events` forum\n join `event_sink`.`course_names` courses\n on (forum.course_key = courses.course_key)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_grades": {"database": "", "schema": "xapi", "name": "fact_grades", "resource_type": "model", "package_name": "aspects", "path": "grading/fact_grades.sql", "original_file_path": "models/grading/fact_grades.sql", "unique_id": "model.aspects.fact_grades", "fqn": ["aspects", "grading", "fact_grades"], "alias": "fact_grades", "checksum": {"name": "sha256", "checksum": "8d4335b0eb71644c3210ff16c0ff1bf882579ab0947e9ba3d89a889cade23720"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record per grading event for courses, subsections, and problems", "columns": {"emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "DateTime64(3)", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_id": {"name": "entity_id", "description": "The block ID or course key for the graded entity", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_name": {"name": "entity_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_name_with_location": {"name": "entity_name_with_location", "description": "", "meta": {}, "data_type": "Nullable(String)", "constraints": [], "quote": null, "tags": []}, "grade_type": {"name": "grade_type", "description": "The type of object graded", "meta": {}, "data_type": "Nullable(String)", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "scaled_score": {"name": "scaled_score", "description": "A ratio between 0 and 1, inclusive, of the learner's grade", "meta": {}, "data_type": "Float32", "constraints": [], "quote": null, "tags": []}, "grade_bucket": {"name": "grade_bucket", "description": "A displayable value of grades sorted into 10% buckets. Useful for grouping grades together to show high-level learner performance", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/grading/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094501.9839773, "relation_name": "`xapi`.`fact_grades`", "raw_code": "with grades as (\n select\n emission_time,\n org,\n course_key,\n case\n when object_id like '%/course/%' then 'course'\n when object_id like '%@sequential+block@%' then 'subsection'\n when object_id like '%@problem+block@%' then 'problem'\n end as grade_type,\n if(\n grade_type = 'course',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n actor_id,\n scaled_score\n from\n {{ ref('grading_events') }}\n)\n\nselect\n grades.emission_time as emission_time,\n grades.org as org,\n grades.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n grades.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n grades.grade_type as grade_type,\n grades.actor_id as actor_id,\n grades.scaled_score as scaled_score,\n case\n when scaled_score >= 0.9 then '90-100%'\n when scaled_score >= 0.8 and scaled_score < 0.9 then '80-89%'\n when scaled_score >= 0.7 and scaled_score < 0.8 then '70-79%'\n when scaled_score >= 0.6 and scaled_score < 0.7 then '60-69%'\n when scaled_score >= 0.5 and scaled_score < 0.6 then '50-59%'\n when scaled_score >= 0.4 and scaled_score < 0.5 then '40-49%'\n when scaled_score >= 0.3 and scaled_score < 0.4 then '30-39%'\n when scaled_score >= 0.2 and scaled_score < 0.3 then '20-29%'\n when scaled_score >= 0.1 and scaled_score < 0.2 then '10-19%'\n else '0-9%'\n end as grade_bucket\nfrom\n grades\n join {{ source('event_sink', 'course_names')}} courses\n on grades.course_key = courses.course_key\n left join {{ source('event_sink', 'course_block_names') }} blocks\n on grades.entity_id = blocks.location", "language": "sql", "refs": [{"name": "grading_events", "package": null, "version": null}], "sources": [["event_sink", "course_block_names"], ["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names", "model.aspects.grading_events"]}, "compiled_path": "target/compiled/aspects/models/grading/fact_grades.sql", "compiled": true, "compiled_code": "with grades as (\n select\n emission_time,\n org,\n course_key,\n case\n when object_id like '%/course/%' then 'course'\n when object_id like '%@sequential+block@%' then 'subsection'\n when object_id like '%@problem+block@%' then 'problem'\n end as grade_type,\n if(\n grade_type = 'course',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n actor_id,\n scaled_score\n from\n `xapi`.`grading_events`\n)\n\nselect\n grades.emission_time as emission_time,\n grades.org as org,\n grades.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n grades.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n grades.grade_type as grade_type,\n grades.actor_id as actor_id,\n grades.scaled_score as scaled_score,\n case\n when scaled_score >= 0.9 then '90-100%'\n when scaled_score >= 0.8 and scaled_score < 0.9 then '80-89%'\n when scaled_score >= 0.7 and scaled_score < 0.8 then '70-79%'\n when scaled_score >= 0.6 and scaled_score < 0.7 then '60-69%'\n when scaled_score >= 0.5 and scaled_score < 0.6 then '50-59%'\n when scaled_score >= 0.4 and scaled_score < 0.5 then '40-49%'\n when scaled_score >= 0.3 and scaled_score < 0.4 then '30-39%'\n when scaled_score >= 0.2 and scaled_score < 0.3 then '20-29%'\n when scaled_score >= 0.1 and scaled_score < 0.2 then '10-19%'\n else '0-9%'\n end as grade_bucket\nfrom\n grades\n join `event_sink`.`course_names` courses\n on grades.course_key = courses.course_key\n left join `event_sink`.`course_block_names` blocks\n on grades.entity_id = blocks.location", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.grading_events": {"database": "", "schema": "xapi", "name": "grading_events", "resource_type": "model", "package_name": "aspects", "path": "grading/grading_events.sql", "original_file_path": "models/grading/grading_events.sql", "unique_id": "model.aspects.grading_events", "fqn": ["aspects", "grading", "grading_events"], "alias": "grading_events", "checksum": {"name": "sha256", "checksum": "bfdaf975eb67528de16e64482dafcae1108fc50369628e834328d9248fa04560"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, scaled_score, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, scaled_score, event_id)"}, "created_at": 1705094501.626424, "relation_name": "`xapi`.`grading_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, scaled_score, event_id)'\n ) }}\n\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractFloat(event_str, 'result', 'score', 'scaled') AS scaled_score\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE verb_id IN ('http://id.tincanapi.com/verb/earned', 'https://w3id.org/xapi/acrossx/verbs/evaluated')", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/grading/grading_events.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractFloat(event_str, 'result', 'score', 'scaled') AS scaled_score\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN ('http://id.tincanapi.com/verb/earned', 'https://w3id.org/xapi/acrossx/verbs/evaluated')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_video_plays": {"database": "", "schema": "xapi", "name": "fact_video_plays", "resource_type": "model", "package_name": "aspects", "path": "video/fact_video_plays.sql", "original_file_path": "models/video/fact_video_plays.sql", "unique_id": "model.aspects.fact_video_plays", "fqn": ["aspects", "video", "fact_video_plays"], "alias": "fact_video_plays", "checksum": {"name": "sha256", "checksum": "85ab8faefe964ecf36254cab661f50df9eb0fc59bfd6f9b10af0a00779956fc2"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record for each time a learner played a video", "columns": {"emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": "DateTime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_id": {"name": "video_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_name": {"name": "video_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_name_with_location": {"name": "video_name_with_location", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/video/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094502.0688229, "relation_name": "`xapi`.`fact_video_plays`", "raw_code": "-- model to support number of watches per video\n-- ref: https://edx.readthedocs.io/projects/edx-insights/en/latest/Reference.html#engagement-computations\nwith plays as (\n select\n emission_time,\n org,\n course_key,\n splitByString('/xblock/', object_id)[-1] as video_id,\n actor_id\n from\n {{ ref('video_playback_events') }}\n where\n verb_id = 'https://w3id.org/xapi/video/verbs/played'\n)\n\nselect\n plays.emission_time as emission_time,\n plays.org as org,\n plays.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n plays.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n plays.actor_id as actor_id\nfrom\n plays\n join {{ ref('dim_course_blocks')}} blocks\n on (plays.course_key = blocks.course_key\n and plays.video_id = blocks.block_id)", "language": "sql", "refs": [{"name": "video_playback_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.video_playback_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/video/fact_video_plays.sql", "compiled": true, "compiled_code": "-- model to support number of watches per video\n-- ref: https://edx.readthedocs.io/projects/edx-insights/en/latest/Reference.html#engagement-computations\nwith plays as (\n select\n emission_time,\n org,\n course_key,\n splitByString('/xblock/', object_id)[-1] as video_id,\n actor_id\n from\n `xapi`.`video_playback_events`\n where\n verb_id = 'https://w3id.org/xapi/video/verbs/played'\n)\n\nselect\n plays.emission_time as emission_time,\n plays.org as org,\n plays.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n plays.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n plays.actor_id as actor_id\nfrom\n plays\n join `xapi`.`dim_course_blocks` blocks\n on (plays.course_key = blocks.course_key\n and plays.video_id = blocks.block_id)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.video_transcript_events": {"database": "", "schema": "xapi", "name": "video_transcript_events", "resource_type": "model", "package_name": "aspects", "path": "video/video_transcript_events.sql", "original_file_path": "models/video/video_transcript_events.sql", "unique_id": "model.aspects.video_transcript_events", "fqn": ["aspects", "video", "video_transcript_events"], "alias": "video_transcript_events", "checksum": {"name": "sha256", "checksum": "ef25edd97b8299a5bb1b0e59251dad82c10291be74d2d75fc6db535b71f85a40"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, video_id, emission_time, actor_id, cc_enabled, event_id)", "primary_key": "(org, course_key, video_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, video_id)", "order_by": "(org, course_key, video_id, emission_time, actor_id, cc_enabled, event_id)"}, "created_at": 1705094501.6355157, "relation_name": "`xapi`.`video_transcript_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, video_id)',\n order_by='(org, course_key, video_id, emission_time, actor_id, cc_enabled, event_id)'\n ) }}\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n splitByString('/xblock/', object_id)[2] as video_id,\n actor_id,\n JSONExtractBool(event_str, 'result','extensions','https://w3id.org/xapi/video/extensions/cc-enabled') as cc_enabled\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE\n verb_id IN ('http://adlnet.gov/expapi/verbs/interacted')\n AND JSONHas(event_str, 'result', 'extensions', 'https://w3id.org/xapi/video/extensions/cc-enabled')", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/video/video_transcript_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n splitByString('/xblock/', object_id)[2] as video_id,\n actor_id,\n JSONExtractBool(event_str, 'result','extensions','https://w3id.org/xapi/video/extensions/cc-enabled') as cc_enabled\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE\n verb_id IN ('http://adlnet.gov/expapi/verbs/interacted')\n AND JSONHas(event_str, 'result', 'extensions', 'https://w3id.org/xapi/video/extensions/cc-enabled')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_transcript_usage": {"database": "", "schema": "xapi", "name": "fact_transcript_usage", "resource_type": "model", "package_name": "aspects", "path": "video/fact_transcript_usage.sql", "original_file_path": "models/video/fact_transcript_usage.sql", "unique_id": "model.aspects.fact_transcript_usage", "fqn": ["aspects", "video", "fact_transcript_usage"], "alias": "fact_transcript_usage", "checksum": {"name": "sha256", "checksum": "6ebe9cc34ac188422c1d512034164d4666a2fcfc30cde343707b141b7343b051"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record for each time a transcript or closed caption was enabled", "columns": {"emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": "DateTime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_id": {"name": "video_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_name": {"name": "video_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_name_with_location": {"name": "video_name_with_location", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/video/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094502.0698674, "relation_name": "`xapi`.`fact_transcript_usage`", "raw_code": "select\n transcripts.emission_time as emission_time,\n transcripts.org as org,\n transcripts.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n transcripts.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n transcripts.actor_id as actor_id\nfrom\n {{ ref('video_transcript_events') }} transcripts\n join {{ ref('dim_course_blocks')}} blocks\n on (transcripts.course_key = blocks.course_key\n and transcripts.video_id = blocks.block_id)\nwhere\n transcripts.cc_enabled", "language": "sql", "refs": [{"name": "video_transcript_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.video_transcript_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/video/fact_transcript_usage.sql", "compiled": true, "compiled_code": "select\n transcripts.emission_time as emission_time,\n transcripts.org as org,\n transcripts.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n transcripts.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n transcripts.actor_id as actor_id\nfrom\n `xapi`.`video_transcript_events` transcripts\n join `xapi`.`dim_course_blocks` blocks\n on (transcripts.course_key = blocks.course_key\n and transcripts.video_id = blocks.block_id)\nwhere\n transcripts.cc_enabled", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.video_playback_events": {"database": "", "schema": "xapi", "name": "video_playback_events", "resource_type": "model", "package_name": "aspects", "path": "video/video_playback_events.sql", "original_file_path": "models/video/video_playback_events.sql", "unique_id": "model.aspects.video_playback_events", "fqn": ["aspects", "video", "video_playback_events"], "alias": "video_playback_events", "checksum": {"name": "sha256", "checksum": "91474c43008d81943f7894bdec98518af730b785cd742350ca0c53e1c16c04bb"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, video_position, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, video_position, event_id)"}, "created_at": 1705094501.6445098, "relation_name": "`xapi`.`video_playback_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, video_position, event_id)'\n ) }}\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n ceil(CAST(coalesce(nullIf(JSON_VALUE(event_str, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time\"'), ''), nullIf(JSON_VALUE(event_str, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time-from\"'), ''), '0.0'), 'Decimal32(2)')) AS video_position\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE (verb_id IN ('http://adlnet.gov/expapi/verbs/completed', 'http://adlnet.gov/expapi/verbs/initialized', 'http://adlnet.gov/expapi/verbs/terminated', 'https://w3id.org/xapi/video/verbs/paused', 'https://w3id.org/xapi/video/verbs/played', 'https://w3id.org/xapi/video/verbs/seeked')) AND (object_id LIKE '%video+block%')", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/video/video_playback_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n ceil(CAST(coalesce(nullIf(JSON_VALUE(event_str, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time\"'), ''), nullIf(JSON_VALUE(event_str, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time-from\"'), ''), '0.0'), 'Decimal32(2)')) AS video_position\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE (verb_id IN ('http://adlnet.gov/expapi/verbs/completed', 'http://adlnet.gov/expapi/verbs/initialized', 'http://adlnet.gov/expapi/verbs/terminated', 'https://w3id.org/xapi/video/verbs/paused', 'https://w3id.org/xapi/video/verbs/played', 'https://w3id.org/xapi/video/verbs/seeked')) AND (object_id LIKE '%video+block%')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_problem_responses": {"database": "", "schema": "xapi", "name": "fact_problem_responses", "resource_type": "model", "package_name": "aspects", "path": "problems/fact_problem_responses.sql", "original_file_path": "models/problems/fact_problem_responses.sql", "unique_id": "model.aspects.fact_problem_responses", "fqn": ["aspects", "problems", "fact_problem_responses"], "alias": "fact_problem_responses", "checksum": {"name": "sha256", "checksum": "9327b7aecfc7487b29850a582a053dff923d287d8db0b76b17b7835d71bcecbd"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record for each submitted response to a problem", "columns": {"emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": "DateTime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_id": {"name": "problem_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_name": {"name": "problem_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_name_with_location": {"name": "problem_name_with_location", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "responses": {"name": "responses", "description": "The responses for this submission. If a problem has multiple parts, values for all parts will be in this field", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "success": {"name": "success", "description": "Boolean indicating whether the responses were correct", "meta": {}, "data_type": "Bool", "constraints": [], "quote": null, "tags": []}, "attempts": {"name": "attempts", "description": "Number indicating which attempt this was", "meta": {}, "data_type": "Int16", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/problems/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094502.0761821, "relation_name": "`xapi`.`fact_problem_responses`", "raw_code": "with responses as (\n select\n emission_time,\n org,\n course_key,\n {{ get_problem_id('object_id') }} as problem_id,\n actor_id,\n responses,\n success,\n attempts\n from\n {{ ref('problem_events') }}\n where\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated'\n)\n\nselect\n responses.emission_time as emission_time,\n responses.org as org,\n responses.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n responses.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n responses.actor_id as actor_id,\n responses.responses as responses,\n responses.success as success,\n responses.attempts as attempts\nfrom\n responses\n join {{ ref('dim_course_blocks')}} blocks\n on (responses.course_key = blocks.course_key\n and responses.problem_id = blocks.block_id)\ngroup by\n -- multi-part questions include an extra record for the response to the first\n -- part of the question. this group by clause eliminates the duplicate record\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts", "language": "sql", "refs": [{"name": "problem_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_problem_id"], "nodes": ["model.aspects.problem_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/problems/fact_problem_responses.sql", "compiled": true, "compiled_code": "with responses as (\n select\n emission_time,\n org,\n course_key,\n \n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n as problem_id,\n actor_id,\n responses,\n success,\n attempts\n from\n `xapi`.`problem_events`\n where\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated'\n)\n\nselect\n responses.emission_time as emission_time,\n responses.org as org,\n responses.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n responses.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n responses.actor_id as actor_id,\n responses.responses as responses,\n responses.success as success,\n responses.attempts as attempts\nfrom\n responses\n join `xapi`.`dim_course_blocks` blocks\n on (responses.course_key = blocks.course_key\n and responses.problem_id = blocks.block_id)\ngroup by\n -- multi-part questions include an extra record for the response to the first\n -- part of the question. this group by clause eliminates the duplicate record\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.int_problem_hints": {"database": "", "schema": "xapi", "name": "int_problem_hints", "resource_type": "model", "package_name": "aspects", "path": "problems/int_problem_hints.sql", "original_file_path": "models/problems/int_problem_hints.sql", "unique_id": "model.aspects.int_problem_hints", "fqn": ["aspects", "problems", "int_problem_hints"], "alias": "int_problem_hints", "checksum": {"name": "sha256", "checksum": "4a8a288769d2f6fa488fd11bb83bfb1eeda843e498cf6972ca4fd7febb386ebf"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094501.6574, "relation_name": "`xapi`.`int_problem_hints`", "raw_code": "with hints as (\n select\n emission_time,\n org,\n course_key,\n {{ get_problem_id('object_id') }} as problem_id,\n actor_id,\n case\n when object_id like '%/hint%' then 'hint'\n when object_id like '%/answer%' then 'answer'\n else 'N/A'\n end as help_type\n from\n {{ ref('problem_events') }}\n where\n verb_id = 'http://adlnet.gov/expapi/verbs/asked'\n)\n\nselect\n hints.emission_time as emission_time,\n hints.org as org,\n hints.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n hints.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n hints.actor_id as actor_id,\n hints.help_type as help_type\nfrom\n hints\n join {{ ref('dim_course_blocks')}} blocks\n on (hints.course_key = blocks.course_key\n and hints.problem_id = blocks.block_id)", "language": "sql", "refs": [{"name": "problem_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_problem_id"], "nodes": ["model.aspects.problem_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/problems/int_problem_hints.sql", "compiled": true, "compiled_code": "with hints as (\n select\n emission_time,\n org,\n course_key,\n \n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n as problem_id,\n actor_id,\n case\n when object_id like '%/hint%' then 'hint'\n when object_id like '%/answer%' then 'answer'\n else 'N/A'\n end as help_type\n from\n `xapi`.`problem_events`\n where\n verb_id = 'http://adlnet.gov/expapi/verbs/asked'\n)\n\nselect\n hints.emission_time as emission_time,\n hints.org as org,\n hints.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n hints.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n hints.actor_id as actor_id,\n hints.help_type as help_type\nfrom\n hints\n join `xapi`.`dim_course_blocks` blocks\n on (hints.course_key = blocks.course_key\n and hints.problem_id = blocks.block_id)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.problem_events": {"database": "", "schema": "xapi", "name": "problem_events", "resource_type": "model", "package_name": "aspects", "path": "problems/problem_events.sql", "original_file_path": "models/problems/problem_events.sql", "unique_id": "model.aspects.problem_events", "fqn": ["aspects", "problems", "problem_events"], "alias": "problem_events", "checksum": {"name": "sha256", "checksum": "6e722e887726b30f927c54b80252e5380ed94f6fffa4fcb8d088d2b9cc8e7493"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, responses, success, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, responses, success, event_id)"}, "created_at": 1705094501.6633642, "relation_name": "`xapi`.`problem_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, responses, success, event_id)'\n ) }}\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event_str, '$.result.response') as responses,\n JSON_VALUE(event_str, '$.result.score.scaled') as scaled_score,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event_str, '$.result.success') as Bool),\n false\n ) as success,\n JSON_VALUE(event_str, '$.object.definition.interactionType') as interaction_type,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event_str, '$.object.definition.extensions.\"http://id.tincanapi.com/extension/attempt-id\"') as Int16),\n 0\n ) as attempts\nFROM\n {{ ref('xapi_events_all_parsed') }}\nWHERE\n verb_id in (\n 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n 'http://adlnet.gov/expapi/verbs/passed',\n 'http://adlnet.gov/expapi/verbs/asked'\n )", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/problems/problem_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event_str, '$.result.response') as responses,\n JSON_VALUE(event_str, '$.result.score.scaled') as scaled_score,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event_str, '$.result.success') as Bool),\n false\n ) as success,\n JSON_VALUE(event_str, '$.object.definition.interactionType') as interaction_type,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event_str, '$.object.definition.extensions.\"http://id.tincanapi.com/extension/attempt-id\"') as Int16),\n 0\n ) as attempts\nFROM\n `xapi`.`xapi_events_all_parsed`\nWHERE\n verb_id in (\n 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n 'http://adlnet.gov/expapi/verbs/passed',\n 'http://adlnet.gov/expapi/verbs/asked'\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_learner_problem_summary": {"database": "", "schema": "xapi", "name": "fact_learner_problem_summary", "resource_type": "model", "package_name": "aspects", "path": "problems/fact_learner_problem_summary.sql", "original_file_path": "models/problems/fact_learner_problem_summary.sql", "unique_id": "model.aspects.fact_learner_problem_summary", "fqn": ["aspects", "problems", "fact_learner_problem_summary"], "alias": "fact_learner_problem_summary", "checksum": {"name": "sha256", "checksum": "fd0a2f24f39497aee19b9f6de759ee4a53b2312b1ef8fe24f94c44dd3dc9bfc7"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record per learner per problem in a course", "columns": {"org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_id": {"name": "problem_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_name": {"name": "problem_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_name_with_location": {"name": "problem_name_with_location", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "success": {"name": "success", "description": "The result of the last submission", "meta": {}, "data_type": "Bool", "constraints": [], "quote": null, "tags": []}, "attempts": {"name": "attempts", "description": "The number of attempts made", "meta": {}, "data_type": "Int16", "constraints": [], "quote": null, "tags": []}, "num_hints_displayed": {"name": "num_hints_displayed", "description": "The number of times a learner asked for a hint", "meta": {}, "data_type": "UInt64", "constraints": [], "quote": null, "tags": []}, "num_answers_displayed": {"name": "num_answers_displayed", "description": "The number of times a learner requested the answers for the problem", "meta": {}, "data_type": "UInt64", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/problems/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094502.074705, "relation_name": "`xapi`.`fact_learner_problem_summary`", "raw_code": "-- summary table for a learner's performance on and interactions with a\n-- particular problem\nwith results_with_hints as (\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n success,\n attempts,\n 0 as num_hints_displayed,\n 0 as num_answers_displayed\n from {{ ref('int_problem_results') }}\n union all\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n null as success,\n null as attempts,\n case help_type\n when 'hint' then 1\n else 0\n end as num_hints_displayed,\n case help_type\n when 'answer' then 1\n else 0\n end as num_answers_displayed\n from {{ ref('int_problem_hints') }}\n)\n\n-- n.b.: there should only be one row per org, course, problem, and actor\n-- in problem_results, so any(success) and any(attempts) should return the\n-- values from that part of the union and not the null values used as\n-- placeholders in the problem_hints part of the union\nselect\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n coalesce(any(success), false) as success,\n coalesce(any(attempts), 0) as attempts,\n sum(num_hints_displayed) as num_hints_displayed,\n sum(num_answers_displayed) as num_answers_displayed\nfrom\n results_with_hints\ngroup by\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id", "language": "sql", "refs": [{"name": "int_problem_results", "package": null, "version": null}, {"name": "int_problem_hints", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.int_problem_results", "model.aspects.int_problem_hints"]}, "compiled_path": "target/compiled/aspects/models/problems/fact_learner_problem_summary.sql", "compiled": true, "compiled_code": "-- summary table for a learner's performance on and interactions with a\n-- particular problem\nwith results_with_hints as (\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n success,\n attempts,\n 0 as num_hints_displayed,\n 0 as num_answers_displayed\n from `xapi`.`int_problem_results`\n union all\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n null as success,\n null as attempts,\n case help_type\n when 'hint' then 1\n else 0\n end as num_hints_displayed,\n case help_type\n when 'answer' then 1\n else 0\n end as num_answers_displayed\n from `xapi`.`int_problem_hints`\n)\n\n-- n.b.: there should only be one row per org, course, problem, and actor\n-- in problem_results, so any(success) and any(attempts) should return the\n-- values from that part of the union and not the null values used as\n-- placeholders in the problem_hints part of the union\nselect\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n coalesce(any(success), false) as success,\n coalesce(any(attempts), 0) as attempts,\n sum(num_hints_displayed) as num_hints_displayed,\n sum(num_answers_displayed) as num_answers_displayed\nfrom\n results_with_hints\ngroup by\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.int_problem_results": {"database": "", "schema": "xapi", "name": "int_problem_results", "resource_type": "model", "package_name": "aspects", "path": "problems/int_problem_results.sql", "original_file_path": "models/problems/int_problem_results.sql", "unique_id": "model.aspects.int_problem_results", "fqn": ["aspects", "problems", "int_problem_results"], "alias": "int_problem_results", "checksum": {"name": "sha256", "checksum": "a0f3b295ad345aae0555b804478a62cef3cb2854cb5c9b6066e18df64fdecf84"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094501.6733332, "relation_name": "`xapi`.`int_problem_results`", "raw_code": "-- select one record per (learner, problem, course, org) tuple\n-- contains either the first successful attempt\n-- or the most recent unsuccessful attempt\n\n\n-- find the timestamp of the earliest successful response\n-- this will be used to pick the xAPI event corresponding to that submission\nwith successful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n min(emission_time) as first_success_at\n from\n {{ ref('fact_problem_responses') }}\n where\n -- clickhouse throws an error when shortening this to `where success`\n success = true\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- for all learners who did not submit a successful response,\n-- find the timestamp of the most recent unsuccessful response\nunsuccessful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n max(emission_time) as last_response_at\n from\n {{ ref('fact_problem_responses') }}\n where\n actor_id not in (select distinct actor_id from successful_responses)\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- combine result sets for successful and unsuccessful problem submissions\nresponses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n first_success_at as emission_time\n from\n successful_responses\n union all\n select\n org,\n course_key,\n problem_id,\n actor_id,\n last_response_at as emission_time\n from\n unsuccessful_responses\n)\n\nselect\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts\nfrom\n {{ ref('fact_problem_responses') }} problem_responses\n join responses\n using (org, course_key, problem_id, actor_id, emission_time)", "language": "sql", "refs": [{"name": "fact_problem_responses", "package": null, "version": null}, {"name": "fact_problem_responses", "package": null, "version": null}, {"name": "fact_problem_responses", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.fact_problem_responses"]}, "compiled_path": "target/compiled/aspects/models/problems/int_problem_results.sql", "compiled": true, "compiled_code": "-- select one record per (learner, problem, course, org) tuple\n-- contains either the first successful attempt\n-- or the most recent unsuccessful attempt\n\n\n-- find the timestamp of the earliest successful response\n-- this will be used to pick the xAPI event corresponding to that submission\nwith successful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n min(emission_time) as first_success_at\n from\n `xapi`.`fact_problem_responses`\n where\n -- clickhouse throws an error when shortening this to `where success`\n success = true\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- for all learners who did not submit a successful response,\n-- find the timestamp of the most recent unsuccessful response\nunsuccessful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n max(emission_time) as last_response_at\n from\n `xapi`.`fact_problem_responses`\n where\n actor_id not in (select distinct actor_id from successful_responses)\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- combine result sets for successful and unsuccessful problem submissions\nresponses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n first_success_at as emission_time\n from\n successful_responses\n union all\n select\n org,\n course_key,\n problem_id,\n actor_id,\n last_response_at as emission_time\n from\n unsuccessful_responses\n)\n\nselect\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts\nfrom\n `xapi`.`fact_problem_responses` problem_responses\n join responses\n using (org, course_key, problem_id, actor_id, emission_time)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_enrollments": {"database": "", "schema": "xapi", "name": "fact_enrollments", "resource_type": "model", "package_name": "aspects", "path": "enrollment/fact_enrollments.sql", "original_file_path": "models/enrollment/fact_enrollments.sql", "unique_id": "model.aspects.fact_enrollments", "fqn": ["aspects", "enrollment", "fact_enrollments"], "alias": "fact_enrollments", "checksum": {"name": "sha256", "checksum": "9b892578d56e433cab6a0206b773cf5d32c6787b76401c0f2bb1029a551e7217"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "A record for each enrollment event", "columns": {"emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "DateTime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "enrollment_mode": {"name": "enrollment_mode", "description": "", "meta": {}, "data_type": "LowCardinality(String)", "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Whether a learner is actively enrolled in a course", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/enrollment/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {"materialized": "view"}, "created_at": 1705094502.0824118, "relation_name": "`xapi`.`fact_enrollments`", "raw_code": "with enrollments as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n enrollment_mode,\n splitByString('/', verb_id)[-1] as enrollment_status\n from\n {{ ref('enrollment_events') }}\n)\n\nselect\n enrollments.emission_time as emission_time,\n enrollments.org as org,\n enrollments.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n enrollments.actor_id as actor_id,\n enrollments.enrollment_mode as enrollment_mode,\n enrollments.enrollment_status as enrollment_status\nfrom\n enrollments\n join {{ source('event_sink', 'course_names')}} courses\n on enrollments.course_key = courses.course_key", "language": "sql", "refs": [{"name": "enrollment_events", "package": null, "version": null}], "sources": [["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_names", "model.aspects.enrollment_events"]}, "compiled_path": "target/compiled/aspects/models/enrollment/fact_enrollments.sql", "compiled": true, "compiled_code": "with enrollments as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n enrollment_mode,\n splitByString('/', verb_id)[-1] as enrollment_status\n from\n `xapi`.`enrollment_events`\n)\n\nselect\n enrollments.emission_time as emission_time,\n enrollments.org as org,\n enrollments.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n enrollments.actor_id as actor_id,\n enrollments.enrollment_mode as enrollment_mode,\n enrollments.enrollment_status as enrollment_status\nfrom\n enrollments\n join `event_sink`.`course_names` courses\n on enrollments.course_key = courses.course_key", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.enrollment_events": {"database": "", "schema": "xapi", "name": "enrollment_events", "resource_type": "model", "package_name": "aspects", "path": "enrollment/enrollment_events.sql", "original_file_path": "models/enrollment/enrollment_events.sql", "unique_id": "model.aspects.enrollment_events", "fqn": ["aspects", "enrollment", "enrollment_events"], "alias": "enrollment_events", "checksum": {"name": "sha256", "checksum": "187123b5b5f2bfc9bf7977162789f45fb3834a16f73cca378a2555a2442828d7"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, emission_time, actor_id, enrollment_mode, event_id)", "primary_key": "(org, course_key)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key)", "order_by": "(org, course_key, emission_time, actor_id, enrollment_mode, event_id)"}, "created_at": 1705094501.6787083, "relation_name": "`xapi`.`enrollment_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key)',\n order_by='(org, course_key, emission_time, actor_id, enrollment_mode, event_id)'\n ) }}\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event_str, '$.object.definition.extensions.\"https://w3id.org/xapi/acrossx/extensions/type\"') AS enrollment_mode\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE verb_id IN (\n 'http://adlnet.gov/expapi/verbs/registered',\n 'http://id.tincanapi.com/verb/unregistered'\n)", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/enrollment/enrollment_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event_str, '$.object.definition.extensions.\"https://w3id.org/xapi/acrossx/extensions/type\"') AS enrollment_mode\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN (\n 'http://adlnet.gov/expapi/verbs/registered',\n 'http://id.tincanapi.com/verb/unregistered'\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_navigation": {"database": "", "schema": "xapi", "name": "fact_navigation", "resource_type": "model", "package_name": "aspects", "path": "navigation/fact_navigation.sql", "original_file_path": "models/navigation/fact_navigation.sql", "unique_id": "model.aspects.fact_navigation", "fqn": ["aspects", "navigation", "fact_navigation"], "alias": "fact_navigation", "checksum": {"name": "sha256", "checksum": "3e0c52c42cac487e47832f166410ceea1c8253ef99357cd1f3e3de372248d87d"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "A view of navigation_events enriched with course and block metadata", "columns": {"emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "datetime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "block_id": {"name": "block_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "block_name": {"name": "block_name", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "block_name_with_location": {"name": "block_name_with_location", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "object_type": {"name": "object_type", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "starting_position": {"name": "starting_position", "description": "The tab in the unit navigation bar that the learner was viewing before clicking a link", "meta": {}, "data_type": "int64", "constraints": [], "quote": null, "tags": []}, "ending_point": {"name": "ending_point", "description": "The tab in the unit navigation bar that the learner selected to navigate to", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/navigation/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094502.0928984, "relation_name": "`xapi`.`fact_navigation`", "raw_code": "select\n navigation.emission_time as emission_time,\n navigation.org as org,\n navigation.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n navigation.actor_id as actor_id,\n navigation.block_id as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as block_name_with_location,\n navigation.object_type as object_type,\n navigation.starting_position as starting_position,\n navigation.ending_point as ending_point\nfrom\n {{ ref('navigation_events') }} navigation\n join {{ ref('dim_course_blocks') }} blocks\n on (navigation.course_key = blocks.course_key\n and navigation.block_id = blocks.block_id)", "language": "sql", "refs": [{"name": "navigation_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.navigation_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/navigation/fact_navigation.sql", "compiled": true, "compiled_code": "select\n navigation.emission_time as emission_time,\n navigation.org as org,\n navigation.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n navigation.actor_id as actor_id,\n navigation.block_id as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as block_name_with_location,\n navigation.object_type as object_type,\n navigation.starting_position as starting_position,\n navigation.ending_point as ending_point\nfrom\n `xapi`.`navigation_events` navigation\n join `xapi`.`dim_course_blocks` blocks\n on (navigation.course_key = blocks.course_key\n and navigation.block_id = blocks.block_id)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.navigation_events": {"database": "", "schema": "xapi", "name": "navigation_events", "resource_type": "model", "package_name": "aspects", "path": "navigation/navigation_events.sql", "original_file_path": "models/navigation/navigation_events.sql", "unique_id": "model.aspects.navigation_events", "fqn": ["aspects", "navigation", "navigation_events"], "alias": "navigation_events", "checksum": {"name": "sha256", "checksum": "e61758b7f9f2c24424e42b03608f740bc12ca8a17aa123570f7d4a957c03035b"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, object_type, emission_time, actor_id, starting_position, event_id)", "primary_key": "(org, course_key, object_type)"}, "tags": [], "description": "A materialized view for xAPI events related to course navigation", "columns": {"event_id": {"name": "event_id", "description": "", "meta": {}, "data_type": "uuid", "constraints": [], "quote": null, "tags": []}, "emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "datetime", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "block_id": {"name": "block_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "verb_id": {"name": "verb_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "object_type": {"name": "object_type", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "starting_position": {"name": "starting_position", "description": "The tab in the unit navigation bar that the learner was viewing before clicking a link", "meta": {}, "data_type": "int64", "constraints": [], "quote": null, "tags": []}, "ending_point": {"name": "ending_point", "description": "The tab in the unit navigation bar that the learner selected to navigate to", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/navigation/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, object_type)", "order_by": "(org, course_key, object_type, emission_time, actor_id, starting_position, event_id)"}, "created_at": 1705094502.0913975, "relation_name": "`xapi`.`navigation_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, object_type)',\n order_by='(org, course_key, object_type, emission_time, actor_id, starting_position, event_id)'\n ) }}\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n splitByString('/xblock/', object_id)[-1] as block_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractString(event_str, 'object', 'definition', 'type') AS object_type,\n -- clicking a link and selecting a module outline have no starting-position field\n if (\n object_type in (\n 'http://adlnet.gov/expapi/activities/link',\n 'http://adlnet.gov/expapi/activities/module'\n ),\n 0,\n JSONExtractInt(\n event_str,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/starting-position'\n )\n ) AS starting_position,\n JSONExtractString(\n event_str,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/ending-point'\n ) AS ending_point\nFROM\n {{ ref('xapi_events_all_parsed') }}\nWHERE verb_id IN (\n 'https://w3id.org/xapi/dod-isd/verbs/navigated'\n)", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/navigation/navigation_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n splitByString('/xblock/', object_id)[-1] as block_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractString(event_str, 'object', 'definition', 'type') AS object_type,\n -- clicking a link and selecting a module outline have no starting-position field\n if (\n object_type in (\n 'http://adlnet.gov/expapi/activities/link',\n 'http://adlnet.gov/expapi/activities/module'\n ),\n 0,\n JSONExtractInt(\n event_str,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/starting-position'\n )\n ) AS starting_position,\n JSONExtractString(\n event_str,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/ending-point'\n ) AS ending_point\nFROM\n `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN (\n 'https://w3id.org/xapi/dod-isd/verbs/navigated'\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_completions": {"database": "", "schema": "xapi", "name": "fact_completions", "resource_type": "model", "package_name": "aspects", "path": "completion/fact_completions.sql", "original_file_path": "models/completion/fact_completions.sql", "unique_id": "model.aspects.fact_completions", "fqn": ["aspects", "completion", "fact_completions"], "alias": "fact_completions", "checksum": {"name": "sha256", "checksum": "e6a57f59728805c8e854fa05615b69fb3ebd0b4d1531b3441bfe5cf2dcd75627"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record per completion events for component", "columns": {"emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "DateTime64(3)", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_id": {"name": "entity_id", "description": "The block ID or course key for the graded entity", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_name": {"name": "entity_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_name_with_location": {"name": "entity_name_with_location", "description": "", "meta": {}, "data_type": "Nullable(String)", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "scaled_progress": {"name": "scaled_progress", "description": "A ratio between 0 and 1, inclusive, of the learner's progress", "meta": {}, "data_type": "Float32", "constraints": [], "quote": null, "tags": []}, "completion_bucket": {"name": "completion_bucket", "description": "A displayable value of progress sorted into 10% buckets. Useful for grouping progress together to show high-level learner performance", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/completion/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094502.0955868, "relation_name": "`xapi`.`fact_completions`", "raw_code": "with completions as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n progress_percent,\n if(\n object_id like '%/course/%',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n cast(progress_percent as Float)/100 as scaled_progress\n from\n {{ ref('completion_events') }}\n)\n\nselect\n completions.emission_time as emission_time,\n completions.org as org,\n completions.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n completions.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n completions.actor_id as actor_id,\n cast(completions.scaled_progress as Float) as scaled_progress,\n case\n when scaled_progress >= 0.9 then '90-100%'\n when scaled_progress >= 0.8 and scaled_progress < 0.9 then '80-89%'\n when scaled_progress >= 0.7 and scaled_progress < 0.8 then '70-79%'\n when scaled_progress >= 0.6 and scaled_progress < 0.7 then '60-69%'\n when scaled_progress >= 0.5 and scaled_progress < 0.6 then '50-59%'\n when scaled_progress >= 0.4 and scaled_progress < 0.5 then '40-49%'\n when scaled_progress >= 0.3 and scaled_progress < 0.4 then '30-39%'\n when scaled_progress >= 0.2 and scaled_progress < 0.3 then '20-29%'\n when scaled_progress >= 0.1 and scaled_progress < 0.2 then '10-19%'\n else '0-9%'\n end as completion_bucket\nfrom\n completions\n join {{ source('event_sink', 'course_names')}} courses\n on completions.course_key = courses.course_key\n left join {{ source('event_sink', 'course_block_names') }} blocks\n on completions.entity_id = blocks.location", "language": "sql", "refs": [{"name": "completion_events", "package": null, "version": null}], "sources": [["event_sink", "course_block_names"], ["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names", "model.aspects.completion_events"]}, "compiled_path": "target/compiled/aspects/models/completion/fact_completions.sql", "compiled": true, "compiled_code": "with completions as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n progress_percent,\n if(\n object_id like '%/course/%',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n cast(progress_percent as Float)/100 as scaled_progress\n from\n `xapi`.`completion_events`\n)\n\nselect\n completions.emission_time as emission_time,\n completions.org as org,\n completions.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n completions.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n completions.actor_id as actor_id,\n cast(completions.scaled_progress as Float) as scaled_progress,\n case\n when scaled_progress >= 0.9 then '90-100%'\n when scaled_progress >= 0.8 and scaled_progress < 0.9 then '80-89%'\n when scaled_progress >= 0.7 and scaled_progress < 0.8 then '70-79%'\n when scaled_progress >= 0.6 and scaled_progress < 0.7 then '60-69%'\n when scaled_progress >= 0.5 and scaled_progress < 0.6 then '50-59%'\n when scaled_progress >= 0.4 and scaled_progress < 0.5 then '40-49%'\n when scaled_progress >= 0.3 and scaled_progress < 0.4 then '30-39%'\n when scaled_progress >= 0.2 and scaled_progress < 0.3 then '20-29%'\n when scaled_progress >= 0.1 and scaled_progress < 0.2 then '10-19%'\n else '0-9%'\n end as completion_bucket\nfrom\n completions\n join `event_sink`.`course_names` courses\n on completions.course_key = courses.course_key\n left join `event_sink`.`course_block_names` blocks\n on completions.entity_id = blocks.location", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.completion_events": {"database": "", "schema": "xapi", "name": "completion_events", "resource_type": "model", "package_name": "aspects", "path": "completion/completion_events.sql", "original_file_path": "models/completion/completion_events.sql", "unique_id": "model.aspects.completion_events", "fqn": ["aspects", "completion", "completion_events"], "alias": "completion_events", "checksum": {"name": "sha256", "checksum": "fae8ff8ab88e66030da09e361f4179fa46255306fcc95e04bfe0f4daa40c034f"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)"}, "created_at": 1705094501.6969666, "relation_name": "`xapi`.`completion_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)'\n ) }}\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event_str, '$.result.extensions.\"https://w3id.org/xapi/cmi5/result/extensions/progress\"') AS progress_percent\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE verb_id = 'http://adlnet.gov/expapi/verbs/progressed'", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/completion/completion_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event_str, '$.result.extensions.\"https://w3id.org/xapi/cmi5/result/extensions/progress\"') AS progress_percent\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id = 'http://adlnet.gov/expapi/verbs/progressed'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "test.aspects.learner_problem_summary_uniqueness": {"database": "", "schema": "xapi", "name": "learner_problem_summary_uniqueness", "resource_type": "test", "package_name": "aspects", "path": "learner_problem_summary_uniqueness.sql", "original_file_path": "tests/learner_problem_summary_uniqueness.sql", "unique_id": "test.aspects.learner_problem_summary_uniqueness", "fqn": ["aspects", "learner_problem_summary_uniqueness"], "alias": "learner_problem_summary_uniqueness", "checksum": {"name": "sha256", "checksum": "9cb84d9dc15e82589de6c3cbb6b1c97e7cde37513a6399754e490a4453802244"}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094501.7906651, "relation_name": null, "raw_code": "select\n org,\n course_key,\n problem_id,\n actor_id,\n count(*) as num_rows\nfrom\n {{ ref('fact_learner_problem_summary') }}\ngroup by\n org,\n course_key,\n problem_id,\n actor_id\nhaving num_rows > 1", "language": "sql", "refs": [{"name": "fact_learner_problem_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.fact_learner_problem_summary"]}, "compiled_path": "target/compiled/aspects/tests/learner_problem_summary_uniqueness.sql", "compiled": true, "compiled_code": "select\n org,\n course_key,\n problem_id,\n actor_id,\n count(*) as num_rows\nfrom\n `xapi`.`fact_learner_problem_summary`\ngroup by\n org,\n course_key,\n problem_id,\n actor_id\nhaving num_rows > 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}}, "test.aspects.problem_results_uniqueness": {"database": "", "schema": "xapi", "name": "problem_results_uniqueness", "resource_type": "test", "package_name": "aspects", "path": "problem_results_uniqueness.sql", "original_file_path": "tests/problem_results_uniqueness.sql", "unique_id": "test.aspects.problem_results_uniqueness", "fqn": ["aspects", "problem_results_uniqueness"], "alias": "problem_results_uniqueness", "checksum": {"name": "sha256", "checksum": "d21bd7a3a03835f0d1c3ba9edb31a94067fffa2450bb56ceed607997f41524b7"}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094501.7962756, "relation_name": null, "raw_code": "-- problem_results should only have one record for the following\n-- combination of values:\n-- actor_id, problem_id, course_id, org\n\nselect\n org,\n course_key,\n problem_id,\n actor_id,\n responses,\n count(*) as num_rows\nfrom\n {{ ref('int_problem_results') }}\ngroup by\n org,\n course_key,\n problem_id,\n actor_id,\n responses\nhaving num_rows > 1", "language": "sql", "refs": [{"name": "int_problem_results", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.int_problem_results"]}, "compiled_path": "target/compiled/aspects/tests/problem_results_uniqueness.sql", "compiled": true, "compiled_code": "-- problem_results should only have one record for the following\n-- combination of values:\n-- actor_id, problem_id, course_id, org\n\nselect\n org,\n course_key,\n problem_id,\n actor_id,\n responses,\n count(*) as num_rows\nfrom\n `xapi`.`int_problem_results`\ngroup by\n org,\n course_key,\n problem_id,\n actor_id,\n responses\nhaving num_rows > 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}}, "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f": {"test_metadata": {"name": "accepted_values", "kwargs": {"values": ["course", "subsection", "problem"], "column_name": "grade_type", "model": "{{ get_where_subquery(ref('fact_grades')) }}"}, "namespace": null}, "database": "", "schema": "xapi", "name": "accepted_values_fact_grades_grade_type__course__subsection__problem", "resource_type": "test", "package_name": "aspects", "path": "accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87.sql", "original_file_path": "models/grading/schema.yml", "unique_id": "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f", "fqn": ["aspects", "grading", "accepted_values_fact_grades_grade_type__course__subsection__problem"], "alias": "accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"alias": "accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87"}, "created_at": 1705094502.053135, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87\") }}", "language": "sql", "refs": [{"name": "fact_grades", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.aspects.fact_grades"]}, "compiled_path": "target/compiled/aspects/models/grading/schema.yml/accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87.sql", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n grade_type as value_field,\n count(*) as n_records\n\n from `xapi`.`fact_grades`\n group by grade_type\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'course','subsection','problem'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "grade_type", "file_key_name": "models.fact_grades", "attached_node": "model.aspects.fact_grades"}, "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da": {"test_metadata": {"name": "not_null", "kwargs": {"column_name": "success", "model": "{{ get_where_subquery(ref('fact_learner_problem_summary')) }}"}, "namespace": null}, "database": "", "schema": "xapi", "name": "not_null_fact_learner_problem_summary_success", "resource_type": "test", "package_name": "aspects", "path": "not_null_fact_learner_problem_summary_success.sql", "original_file_path": "models/problems/schema.yml", "unique_id": "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da", "fqn": ["aspects", "problems", "not_null_fact_learner_problem_summary_success"], "alias": "not_null_fact_learner_problem_summary_success", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094502.077382, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "fact_learner_problem_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.aspects.fact_learner_problem_summary"]}, "compiled_path": "target/compiled/aspects/models/problems/schema.yml/not_null_fact_learner_problem_summary_success.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect success\nfrom `xapi`.`fact_learner_problem_summary`\nwhere success is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "success", "file_key_name": "models.fact_learner_problem_summary", "attached_node": "model.aspects.fact_learner_problem_summary"}, "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b": {"test_metadata": {"name": "not_null", "kwargs": {"column_name": "attempts", "model": "{{ get_where_subquery(ref('fact_learner_problem_summary')) }}"}, "namespace": null}, "database": "", "schema": "xapi", "name": "not_null_fact_learner_problem_summary_attempts", "resource_type": "test", "package_name": "aspects", "path": "not_null_fact_learner_problem_summary_attempts.sql", "original_file_path": "models/problems/schema.yml", "unique_id": "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b", "fqn": ["aspects", "problems", "not_null_fact_learner_problem_summary_attempts"], "alias": "not_null_fact_learner_problem_summary_attempts", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1705094502.0794737, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "fact_learner_problem_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.aspects.fact_learner_problem_summary"]}, "compiled_path": "target/compiled/aspects/models/problems/schema.yml/not_null_fact_learner_problem_summary_attempts.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect attempts\nfrom `xapi`.`fact_learner_problem_summary`\nwhere attempts is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "attempts", "file_key_name": "models.fact_learner_problem_summary", "attached_node": "model.aspects.fact_learner_problem_summary"}, "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4": {"test_metadata": {"name": "accepted_values", "kwargs": {"values": ["registered", "unregistered"], "column_name": "enrollment_status", "model": "{{ get_where_subquery(ref('fact_enrollments')) }}"}, "namespace": null}, "database": "", "schema": "xapi", "name": "accepted_values_fact_enrollments_enrollment_status__registered__unregistered", "resource_type": "test", "package_name": "aspects", "path": "accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9.sql", "original_file_path": "models/enrollment/schema.yml", "unique_id": "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4", "fqn": ["aspects", "enrollment", "accepted_values_fact_enrollments_enrollment_status__registered__unregistered"], "alias": "accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"alias": "accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9"}, "created_at": 1705094502.083498, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9\") }}", "language": "sql", "refs": [{"name": "fact_enrollments", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.aspects.fact_enrollments"]}, "compiled_path": "target/compiled/aspects/models/enrollment/schema.yml/accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9.sql", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n enrollment_status as value_field,\n count(*) as n_records\n\n from `xapi`.`fact_enrollments`\n group by enrollment_status\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'registered','unregistered'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "enrollment_status", "file_key_name": "models.fact_enrollments", "attached_node": "model.aspects.fact_enrollments"}}, "sources": {"source.aspects.xapi.xapi_events_all": {"database": "xapi", "schema": "xapi", "name": "xapi_events_all", "resource_type": "source", "package_name": "aspects", "path": "models/base/sources.yml", "original_file_path": "models/base/sources.yml", "unique_id": "source.aspects.xapi.xapi_events_all", "fqn": ["aspects", "base", "xapi", "xapi_events_all"], "source_name": "xapi", "source_description": "the xapi database in clickhouse", "loader": "", "identifier": "xapi_events_all", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": null, "freshness": {"warn_after": {"count": null, "period": null}, "error_after": {"count": null, "period": null}, "filter": null}, "external": null, "description": "Base table for raw xAPI events", "columns": {"event_id": {"name": "event_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "event": {"name": "event", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "event_str": {"name": "event_str", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "`xapi`.`xapi_events_all`", "created_at": 1705094502.097726}, "source.aspects.event_sink.course_block_names": {"database": "event_sink", "schema": "event_sink", "name": "course_block_names", "resource_type": "source", "package_name": "aspects", "path": "models/base/sources.yml", "original_file_path": "models/base/sources.yml", "unique_id": "source.aspects.event_sink.course_block_names", "fqn": ["aspects", "base", "event_sink", "course_block_names"], "source_name": "event_sink", "source_description": "", "loader": "", "identifier": "course_block_names", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": null, "freshness": {"warn_after": {"count": null, "period": null}, "error_after": {"count": null, "period": null}, "filter": null}, "external": null, "description": "", "columns": {"location": {"name": "location", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "block_name": {"name": "block_name", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "graded": {"name": "graded", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "display_name_with_location": {"name": "display_name_with_location", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "`event_sink`.`course_block_names`", "created_at": 1705094502.0980172}, "source.aspects.event_sink.course_names": {"database": "event_sink", "schema": "event_sink", "name": "course_names", "resource_type": "source", "package_name": "aspects", "path": "models/base/sources.yml", "original_file_path": "models/base/sources.yml", "unique_id": "source.aspects.event_sink.course_names", "fqn": ["aspects", "base", "event_sink", "course_names"], "source_name": "event_sink", "source_description": "", "loader": "", "identifier": "course_names", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": null, "freshness": {"warn_after": {"count": null, "period": null}, "error_after": {"count": null, "period": null}, "filter": null}, "external": null, "description": "", "columns": {"course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "`event_sink`.`course_names`", "created_at": 1705094502.0982409}}, "macros": {"macro.aspects.get_problem_id": {"name": "get_problem_id", "resource_type": "macro", "package_name": "aspects", "path": "macros/get_problem_id.sql", "original_file_path": "macros/get_problem_id.sql", "unique_id": "macro.aspects.get_problem_id", "macro_sql": "{% macro get_problem_id(object_id) %}\n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1032407, "supported_languages": null}, "macro.aspects.on_cluster": {"name": "on_cluster", "resource_type": "macro", "package_name": "aspects", "path": "macros/cluster_macros.sql", "original_file_path": "macros/cluster_macros.sql", "unique_id": "macro.aspects.on_cluster", "macro_sql": "{% macro on_cluster() -%}\n {%- if env_var(\"CLICKHOUSE_CLUSTER_NAME\", \"\") != \"\" -%}\n ON CLUSTER {{ env_var(\"CLICKHOUSE_CLUSTER_NAME\") }}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1040955, "supported_languages": null}, "macro.aspects.get_engine": {"name": "get_engine", "resource_type": "macro", "package_name": "aspects", "path": "macros/cluster_macros.sql", "original_file_path": "macros/cluster_macros.sql", "unique_id": "macro.aspects.get_engine", "macro_sql": "{% macro get_engine(engine) -%}\n {%- if env_var(\"CLICKHOUSE_CLUSTER_NAME\", \"\") != \"\" -%}\n {{ \"Replicated\" + engine }}\n {% else %}\n {{ engine }}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1046538, "supported_languages": null}, "macro.aspects.generate_schema_name": {"name": "generate_schema_name", "resource_type": "macro", "package_name": "aspects", "path": "macros/get_custom_schema.sql", "original_file_path": "macros/get_custom_schema.sql", "unique_id": "macro.aspects.generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name, node) -%}\n {{ generate_schema_name_for_env(custom_schema_name, node) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.generate_schema_name_for_env"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1050873, "supported_languages": null}, "macro.dbt_clickhouse.one_alter_relation": {"name": "one_alter_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.one_alter_relation", "macro_sql": "{% macro one_alter_relation(relation, alter_comments) %}\n alter table {{ relation }} {{ on_cluster_clause(relation) }} {{ alter_comments }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.107088, "supported_languages": null}, "macro.dbt_clickhouse.one_alter_column_comment": {"name": "one_alter_column_comment", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.one_alter_column_comment", "macro_sql": "{% macro one_alter_column_comment(relation, column_name, comment) %}\n alter table {{ relation }} {{ on_cluster_clause(relation) }} comment column {{ column_name }} '{{ comment }}'\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1076667, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__alter_relation_comment": {"name": "clickhouse__alter_relation_comment", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__alter_relation_comment", "macro_sql": "{% macro clickhouse__alter_relation_comment(relation, comment) %}\n alter table {{ relation }} {{ on_cluster_clause(relation) }} modify comment '{{ comment }}'\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1080577, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__persist_docs": {"name": "clickhouse__persist_docs", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__persist_docs", "macro_sql": "{% macro clickhouse__persist_docs(relation, model, for_relation, for_columns) %}\n {%- set alter_comments = [] %}\n\n {%- if for_relation and config.persist_relation_docs() and model.description -%}\n {% set escaped_comment = clickhouse_escape_comment(model.description) %}\n {% do alter_comments.append(\"modify comment {comment}\".format(comment=escaped_comment)) %}\n {%- endif -%}\n\n {%- if for_columns and config.persist_column_docs() and model.columns -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n {% for column_name in model.columns if (column_name in existing_columns) %}\n {%- set comment = model.columns[column_name]['description'] -%}\n {%- if comment %}\n {% set escaped_comment = clickhouse_escape_comment(comment) %}\n {% do alter_comments.append(\"comment column {column_name} {comment}\".format(column_name=column_name, comment=escaped_comment)) %}\n {%- endif %}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if alter_comments | length > 0 -%}\n {% do run_query(one_alter_relation(relation, alter_comments|join(', '))) %}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse_escape_comment", "macro.dbt.run_query", "macro.dbt_clickhouse.one_alter_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.110699, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse_escape_comment": {"name": "clickhouse_escape_comment", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.clickhouse_escape_comment", "macro_sql": "{% macro clickhouse_escape_comment(comment) -%}\n {% if adapter.is_before_version('21.9.2.17') %}\n {% do exceptions.raise_compiler_error('Unsupported ClickHouse version for using heredoc syntax') %}\n {% endif %}\n {% if comment is not string %}\n {% do exceptions.raise_compiler_error('cannot escape a non-string: ' ~ comment) %}\n {% endif %}\n {%- set magic = '$dbt_comment_literal_block$' -%}\n {%- if magic in comment -%}\n {%- do exceptions.raise_compiler_error('The string ' ~ magic ~ ' is not allowed in comments.') -%}\n {%- endif -%}\n {{ magic }}{{ comment }}{{ magic }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1119678, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_assert_columns_equivalent": {"name": "clickhouse__get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/column_spec_ddl.sql", "original_file_path": "macros/column_spec_ddl.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_assert_columns_equivalent", "macro_sql": "{% macro clickhouse__get_assert_columns_equivalent(sql) -%}\n {%- set user_defined_columns = model['columns'] -%}\n\n {%- if not user_defined_columns -%}\n {{ exceptions.raise_contract_error([], []) }}\n {%- endif -%}\n\n {%- set yaml_columns = user_defined_columns.values() -%}\n\n {%- set sql_file_provided_columns = adapter.get_column_schema_from_query(sql) -%}\n {%- set sql_columns = adapter.format_columns(sql_file_provided_columns) -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- for sql_col in sql_columns -%}\n {%- set yaml_col = [] -%}\n {%- for this_col in yaml_columns -%}\n {%- if this_col['name'] == sql_col['name'] -%}\n {%- do yaml_col.append(this_col) -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if not yaml_col -%}\n {#-- Column with name not found in yaml #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- if sql_col['data_type'] != yaml_col[0]['data_type'] -%}\n {#-- Column data types don't match #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- endfor -%}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1154678, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_catalog": {"name": "clickhouse__get_catalog", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_catalog", "macro_sql": "{% macro clickhouse__get_catalog(information_schema, schemas) -%}\n {%- call statement('catalog', fetch_result=True) -%}\n select\n '' as table_database,\n columns.database as table_schema,\n columns.table as table_name,\n if(tables.engine not in ('MaterializedView', 'View'), 'table', 'view') as table_type,\n nullIf(tables.comment, '') as table_comment,\n columns.name as column_name,\n columns.position as column_index,\n columns.type as column_type,\n nullIf(columns.comment, '') as column_comment,\n null as table_owner\n from system.columns as columns\n join system.tables as tables on tables.database = columns.database and tables.name = columns.table\n where database != 'system' and\n (\n {%- for schema in schemas -%}\n columns.database = '{{ schema }}'\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n order by columns.database, columns.table, columns.position\n {%- endcall -%}\n {{ return(load_result('catalog').table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1166627, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__list_schemas": {"name": "clickhouse__list_schemas", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__list_schemas", "macro_sql": "{% macro clickhouse__list_schemas(database) %}\n {% call statement('list_schemas', fetch_result=True, auto_begin=False) %}\n select name from system.databases\n {% endcall %}\n {{ return(load_result('list_schemas').table) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1220257, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__create_schema": {"name": "clickhouse__create_schema", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_schema", "macro_sql": "{% macro clickhouse__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create database if not exists {{ relation.without_identifier().include(database=False) }}\n {{ on_cluster_clause(relation)}}\n {{ adapter.clickhouse_db_engine_clause() }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1226783, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__drop_schema": {"name": "clickhouse__drop_schema", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__drop_schema", "macro_sql": "{% macro clickhouse__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop database if exists {{ relation.without_identifier().include(database=False) }} {{ on_cluster_clause(relation)}}\n {%- endcall -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1232202, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__list_relations_without_caching": {"name": "clickhouse__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__list_relations_without_caching", "macro_sql": "{% macro clickhouse__list_relations_without_caching(schema_relation) %}\n {% call statement('list_relations_without_caching', fetch_result=True) -%}\n select\n t.name as name,\n t.database as schema,\n if(engine not in ('MaterializedView', 'View'), 'table', 'view') as type,\n db.engine as db_engine,\n {%- if adapter.get_clickhouse_cluster_name() -%}\n count(distinct _shard_num) > 1 as is_on_cluster\n from clusterAllReplicas({{ adapter.get_clickhouse_cluster_name() }}, system.tables) as t\n join system.databases as db on t.database = db.name\n where schema = '{{ schema_relation.schema }}'\n group by name, schema, type, db_engine\n {%- else -%}\n 0 as is_on_cluster\n from system.tables as t join system.databases as db on t.database = db.name\n where schema = '{{ schema_relation.schema }}'\n {% endif %}\n\n {% endcall %}\n {{ return(load_result('list_relations_without_caching').table) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.124183, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_columns_in_relation": {"name": "clickhouse__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_columns_in_relation", "macro_sql": "{% macro clickhouse__get_columns_in_relation(relation) -%}\n {% call statement('get_columns', fetch_result=True) %}\n select name, type from system.columns where table = '{{ relation.identifier }}'\n {% if relation.schema %}\n and database = '{{ relation.schema }}'\n {% endif %}\n order by position\n {% endcall %}\n {{ return(sql_convert_columns_in_relation(load_result('get_columns').table)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.sql_convert_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1250074, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__drop_relation": {"name": "clickhouse__drop_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__drop_relation", "macro_sql": "{% macro clickhouse__drop_relation(relation, obj_type='table') -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n {# drop relation on cluster by default if cluster is set #}\n drop {{ obj_type }} if exists {{ relation }} {{ on_cluster_clause(relation.without_identifier(), True)}}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1256533, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__rename_relation": {"name": "clickhouse__rename_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__rename_relation", "macro_sql": "{% macro clickhouse__rename_relation(from_relation, to_relation, obj_type='table') -%}\n {% call statement('drop_relation') %}\n drop {{ obj_type }} if exists {{ to_relation }} {{ on_cluster_clause(to_relation.without_identifier())}}\n {% endcall %}\n {% call statement('rename_relation') %}\n rename {{ obj_type }} {{ from_relation }} to {{ to_relation }} {{ on_cluster_clause(from_relation)}}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1265793, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__truncate_relation": {"name": "clickhouse__truncate_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__truncate_relation", "macro_sql": "{% macro clickhouse__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }} {{ on_cluster_clause(relation)}}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1270096, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__make_temp_relation": {"name": "clickhouse__make_temp_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__make_temp_relation", "macro_sql": "{% macro clickhouse__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={\"identifier\": tmp_identifier, \"schema\": None}) -%}\n {% do return(tmp_relation) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1277153, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__generate_database_name": {"name": "clickhouse__generate_database_name", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__generate_database_name", "macro_sql": "{% macro clickhouse__generate_database_name(custom_database_name=none, node=none) -%}\n {% do return('') %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1280487, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_columns_in_query": {"name": "clickhouse__get_columns_in_query", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_columns_in_query", "macro_sql": "{% macro clickhouse__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n limit 0\n {% endcall %}\n\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1287858, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__alter_column_type": {"name": "clickhouse__alter_column_type", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__alter_column_type", "macro_sql": "{% macro clickhouse__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} {{ on_cluster_clause(relation)}} modify column {{ adapter.quote(column_name) }} {{ new_column_type }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1295168, "supported_languages": null}, "macro.dbt_clickhouse.exchange_tables_atomic": {"name": "exchange_tables_atomic", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.exchange_tables_atomic", "macro_sql": "{% macro exchange_tables_atomic(old_relation, target_relation, obj_types='TABLES') %}\n\n {%- if adapter.get_clickhouse_cluster_name() is not none and obj_types == 'TABLES' and 'Replicated' in engine_clause() %}\n {%- call statement('exchange_table_sync_replica') -%}\n SYSTEM SYNC REPLICA {{ on_cluster_clause(target_relation) }} {{ target_relation.schema }}.{{ target_relation.identifier }}\n {% endcall %}\n {%- endif %}\n {%- call statement('exchange_tables_atomic') -%}\n EXCHANGE {{ obj_types }} {{ old_relation }} AND {{ target_relation }} {{ on_cluster_clause(target_relation)}}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.engine_clause", "macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.13079, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__load_csv_rows": {"name": "clickhouse__load_csv_rows", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__load_csv_rows", "macro_sql": "{% macro clickhouse__load_csv_rows(model, agate_table) %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set data_sql = adapter.get_csv_data(agate_table) %}\n\n {% set sql -%}\n insert into {{ this.render() }} ({{ cols_sql }})\n {{ adapter.get_model_query_settings(model) }}\n format CSV\n {{ data_sql }}\n {%- endset %}\n\n {% do adapter.add_query(sql, bindings=agate_table, abridge_sql_log=True) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_seed_column_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1330223, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__create_csv_table": {"name": "clickhouse__create_csv_table", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_csv_table", "macro_sql": "{% macro clickhouse__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} {{ on_cluster_clause(this) }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {{ engine_clause() }}\n {{ order_cols(label='order by') }}\n {{ partition_cols(label='partition by') }}\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt_clickhouse.engine_clause", "macro.dbt_clickhouse.order_cols", "macro.dbt_clickhouse.partition_cols", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1352565, "supported_languages": null}, "macro.dbt_clickhouse.materialization_view_clickhouse": {"name": "materialization_view_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "unique_id": "macro.dbt_clickhouse.materialization_view_clickhouse", "macro_sql": "{%- materialization view, adapter='clickhouse' -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set backup_relation = none -%}\n {%- set preexisting_backup_relation = none -%}\n {%- set preexisting_intermediate_relation = none -%}\n\n {% if existing_relation is not none %}\n {%- set backup_relation_type = existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {% if not existing_relation.can_exchange %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n {% endif %}\n {% endif %}\n\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if backup_relation is none %}\n {{ log('Creating new relation ' + target_relation.name )}}\n -- There is not existing relation, so we can just create\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n {% elif existing_relation.can_exchange %}\n -- We can do an atomic exchange, so no need for an intermediate\n {% call statement('main') -%}\n {{ get_create_view_as_sql(backup_relation, sql) }}\n {%- endcall %}\n {% do exchange_tables_atomic(backup_relation, existing_relation) %}\n {% else %}\n -- We have to use an intermediate and rename accordingly\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n {% endif %}\n\n -- cleanup\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_backup_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1428034, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.clickhouse__create_view_as": {"name": "clickhouse__create_view_as", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_view_as", "macro_sql": "{% macro clickhouse__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n {{ sql_header if sql_header is not none }}\n\n create view {{ relation.include(database=False) }} {{ on_cluster_clause(relation)}}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced %}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n as (\n {{ sql }}\n )\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1438894, "supported_languages": null}, "macro.dbt_clickhouse.materialization_table_clickhouse": {"name": "materialization_table_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.materialization_table_clickhouse", "macro_sql": "{% materialization table, adapter='clickhouse' %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set backup_relation = none -%}\n {%- set preexisting_backup_relation = none -%}\n {%- set preexisting_intermediate_relation = none -%}\n\n {% if existing_relation is not none %}\n {%- set backup_relation_type = existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {% if not existing_relation.can_exchange %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n {% endif %}\n {% endif %}\n\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if backup_relation is none %}\n {{ log('Creating new relation ' + target_relation.name )}}\n -- There is not existing relation, so we can just create\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, target_relation, sql) }}\n {%- endcall %}\n {% elif existing_relation.can_exchange %}\n -- We can do an atomic exchange, so no need for an intermediate\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, backup_relation, sql) }}\n {%- endcall %}\n {% do exchange_tables_atomic(backup_relation, existing_relation) %}\n {% else %}\n -- We have to use an intermediate and rename accordingly\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n {% endif %}\n\n -- cleanup\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_backup_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1579437, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.engine_clause": {"name": "engine_clause", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.engine_clause", "macro_sql": "{% macro engine_clause() %}\n engine = {{ config.get('engine', default='MergeTree()') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1583562, "supported_languages": null}, "macro.dbt_clickhouse.partition_cols": {"name": "partition_cols", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.partition_cols", "macro_sql": "{% macro partition_cols(label) %}\n {%- set cols = config.get('partition_by', validator=validation.any[list, basestring]) -%}\n {%- if cols is not none %}\n {%- if cols is string -%}\n {%- set cols = [cols] -%}\n {%- endif -%}\n {{ label }} (\n {%- for item in cols -%}\n {{ item }}\n {%- if not loop.last -%},{%- endif -%}\n {%- endfor -%}\n )\n {%- endif %}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1594687, "supported_languages": null}, "macro.dbt_clickhouse.primary_key_clause": {"name": "primary_key_clause", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.primary_key_clause", "macro_sql": "{% macro primary_key_clause(label) %}\n {%- set primary_key = config.get('primary_key', validator=validation.any[basestring]) -%}\n\n {%- if primary_key is not none %}\n {{ label }} {{ primary_key }}\n {%- endif %}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1601105, "supported_languages": null}, "macro.dbt_clickhouse.order_cols": {"name": "order_cols", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.order_cols", "macro_sql": "{% macro order_cols(label) %}\n {%- set cols = config.get('order_by', validator=validation.any[list, basestring]) -%}\n {%- set engine = config.get('engine', default='MergeTree()') -%}\n {%- set supported = [\n 'HDFS',\n 'MaterializedPostgreSQL',\n 'S3',\n 'EmbeddedRocksDB',\n 'Hive'\n ] -%}\n\n {%- if 'MergeTree' in engine or engine in supported %}\n {%- if cols is not none %}\n {%- if cols is string -%}\n {%- set cols = [cols] -%}\n {%- endif -%}\n {{ label }} (\n {%- for item in cols -%}\n {{ item }}\n {%- if not loop.last -%},{%- endif -%}\n {%- endfor -%}\n )\n {%- else %}\n {{ label }} (tuple())\n {%- endif %}\n {%- endif %}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1618679, "supported_languages": null}, "macro.dbt_clickhouse.on_cluster_clause": {"name": "on_cluster_clause", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.on_cluster_clause", "macro_sql": "{% macro on_cluster_clause(relation, force_sync) %}\n {% set active_cluster = adapter.get_clickhouse_cluster_name() %}\n {%- if active_cluster is not none and relation.should_on_cluster %}\n {# Add trailing whitespace to avoid problems when this clause is not last #}\n ON CLUSTER {{ active_cluster + ' ' }}\n {%- if force_sync %}\n SYNC\n {%- endif %}\n {%- endif %}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1625586, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__create_table_as": {"name": "clickhouse__create_table_as", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_table_as", "macro_sql": "{% macro clickhouse__create_table_as(temporary, relation, sql) -%}\n {% set has_contract = config.get('contract').enforced %}\n {% set create_table = create_table_or_empty(temporary, relation, sql, has_contract) %}\n {% if adapter.is_before_version('22.7.1.2484') -%}\n {{ create_table }}\n {%- else %}\n {% call statement('create_table_empty') %}\n {{ create_table }}\n {% endcall %}\n {{ clickhouse__insert_into(relation, sql, has_contract) }}\n {%- endif %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.create_table_or_empty", "macro.dbt.statement", "macro.dbt_clickhouse.clickhouse__insert_into"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1636698, "supported_languages": null}, "macro.dbt_clickhouse.create_table_or_empty": {"name": "create_table_or_empty", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.create_table_or_empty", "macro_sql": "{% macro create_table_or_empty(temporary, relation, sql, has_contract) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n {% if temporary -%}\n create temporary table {{ relation }}\n engine Memory\n {{ order_cols(label=\"order by\") }}\n {{ partition_cols(label=\"partition by\") }}\n {{ adapter.get_model_settings(model) }}\n as (\n {{ sql }}\n )\n {%- else %}\n create table {{ relation }}\n {{ on_cluster_clause(relation)}}\n {%- if has_contract%}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {%- endif %}\n {{ engine_clause() }}\n {{ order_cols(label=\"order by\") }}\n {{ primary_key_clause(label=\"primary key\") }}\n {{ partition_cols(label=\"partition by\") }}\n {{ adapter.get_model_settings(model) }}\n\n {%- if not has_contract %}\n {%- if not adapter.is_before_version('22.7.1.2484') %}\n empty\n {%- endif %}\n as (\n {{ sql }}\n )\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.order_cols", "macro.dbt_clickhouse.partition_cols", "macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt_clickhouse.engine_clause", "macro.dbt_clickhouse.primary_key_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1658063, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__insert_into": {"name": "clickhouse__insert_into", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__insert_into", "macro_sql": "{% macro clickhouse__insert_into(target_relation, sql, has_contract) %}\n {%- set dest_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') -%}\n\n insert into {{ target_relation }}\n ({{ dest_cols_csv }})\n {%- if has_contract -%}\n -- Use a subquery to get columns in the right order\n SELECT {{ dest_cols_csv }} FROM ( {{ sql }} )\n {%- else -%}\n {{ sql }}\n {{ adapter.get_model_query_settings(model) }}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1668336, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__snapshot_hash_arguments": {"name": "clickhouse__snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__snapshot_hash_arguments", "macro_sql": "{% macro clickhouse__snapshot_hash_arguments(args) -%}\n halfMD5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1715145, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__post_snapshot": {"name": "clickhouse__post_snapshot", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__post_snapshot", "macro_sql": "{% macro clickhouse__post_snapshot(staging_relation) %}\n {{ drop_relation_if_exists(staging_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1717968, "supported_languages": null}, "macro.dbt_clickhouse.build_snapshot_staging_table": {"name": "build_snapshot_staging_table", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_clickhouse.build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(False, tmp_relation, select) }}\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1727183, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__snapshot_merge_sql": {"name": "clickhouse__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__snapshot_merge_sql", "macro_sql": "{% macro clickhouse__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n {%- set valid_to_col = adapter.quote('dbt_valid_to') -%}\n\n {%- set upsert = target.derivative('__snapshot_upsert') -%}\n {% call statement('create_upsert_relation') %}\n create table if not exists {{ upsert }} as {{ target }}\n {% endcall %}\n\n {% call statement('insert_unchanged_data') %}\n insert into {{ upsert }} ({{ insert_cols_csv }})\n select {% for column in insert_cols -%}\n {{ column }} {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n from {{ target }}\n where dbt_scd_id not in (\n select {{ source }}.dbt_scd_id from {{ source }} \n )\n {% endcall %}\n\n {% call statement('insert_updated_and_deleted') %}\n insert into {{ upsert }} ({{ insert_cols_csv }})\n with updates_and_deletes as (\n select\n dbt_scd_id,\n dbt_valid_to\n from {{ source }}\n where dbt_change_type IN ('update', 'delete')\n )\n select {% for column in insert_cols %}\n {%- if column == valid_to_col -%}\n updates_and_deletes.dbt_valid_to as dbt_valid_to\n {%- else -%}\n target.{{ column }} as {{ column }}\n {%- endif %} {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n from {{ target }} target\n join updates_and_deletes on target.dbt_scd_id = updates_and_deletes.dbt_scd_id;\n {% endcall %}\n\n {% call statement('insert_new') %}\n insert into {{ upsert }} ({{ insert_cols_csv }})\n select {% for column in insert_cols -%}\n {{ column }} {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n from {{ source }}\n where {{ source }}.dbt_change_type IN ('insert');\n {% endcall %}\n\n {% if target.can_exchange %}\n {% do exchange_tables_atomic(upsert, target) %}\n {% call statement('drop_exchanged_relation') %}\n drop table if exists {{ upsert }};\n {% endcall %}\n {% else %}\n {% call statement('drop_target_relation') %}\n drop table if exists {{ target }};\n {% endcall %}\n {% call statement('rename_upsert_relation') %}\n rename table {{ upsert }} to {{ target }};\n {% endcall %}\n {% endif %}\n\n {% do return ('select 1') %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.exchange_tables_atomic"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.176758, "supported_languages": null}, "macro.dbt_clickhouse.materialization_materialized_view_clickhouse": {"name": "materialization_materialized_view_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/materialized_view.sql", "original_file_path": "macros/materializations/materialized_view.sql", "unique_id": "macro.dbt_clickhouse.materialization_materialized_view_clickhouse", "macro_sql": "\n{%- materialization materialized_view, adapter='clickhouse' -%}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set mv_relation = target_relation.derivative('_mv', 'MaterializedView') -%}\n {%- set cluster_clause = on_cluster_clause(target_relation) -%}\n\n {# look for an existing relation for the target table and create backup relations if necessary #}\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set backup_relation = none -%}\n {%- set preexisting_backup_relation = none -%}\n {%- set preexisting_intermediate_relation = none -%}\n {% if existing_relation is not none %}\n {%- set backup_relation_type = existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {% if not existing_relation.can_exchange %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n {% endif %}\n {% endif %}\n\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if backup_relation is none %}\n {{ log('Creating new materialized view ' + target_relation.name )}}\n {% call statement('main') -%}\n {{ clickhouse__get_create_materialized_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n {% elif existing_relation.can_exchange %}\n {{ log('Replacing existing materialized view' + target_relation.name) }}\n {% call statement('drop existing materialized view') %}\n drop view if exists {{ mv_relation }} {{ cluster_clause }}\n {% endcall %}\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, backup_relation, sql) }}\n {%- endcall %}\n {% do exchange_tables_atomic(backup_relation, existing_relation) %}\n {% call statement('create new materialized view') %}\n {{ clickhouse__create_mv_sql(mv_relation, existing_relation.name, cluster_clause, sql) }}\n {% endcall %}\n {% else %}\n {{ log('Replacing existing materialized view' + target_relation.name) }}\n {{ clickhouse__replace_mv(target_relation, existing_relation, intermediate_relation, backup_relation, sql) }}\n {% endif %}\n\n -- cleanup\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation, mv_relation]}) }}\n\n{%- endmaterialization -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.load_cached_relation", "macro.dbt.make_backup_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt_clickhouse.clickhouse__get_create_materialized_view_as_sql", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt_clickhouse.clickhouse__create_mv_sql", "macro.dbt_clickhouse.clickhouse__replace_mv", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1851702, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.clickhouse__get_create_materialized_view_as_sql": {"name": "clickhouse__get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/materialized_view.sql", "original_file_path": "macros/materializations/materialized_view.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_create_materialized_view_as_sql", "macro_sql": "{% macro clickhouse__get_create_materialized_view_as_sql(relation, sql) -%}\n {% call statement('create_target_table') %}\n {{ get_create_table_as_sql(False, relation, sql) }}\n {% endcall %}\n {%- set cluster_clause = on_cluster_clause(relation) -%}\n {%- set mv_relation = relation.derivative('_mv', 'MaterializedView') -%}\n {{ clickhouse__create_mv_sql(mv_relation, relation, cluster_clause, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.on_cluster_clause", "macro.dbt_clickhouse.clickhouse__create_mv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1861312, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__create_mv_sql": {"name": "clickhouse__create_mv_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/materialized_view.sql", "original_file_path": "macros/materializations/materialized_view.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_mv_sql", "macro_sql": "{% macro clickhouse__create_mv_sql(mv_relation, target_table, cluster_clause, sql) -%}\n create materialized view if not exists {{ mv_relation }} {{ cluster_clause }}\n to {{ target_table }}\n as {{ sql }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1865458, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__replace_mv": {"name": "clickhouse__replace_mv", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/materialized_view.sql", "original_file_path": "macros/materializations/materialized_view.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__replace_mv", "macro_sql": "{% macro clickhouse__replace_mv(target_relation, existing_relation, intermediate_relation, backup_relation, sql) %}\n {# drop existing materialized view while we recreate the target table #}\n {%- set cluster_clause = on_cluster_clause(target_relation) -%}\n {%- set mv_relation = target_relation.derivative('_mv', 'MaterializedView') -%}\n {% call statement('drop existing mv') -%}\n drop view if exists {{ mv_relation }} {{ cluster_clause }}\n {%- endcall %}\n\n {# recreate the target table #}\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {# now that the target table is recreated, we can finally create our new view #}\n {{ clickhouse__create_mv_sql(mv_relation, target_relation, cluster_clause, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.clickhouse__create_mv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.1880088, "supported_languages": null}, "macro.dbt_clickhouse.materialization_distributed_table_clickhouse": {"name": "materialization_distributed_table_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/distributed_table.sql", "original_file_path": "macros/materializations/distributed_table.sql", "unique_id": "macro.dbt_clickhouse.materialization_distributed_table_clickhouse", "macro_sql": "{% materialization distributed_table, adapter='clickhouse' %}\n {% set insert_distributed_sync = run_query(\"SELECT value FROM system.settings WHERE name = 'insert_distributed_sync'\")[0][0] %}\n {% if insert_distributed_sync != '1' %}\n {% do exceptions.raise_compiler_error('To use distributed materialization setting insert_distributed_sync should be set to 1') %}\n {% endif %}\n\n {%- set local_suffix = adapter.get_clickhouse_local_suffix() -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n\n {% set on_cluster = on_cluster_clause(target_relation) %}\n {% if on_cluster.strip() == '' %}\n {% do exceptions.raise_compiler_error('To use distributed materialization cluster setting in dbt profile must be set') %}\n {% endif %}\n\n {% set existing_relation_local = existing_relation.incorporate(path={\"identifier\": this.identifier + local_suffix}) if existing_relation is not none else none %}\n {% set target_relation_local = target_relation.incorporate(path={\"identifier\": this.identifier + local_suffix}) if target_relation is not none else none %}\n\n {%- set backup_relation = none -%}\n {%- set preexisting_backup_relation = none -%}\n {%- set preexisting_intermediate_relation = none -%}\n\n {% if existing_relation_local is not none %}\n {%- set backup_relation_type = existing_relation_local.type -%}\n {%- set backup_relation = make_backup_relation(target_relation_local, backup_relation_type) -%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {% if not existing_relation.can_exchange %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation_local) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n {% endif %}\n {% endif %}\n {% set view_relation = default__make_temp_relation(target_relation, '__dbt_tmp') %}\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(view_relation) }}\n\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {% call statement('main') %}\n {{ create_view_as(view_relation, sql) }}\n {% endcall %}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if backup_relation is none %}\n {{ create_distributed_local_table(target_relation, target_relation_local, view_relation) }}\n {% elif existing_relation.can_exchange %}\n -- We can do an atomic exchange, so no need for an intermediate\n {% call statement('main') -%}\n {{ create_empty_table_from_relation(backup_relation, view_relation) }}\n {%- endcall %}\n {% do exchange_tables_atomic(backup_relation, existing_relation_local) %}\n {% else %}\n {% do run_query(create_empty_table_from_relation(intermediate_relation, view_relation)) or '' %}\n {{ adapter.rename_relation(existing_relation_local, backup_relation) }}\n {{ adapter.rename_relation(intermediate_relation, target_relation_local) }}\n {{ create_distributed_table(target_relation, target_relation_local) }}\n {% endif %}\n {% do run_query(clickhouse__insert_into(target_relation, sql)) or '' %}\n {{ drop_relation_if_exists(view_relation) }}\n -- cleanup\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation_local, grant_config, should_revoke=should_revoke) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n {{ adapter.commit() }}\n {{ drop_relation_if_exists(backup_relation) }}\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.load_cached_relation", "macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.make_backup_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.default__make_temp_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_view_as", "macro.dbt_clickhouse.create_distributed_local_table", "macro.dbt_clickhouse.create_empty_table_from_relation", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt_clickhouse.create_distributed_table", "macro.dbt_clickhouse.clickhouse__insert_into", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2036602, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.create_distributed_table": {"name": "create_distributed_table", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/distributed_table.sql", "original_file_path": "macros/materializations/distributed_table.sql", "unique_id": "macro.dbt_clickhouse.create_distributed_table", "macro_sql": "{% macro create_distributed_table(relation, local_relation) %}\n {%- set cluster = adapter.get_clickhouse_cluster_name() -%}\n {% if cluster is none %}\n {% do exceptions.raise_compiler_error('Cluster name should be defined for using distributed materializations, current is None') %}\n {% endif %}\n\n {%- set cluster = cluster[1:-1] -%}\n {%- set sharding = config.get('sharding_key') -%}\n\n create table {{ relation }} {{ on_cluster_clause(relation) }} as {{ local_relation }}\n ENGINE = Distributed('{{ cluster}}', '{{ relation.schema }}', '{{ local_relation.name }}'\n {%- if sharding is not none and sharding.strip() != '' -%}\n , {{ sharding }}\n {%- else %}\n , rand()\n {% endif -%}\n )\n {% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2052495, "supported_languages": null}, "macro.dbt_clickhouse.create_empty_table_from_relation": {"name": "create_empty_table_from_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/distributed_table.sql", "original_file_path": "macros/materializations/distributed_table.sql", "unique_id": "macro.dbt_clickhouse.create_empty_table_from_relation", "macro_sql": "{% macro create_empty_table_from_relation(relation, source_relation) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n {%- set columns = adapter.get_columns_in_relation(source_relation) | list -%}\n\n {%- set col_list = [] -%}\n {% for col in columns %}\n {{col_list.append(col.name + ' ' + col.data_type) or '' }}\n {% endfor %}\n {{ sql_header if sql_header is not none }}\n\n create table {{ relation.include(database=False) }}\n {{ on_cluster_clause(relation) }} (\n {{col_list | join(', ')}}\n )\n\n {{ engine_clause() }}\n {{ order_cols(label=\"order by\") }}\n {{ primary_key_clause(label=\"primary key\") }}\n {{ partition_cols(label=\"partition by\") }}\n {{ adapter.get_model_settings(model) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt_clickhouse.engine_clause", "macro.dbt_clickhouse.order_cols", "macro.dbt_clickhouse.primary_key_clause", "macro.dbt_clickhouse.partition_cols"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2070408, "supported_languages": null}, "macro.dbt_clickhouse.create_distributed_local_table": {"name": "create_distributed_local_table", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/distributed_table.sql", "original_file_path": "macros/materializations/distributed_table.sql", "unique_id": "macro.dbt_clickhouse.create_distributed_local_table", "macro_sql": "{% macro create_distributed_local_table(distributed_relation, shard_relation, structure_relation, sql_query=none) -%}\n {{ drop_relation_if_exists(shard_relation) }}\n {{ drop_relation_if_exists(distributed_relation) }}\n {% do run_query(create_empty_table_from_relation(shard_relation, structure_relation)) or '' %}\n {% do run_query(create_distributed_table(distributed_relation, shard_relation)) or '' %}\n {% if sql_query is not none %}\n {% do run_query(clickhouse__insert_into(distributed_relation, sql_query)) or '' %}\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt.run_query", "macro.dbt_clickhouse.create_empty_table_from_relation", "macro.dbt_clickhouse.create_distributed_table", "macro.dbt_clickhouse.clickhouse__insert_into"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.208186, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse_s3source": {"name": "clickhouse_s3source", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/s3.sql", "original_file_path": "macros/materializations/s3.sql", "unique_id": "macro.dbt_clickhouse.clickhouse_s3source", "macro_sql": "{% macro clickhouse_s3source(config_name='', bucket='', path='', fmt='', structure='',\n aws_access_key_id='', aws_secret_access_key='', compression='') %}\n {% if config_name and not config_name.lower().endswith('s3') %}\n {{ exceptions.raise_compiler_error(\"S3 configuration should end with 's3'\") }}\n {% endif %}\n {% set s3config = config.get(config_name, {}) %}\n {{ adapter.s3source_clause(\n config_name=config_name,\n s3_model_config=s3config,\n bucket=bucket,\n path=path,\n fmt=fmt,\n structure=structure,\n aws_access_key_id=aws_access_key_id,\n aws_secret_access_key=aws_secret_access_key,\n compression=compression) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.209984, "supported_languages": null}, "macro.dbt_clickhouse.materialization_incremental_clickhouse": {"name": "materialization_incremental_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/incremental.sql", "original_file_path": "macros/materializations/incremental/incremental.sql", "unique_id": "macro.dbt_clickhouse.materialization_incremental_clickhouse", "macro_sql": "{% materialization incremental, adapter='clickhouse' %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n\n {%- set unique_key = config.get('unique_key') -%}\n {% if unique_key is not none and unique_key|length == 0 %}\n {% set unique_key = none %}\n {% endif %}\n {% if unique_key is iterable and (unique_key is not string and unique_key is not mapping) %}\n {% set unique_key = unique_key|join(', ') %}\n {% endif %}\n {%- set inserts_only = config.get('inserts_only') -%}\n {%- set grant_config = config.get('grants') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n -- No existing table, simply create a new one\n {% call statement('main') %}\n {{ get_create_table_as_sql(False, target_relation, sql) }}\n {% endcall %}\n\n {% elif full_refresh_mode %}\n -- Completely replacing the old table, so create a temporary table and then swap it\n {% call statement('main') %}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {% endcall %}\n {% set need_swap = true %}\n\n {% elif inserts_only or unique_key is none -%}\n -- There are no updates/deletes or duplicate keys are allowed. Simply add all of the new rows to the existing\n -- table. It is the user's responsibility to avoid duplicates. Note that \"inserts_only\" is a ClickHouse adapter\n -- specific configurable that is used to avoid creating an expensive intermediate table.\n {% call statement('main') %}\n {{ clickhouse__insert_into(target_relation, sql) }}\n {% endcall %}\n\n {% else %}\n {% set column_changes = none %}\n {% set incremental_strategy = adapter.calculate_incremental_strategy(config.get('incremental_strategy')) %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {%- if on_schema_change != 'ignore' %}\n {%- set column_changes = adapter.check_incremental_schema_changes(on_schema_change, existing_relation, sql) -%}\n {%- if column_changes %}\n {%- if incremental_strategy in ('append', 'delete_insert') %}\n {% set incremental_strategy = 'legacy' %}\n {{ log('Schema changes detected, switching to legacy incremental strategy') }}\n {%- endif %}\n {% endif %}\n {% endif %}\n {% if incremental_strategy != 'delete_insert' and incremental_predicates %}\n {% do exceptions.raise_compiler_error('Cannot apply incremental predicates with ' + incremental_strategy + ' strategy.') %}\n {% endif %}\n {% if incremental_strategy == 'legacy' %}\n {% do clickhouse__incremental_legacy(existing_relation, intermediate_relation, column_changes, unique_key) %}\n {% set need_swap = true %}\n {% elif incremental_strategy == 'delete_insert' %}\n {% do clickhouse__incremental_delete_insert(existing_relation, unique_key, incremental_predicates) %}\n {% elif incremental_strategy == 'append' %}\n {% call statement('main') %}\n {{ clickhouse__insert_into(target_relation, sql) }}\n {% endcall %}\n {% endif %}\n {% endif %}\n\n {% if need_swap %}\n {% if existing_relation.can_exchange %}\n {% do adapter.rename_relation(intermediate_relation, backup_relation) %}\n {% do exchange_tables_atomic(backup_relation, target_relation) %}\n {% else %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% endif %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.clickhouse__insert_into", "macro.dbt_clickhouse.clickhouse__incremental_legacy", "macro.dbt_clickhouse.clickhouse__incremental_delete_insert", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.252866, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.clickhouse__incremental_legacy": {"name": "clickhouse__incremental_legacy", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/incremental.sql", "original_file_path": "macros/materializations/incremental/incremental.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__incremental_legacy", "macro_sql": "{% macro clickhouse__incremental_legacy(existing_relation, intermediate_relation, column_changes, unique_key, is_distributed=False) %}\n {% set new_data_relation = existing_relation.incorporate(path={\"identifier\": existing_relation.identifier + '__dbt_new_data'}) %}\n {{ drop_relation_if_exists(new_data_relation) }}\n\n {%- set inserted_relation = intermediate_relation -%}\n {%- set inserting_relation = new_data_relation -%}\n\n -- First create a temporary table for all of the new data\n {% if is_distributed %}\n {% if column_changes %}\n {% do exceptions.raise_compiler_error('Schema changes not supported with Distributed tables ') %}\n {% endif %}\n -- Need to use distributed table to have data on all shards\n {%- set distributed_new_data_relation = existing_relation.incorporate(path={\"identifier\": existing_relation.identifier + '__dbt_distributed_new_data'}) -%}\n {%- set inserting_relation = distributed_new_data_relation -%}\n {{ create_distributed_local_table(distributed_new_data_relation, new_data_relation, existing_relation, sql) }}\n {% elif column_changes %}\n {% call statement('create_new_data_temp') %}\n {{ get_create_table_as_sql(False, new_data_relation, sql) }}\n {% endcall %}\n {% else %}\n {% call statement('create_new_data_temp') %}\n {{ get_create_table_as_sql(False, new_data_relation, sql) }}\n {% endcall %}\n {% endif %}\n\n -- Next create another temporary table that will eventually be used to replace the existing table. We can't\n -- use the table just created in the previous step because we don't want to override any updated rows with\n -- old rows when we insert the old data\n {% if is_distributed %}\n {%- set distributed_intermediate_relation = make_intermediate_relation(existing_relation) -%}\n {%- set inserted_relation = distributed_intermediate_relation -%}\n {{ create_distributed_local_table(distributed_intermediate_relation, intermediate_relation, existing_relation) }}\n {% else %}\n {% call statement('main') %}\n create table {{ intermediate_relation }} {{ on_cluster_clause(existing_relation) }} as {{ new_data_relation }}\n {% endcall %}\n {% endif %}\n\n -- Insert all the existing rows into the new temporary table, ignoring any rows that have keys in the \"new data\"\n -- table.\n {%- set source_columns = adapter.get_columns_in_relation(existing_relation) -%}\n {%- set source_columns_csv = source_columns | map(attribute='quoted') | join(', ') -%}\n {% call statement('insert_existing_data') %}\n insert into {{ inserted_relation }} ({{ source_columns_csv }})\n select {{ source_columns_csv }}\n from {{ existing_relation }}\n where ({{ unique_key }}) not in (\n select {{ unique_key }}\n from {{ inserting_relation }}\n )\n {{ adapter.get_model_query_settings(model) }}\n {% endcall %}\n\n -- Insert all of the new data into the temporary table\n {% if column_changes %}\n {%- set dest_columns = adapter.get_columns_in_relation(new_data_relation) -%}\n {%- set dest_columns_csv = dest_columns | map(attribute='quoted') | join(', ') -%}\n {% else %}\n {%- set dest_columns_csv = source_columns_csv %}\n {% endif %}\n {% call statement('insert_new_data') %}\n insert into {{ inserted_relation }} ({{ dest_columns_csv }})\n select {{ dest_columns_csv }}\n from {{ inserting_relation }}\n {{ adapter.get_model_query_settings(model) }}\n {% endcall %}\n\n {% do adapter.drop_relation(new_data_relation) %}\n {% if is_distributed %}\n {{ drop_relation_if_exists(distributed_new_data_relation) }}\n {{ drop_relation_if_exists(distributed_intermediate_relation) }}\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt_clickhouse.create_distributed_local_table", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.make_intermediate_relation", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2584133, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__incremental_delete_insert": {"name": "clickhouse__incremental_delete_insert", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/incremental.sql", "original_file_path": "macros/materializations/incremental/incremental.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__incremental_delete_insert", "macro_sql": "{% macro clickhouse__incremental_delete_insert(existing_relation, unique_key, incremental_predicates, is_distributed=False) %}\n {% set new_data_relation = existing_relation.incorporate(path={\"identifier\": existing_relation.identifier\n + '__dbt_new_data_' + invocation_id.replace('-', '_')}) %}\n {{ drop_relation_if_exists(new_data_relation) }}\n {%- set distributed_new_data_relation = existing_relation.incorporate(path={\"identifier\": existing_relation.identifier + '__dbt_distributed_new_data'}) -%}\n\n {%- set inserting_relation = new_data_relation -%}\n\n {% if is_distributed %}\n -- Need to use distributed table to have data on all shards\n {%- set inserting_relation = distributed_new_data_relation -%}\n {{ create_distributed_local_table(distributed_new_data_relation, new_data_relation, existing_relation, sql) }}\n {% else %}\n {% call statement('main') %}\n {{ get_create_table_as_sql(False, new_data_relation, sql) }}\n {% endcall %}\n {% endif %}\n\n {% call statement('delete_existing_data') %}\n {% if is_distributed %}\n {%- set existing_local = existing_relation.derivative(adapter.get_clickhouse_local_suffix()) %}\n delete from {{ existing_local }} {{ on_cluster_clause(existing_relation) }} where ({{ unique_key }}) in (select {{ unique_key }}\n from {{ inserting_relation }})\n {% else %}\n delete from {{ existing_relation }} where ({{ unique_key }}) in (select {{ unique_key }}\n from {{ inserting_relation }})\n {% endif %}\n {%- if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {%- endif -%}\n {{ adapter.get_model_query_settings(model) }}\n {% endcall %}\n\n {%- set dest_columns = adapter.get_columns_in_relation(existing_relation) -%}\n {%- set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') -%}\n {% call statement('insert_new_data') %}\n insert into {{ existing_relation }} {{ adapter.get_model_query_settings(model) }} select {{ dest_cols_csv }} from {{ inserting_relation }}\n {% endcall %}\n {% do adapter.drop_relation(new_data_relation) %}\n {{ drop_relation_if_exists(distributed_new_data_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.drop_relation_if_exists", "macro.dbt_clickhouse.create_distributed_local_table", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.262321, "supported_languages": null}, "macro.dbt_clickhouse.is_incremental": {"name": "is_incremental", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/is_incremental.sql", "original_file_path": "macros/materializations/incremental/is_incremental.sql", "unique_id": "macro.dbt_clickhouse.is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and (model.config.materialized == 'incremental' or model.config.materialized == 'distributed_incremental' )\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2637954, "supported_languages": null}, "macro.dbt_clickhouse.materialization_distributed_incremental_clickhouse": {"name": "materialization_distributed_incremental_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/distributed_incremental.sql", "original_file_path": "macros/materializations/incremental/distributed_incremental.sql", "unique_id": "macro.dbt_clickhouse.materialization_distributed_incremental_clickhouse", "macro_sql": "{% materialization distributed_incremental, adapter='clickhouse' %}\n {% set insert_distributed_sync = run_query(\"SELECT value FROM system.settings WHERE name = 'insert_distributed_sync'\")[0][0] %}\n {% if insert_distributed_sync != '1' %}\n {% do exceptions.raise_compiler_error('To use distributed materialization setting insert_distributed_sync should be set to 1') %}\n {% endif %}\n\n {%- set local_suffix = adapter.get_clickhouse_local_suffix() -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n\n {% set on_cluster = on_cluster_clause(target_relation) %}\n {% if on_cluster.strip() == '' %}\n {% do exceptions.raise_compiler_error('To use distributed materializations cluster setting in dbt profile must be set') %}\n {% endif %}\n\n {% set existing_relation_local = existing_relation.incorporate(path={\"identifier\": this.identifier + local_suffix}) if existing_relation is not none else none %}\n {% set target_relation_local = target_relation.incorporate(path={\"identifier\": this.identifier + local_suffix}) if target_relation is not none else none %}\n\n {%- set unique_key = config.get('unique_key') -%}\n {% if unique_key is not none and unique_key|length == 0 %}\n {% set unique_key = none %}\n {% endif %}\n {% if unique_key is iterable and (unique_key is not string and unique_key is not mapping) %}\n {% set unique_key = unique_key|join(', ') %}\n {% endif %}\n {%- set inserts_only = config.get('inserts_only') -%}\n {%- set grant_config = config.get('grants') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n {%- set intermediate_relation = make_intermediate_relation(target_relation_local)-%}\n {%- set distributed_intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation_local, backup_relation_type) -%}\n {%- set distributed_backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {%- set view_relation = default__make_temp_relation(target_relation, '__dbt_view_tmp') -%}\n\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(view_relation) }}\n {{ drop_relation_if_exists(distributed_intermediate_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n {% set to_drop = [] %}\n {% set schema_changes = none %}\n\n {% call statement('main') %}\n {{ create_view_as(view_relation, sql) }}\n {% endcall %}\n\n {% if existing_relation is none %}\n -- No existing table, simply create a new one\n {{ create_distributed_local_table(target_relation, target_relation_local, view_relation, sql) }}\n\n {% elif full_refresh_mode %}\n -- Completely replacing the old table, so create a temporary table and then swap it\n {{ create_distributed_local_table(distributed_intermediate_relation, intermediate_relation, view_relation, sql) }}\n {% do adapter.drop_relation(distributed_intermediate_relation) or '' %}\n {% set need_swap = true %}\n\n {% elif inserts_only or unique_key is none -%}\n -- There are no updates/deletes or duplicate keys are allowed. Simply add all of the new rows to the existing\n -- table. It is the user's responsibility to avoid duplicates. Note that \"inserts_only\" is a ClickHouse adapter\n -- specific configurable that is used to avoid creating an expensive intermediate table.\n {% call statement('main') %}\n {{ clickhouse__insert_into(target_relation, sql) }}\n {% endcall %}\n\n {% else %}\n {% set incremental_strategy = adapter.calculate_incremental_strategy(config.get('incremental_strategy')) %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% if on_schema_change != 'ignore' %}\n {%- set schema_changes = check_for_schema_changes(existing_relation, target_relation) -%}\n {% if schema_changes['schema_changed'] and incremental_strategy in ('append', 'delete_insert') %}\n {% set incremental_strategy = 'legacy' %}\n {% do log('Schema changes detected, switching to legacy incremental strategy') %}\n {% endif %}\n {% endif %}\n {% if incremental_strategy != 'delete_insert' and incremental_predicates %}\n {% do exceptions.raise_compiler_error('Cannot apply incremental predicates with ' + incremental_strategy + ' strategy.') %}\n {% endif %}\n {% if incremental_strategy == 'legacy' %}\n {% do clickhouse__incremental_legacy(existing_relation, intermediate_relation, schema_changes, unique_key, True) %}\n {% set need_swap = true %}\n {% elif incremental_strategy == 'delete_insert' %}\n {% do clickhouse__incremental_delete_insert(existing_relation, unique_key, incremental_predicates, True) %}\n {% elif incremental_strategy == 'append' %}\n {% call statement('main') %}\n {{ clickhouse__insert_into(target_relation, sql) }}\n {% endcall %}\n {% endif %}\n {% endif %}\n\n {% if need_swap %}\n {% if False %}\n {% do adapter.rename_relation(intermediate_relation, backup_relation) %}\n {% do exchange_tables_atomic(backup_relation, target_relation_local) %}\n {% else %}\n {% do adapter.rename_relation(target_relation_local, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation_local) %}\n {% endif %}\n\n -- Structure could have changed, need to update distributed table from replaced local table\n {% set target_relation_new = target_relation.incorporate(path={\"identifier\": target_relation.identifier + '_temp'}) %}\n {{ drop_relation_if_exists(target_relation_new) }}\n {% do run_query(create_distributed_table(target_relation_new, target_relation_local)) %}\n\n {% if False %}\n {% do adapter.rename_relation(target_relation_new, distributed_backup_relation) %}\n {% do exchange_tables_atomic(distributed_backup_relation, target_relation) %}\n {% else %}\n {% do adapter.rename_relation(target_relation, distributed_backup_relation) %}\n {% do adapter.rename_relation(target_relation_new, target_relation) %}\n {% endif %}\n\n {% do to_drop.append(backup_relation) %}\n {% do to_drop.append(distributed_backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n {% do apply_grants(target_relation_local, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.load_cached_relation", "macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.default__make_temp_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_view_as", "macro.dbt_clickhouse.create_distributed_local_table", "macro.dbt_clickhouse.clickhouse__insert_into", "macro.dbt.check_for_schema_changes", "macro.dbt_clickhouse.clickhouse__incremental_legacy", "macro.dbt_clickhouse.clickhouse__incremental_delete_insert", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt_clickhouse.create_distributed_table", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2894921, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.clickhouse__any_value": {"name": "clickhouse__any_value", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__any_value", "macro_sql": "{% macro clickhouse__any_value(expression) -%}\n any({{ expression }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2911794, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__bool_or": {"name": "clickhouse__bool_or", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__bool_or", "macro_sql": "{% macro clickhouse__bool_or(expression) -%}\n any({{ expression }}) > 0\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.291439, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__cast_bool_to_text": {"name": "clickhouse__cast_bool_to_text", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__cast_bool_to_text", "macro_sql": "{% macro clickhouse__cast_bool_to_text(field) %}\n multiIf({{ field }} > 0, 'true', {{ field }} = 0, 'false', NULL)\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2917166, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__hash": {"name": "clickhouse__hash", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__hash", "macro_sql": "{% macro clickhouse__hash(field) -%}\n lower(hex(MD5(toString({{ field }} ))))\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2919433, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__last_day": {"name": "clickhouse__last_day", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__last_day", "macro_sql": "\n\n\n{%- macro clickhouse__last_day(date, datepart) -%}\n {{ dbt.dateadd('day', '-1', dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date)))}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.292473, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__split_part": {"name": "clickhouse__split_part", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__split_part", "macro_sql": "{% macro clickhouse__split_part(string_text, delimiter_text, part_number) %}\n splitByChar('{{delimiter_text}}', {{ string_text }})[{{ part_number }}]\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.292881, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__replace": {"name": "clickhouse__replace", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__replace", "macro_sql": "{% macro clickhouse__replace(field, old_chars, new_chars) %}\n replaceAll({{ field }},'{{ old_chars }}','{{ new_chars }}')\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2932458, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__listagg": {"name": "clickhouse__listagg", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__listagg", "macro_sql": "{% macro clickhouse__listagg(measure, delimiter_text, order_by_clause, limit_num) %}\n {{ exceptions.raise_compiler_error(\n 'ClickHouse does not support the listagg function. See the groupArray function instead')\n }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.293604, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__array_construct": {"name": "clickhouse__array_construct", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__array_construct", "macro_sql": "{% macro clickhouse__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n [ {{ inputs|join(' , ') }} ]\n {% else %}\n emptyArray{{data_type}}()\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2941315, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__array_append": {"name": "clickhouse__array_append", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__array_append", "macro_sql": "{% macro clickhouse__array_append(array, new_element) -%}\n arrayPushBack({{ array }}, {{ new_element }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.294424, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__array_concat": {"name": "clickhouse__array_concat", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__array_concat", "macro_sql": "{% macro clickhouse__array_concat(array_1, array_2) -%}\n arrayConcat({{ array_1 }}, {{ array_2 }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2948244, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__current_timestamp": {"name": "clickhouse__current_timestamp", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__current_timestamp", "macro_sql": "{% macro clickhouse__current_timestamp() -%}\n now()\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2951648, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__snapshot_string_as_time": {"name": "clickhouse__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__snapshot_string_as_time", "macro_sql": "{% macro clickhouse__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"toDateTime('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2956636, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_show_grant_sql": {"name": "clickhouse__get_show_grant_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_show_grant_sql", "macro_sql": "{% macro clickhouse__get_show_grant_sql(relation) %}\n SELECT access_type as privilege_type, COALESCE(user_name, role_name) as grantee from system.grants where table = '{{ relation.name }}'\n AND database = '{{ relation.schema }}'\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2965455, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__call_dcl_statements": {"name": "clickhouse__call_dcl_statements", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__call_dcl_statements", "macro_sql": "{% macro clickhouse__call_dcl_statements(dcl_statement_list) %}\n {% for dcl_statement in dcl_statement_list %}\n {% call statement('dcl') %}\n {{ dcl_statement }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2971177, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_grant_sql": {"name": "clickhouse__get_grant_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_grant_sql", "macro_sql": "\n\n\n{%- macro clickhouse__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ on_cluster_clause(relation)}} {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2976096, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_revoke_sql": {"name": "clickhouse__get_revoke_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_revoke_sql", "macro_sql": "{%- macro clickhouse__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ on_cluster_clause(relation)}} {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.2981546, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_or_create_relation": {"name": "clickhouse__get_or_create_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_or_create_relation", "macro_sql": "{% macro clickhouse__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set can_exchange = adapter.can_exchange(schema, type) %}\n {%- set should_on_cluster = adapter.should_on_cluster(config.get('materialized'), engine_clause()) %}\n {%- set new_relation = api.Relation.create(\n database=None,\n schema=schema,\n identifier=identifier,\n type=type,\n can_exchange=can_exchange,\n can_on_cluster=should_on_cluster\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.engine_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3004673, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_database": {"name": "clickhouse__get_database", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_database", "macro_sql": "{% macro clickhouse__get_database(database) %}\n {% call statement('get_database', fetch_result=True) %}\n select name, engine, comment\n from system.databases\n where name = '{{ database }}'\n {% endcall %}\n {% do return(load_result('get_database').table) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3011324, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__test_relationships": {"name": "clickhouse__test_relationships", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/schema_tests/relationships.sql", "original_file_path": "macros/schema_tests/relationships.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__test_relationships", "macro_sql": "{% macro clickhouse__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\nsettings join_use_nulls = 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3018286, "supported_languages": null}, "macro.dbt.default__test_accepted_values": {"name": "default__test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/accepted_values.sql", "original_file_path": "macros/generic_test_sql/accepted_values.sql", "unique_id": "macro.dbt.default__test_accepted_values", "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3029783, "supported_languages": null}, "macro.dbt.default__test_not_null": {"name": "default__test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/not_null.sql", "original_file_path": "macros/generic_test_sql/not_null.sql", "unique_id": "macro.dbt.default__test_not_null", "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3036034, "supported_languages": null}, "macro.dbt.default__test_unique": {"name": "default__test_unique", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/unique.sql", "original_file_path": "macros/generic_test_sql/unique.sql", "unique_id": "macro.dbt.default__test_unique", "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.304099, "supported_languages": null}, "macro.dbt.default__test_relationships": {"name": "default__test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/relationships.sql", "original_file_path": "macros/generic_test_sql/relationships.sql", "unique_id": "macro.dbt.default__test_relationships", "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3047862, "supported_languages": null}, "macro.dbt.get_create_intermediate_sql": {"name": "get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_intermediate.sql", "original_file_path": "macros/relations/create_intermediate.sql", "unique_id": "macro.dbt.get_create_intermediate_sql", "macro_sql": "{%- macro get_create_intermediate_sql(relation, sql) -%}\n {{- log('Applying CREATE INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_intermediate_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3055127, "supported_languages": null}, "macro.dbt.default__get_create_intermediate_sql": {"name": "default__get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_intermediate.sql", "original_file_path": "macros/relations/create_intermediate.sql", "unique_id": "macro.dbt.default__get_create_intermediate_sql", "macro_sql": "{%- macro default__get_create_intermediate_sql(relation, sql) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n -- drop any pre-existing intermediate\n {{ get_drop_sql(intermediate_relation) }};\n\n {{ get_create_sql(intermediate_relation, sql) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3060498, "supported_languages": null}, "macro.dbt.get_create_backup_sql": {"name": "get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_backup.sql", "original_file_path": "macros/relations/create_backup.sql", "unique_id": "macro.dbt.get_create_backup_sql", "macro_sql": "{%- macro get_create_backup_sql(relation) -%}\n {{- log('Applying CREATE BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3067179, "supported_languages": null}, "macro.dbt.default__get_create_backup_sql": {"name": "default__get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_backup.sql", "original_file_path": "macros/relations/create_backup.sql", "unique_id": "macro.dbt.default__get_create_backup_sql", "macro_sql": "{%- macro default__get_create_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n -- drop any pre-existing backup\n {{ get_drop_sql(backup_relation) }};\n\n {{ get_rename_sql(relation, backup_relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3072984, "supported_languages": null}, "macro.dbt.get_rename_intermediate_sql": {"name": "get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename_intermediate.sql", "original_file_path": "macros/relations/rename_intermediate.sql", "unique_id": "macro.dbt.get_rename_intermediate_sql", "macro_sql": "{%- macro get_rename_intermediate_sql(relation) -%}\n {{- log('Applying RENAME INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_intermediate_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3079348, "supported_languages": null}, "macro.dbt.default__get_rename_intermediate_sql": {"name": "default__get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename_intermediate.sql", "original_file_path": "macros/relations/rename_intermediate.sql", "unique_id": "macro.dbt.default__get_rename_intermediate_sql", "macro_sql": "{%- macro default__get_rename_intermediate_sql(relation) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n {{ get_rename_sql(intermediate_relation, relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3083804, "supported_languages": null}, "macro.dbt.get_drop_sql": {"name": "get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.get_drop_sql", "macro_sql": "{%- macro get_drop_sql(relation) -%}\n {{- log('Applying DROP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3096786, "supported_languages": null}, "macro.dbt.default__get_drop_sql": {"name": "default__get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.default__get_drop_sql", "macro_sql": "{%- macro default__get_drop_sql(relation) -%}\n\n {%- if relation.is_view -%}\n {{ drop_view(relation) }}\n\n {%- elif relation.is_table -%}\n {{ drop_table(relation) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ drop_materialized_view(relation) }}\n\n {%- else -%}\n drop {{ relation.type }} if exists {{ relation }} cascade\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.drop_view", "macro.dbt.drop_table", "macro.dbt.drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.310493, "supported_languages": null}, "macro.dbt.drop_relation": {"name": "drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3108888, "supported_languages": null}, "macro.dbt.default__drop_relation": {"name": "default__drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.default__drop_relation", "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n {{ get_drop_sql(relation) }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3113215, "supported_languages": null}, "macro.dbt.drop_relation_if_exists": {"name": "drop_relation_if_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.drop_relation_if_exists", "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3117502, "supported_languages": null}, "macro.dbt.get_create_sql": {"name": "get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt.get_create_sql", "macro_sql": "{%- macro get_create_sql(relation, sql) -%}\n {{- log('Applying CREATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.312628, "supported_languages": null}, "macro.dbt.default__get_create_sql": {"name": "default__get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt.default__get_create_sql", "macro_sql": "{%- macro default__get_create_sql(relation, sql) -%}\n\n {%- if relation.is_view -%}\n {{ get_create_view_as_sql(relation, sql) }}\n\n {%- elif relation.is_table -%}\n {{ get_create_table_as_sql(False, relation, sql) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_create_materialized_view_as_sql(relation, sql) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_create_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.get_create_view_as_sql", "macro.dbt.get_create_table_as_sql", "macro.dbt.get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3136106, "supported_languages": null}, "macro.dbt.get_drop_backup_sql": {"name": "get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop_backup.sql", "original_file_path": "macros/relations/drop_backup.sql", "unique_id": "macro.dbt.get_drop_backup_sql", "macro_sql": "{%- macro get_drop_backup_sql(relation) -%}\n {{- log('Applying DROP BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_drop_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.314263, "supported_languages": null}, "macro.dbt.default__get_drop_backup_sql": {"name": "default__get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop_backup.sql", "original_file_path": "macros/relations/drop_backup.sql", "unique_id": "macro.dbt.default__get_drop_backup_sql", "macro_sql": "{%- macro default__get_drop_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n {{ get_drop_sql(backup_relation) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3147104, "supported_languages": null}, "macro.dbt.get_replace_sql": {"name": "get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt.get_replace_sql", "macro_sql": "{% macro get_replace_sql(existing_relation, target_relation, sql) %}\n {{- log('Applying REPLACE to: ' ~ existing_relation) -}}\n {{- adapter.dispatch('get_replace_sql', 'dbt')(existing_relation, target_relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3160484, "supported_languages": null}, "macro.dbt.default__get_replace_sql": {"name": "default__get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt.default__get_replace_sql", "macro_sql": "{% macro default__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {# /* use a create or replace statement if possible */ #}\n\n {% set is_replaceable = existing_relation.type == target_relation_type and existing_relation.can_be_replaced %}\n\n {% if is_replaceable and existing_relation.is_view %}\n {{ get_replace_view_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_table %}\n {{ get_replace_table_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_materialized_view %}\n {{ get_replace_materialized_view_sql(target_relation, sql) }}\n\n {# /* a create or replace statement is not possible, so try to stage and/or backup to be safe */ #}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one using a backup */ #}\n {%- elif target_relation.can_be_renamed and existing_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one without using a backup */ #}\n {%- elif target_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_drop_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }}\n\n {# /* create target_relation in place by first backing up the existing relation */ #}\n {%- elif existing_relation.can_be_renamed -%}\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* no renaming is allowed, so just drop and create */ #}\n {%- else -%}\n {{ get_drop_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }}\n\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_replace_view_sql", "macro.dbt.get_replace_table_sql", "macro.dbt.get_replace_materialized_view_sql", "macro.dbt.get_create_intermediate_sql", "macro.dbt.get_create_backup_sql", "macro.dbt.get_rename_intermediate_sql", "macro.dbt.get_drop_backup_sql", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3191206, "supported_languages": null}, "macro.dbt.get_rename_sql": {"name": "get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.get_rename_sql", "macro_sql": "{%- macro get_rename_sql(relation, new_name) -%}\n {{- log('Applying RENAME to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_sql', 'dbt')(relation, new_name) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3203497, "supported_languages": null}, "macro.dbt.default__get_rename_sql": {"name": "default__get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.default__get_rename_sql", "macro_sql": "{%- macro default__get_rename_sql(relation, new_name) -%}\n\n {%- if relation.is_view -%}\n {{ get_rename_view_sql(relation, new_name) }}\n\n {%- elif relation.is_table -%}\n {{ get_rename_table_sql(relation, new_name) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_rename_materialized_view_sql(relation, new_name) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_rename_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.get_rename_view_sql", "macro.dbt.get_rename_table_sql", "macro.dbt.get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3213758, "supported_languages": null}, "macro.dbt.rename_relation": {"name": "rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.rename_relation", "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__rename_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3218906, "supported_languages": null}, "macro.dbt.default__rename_relation": {"name": "default__rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.default__rename_relation", "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3225882, "supported_languages": null}, "macro.dbt.refresh_materialized_view": {"name": "refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/refresh.sql", "original_file_path": "macros/relations/materialized_view/refresh.sql", "unique_id": "macro.dbt.refresh_materialized_view", "macro_sql": "{% macro refresh_materialized_view(relation) %}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n {{- adapter.dispatch('refresh_materialized_view', 'dbt')(relation) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__refresh_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.323266, "supported_languages": null}, "macro.dbt.default__refresh_materialized_view": {"name": "default__refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/refresh.sql", "original_file_path": "macros/relations/materialized_view/refresh.sql", "unique_id": "macro.dbt.default__refresh_materialized_view", "macro_sql": "{% macro default__refresh_materialized_view(relation) %}\n {{ exceptions.raise_compiler_error(\"`refresh_materialized_view` has not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3236022, "supported_languages": null}, "macro.dbt.drop_materialized_view": {"name": "drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/drop.sql", "original_file_path": "macros/relations/materialized_view/drop.sql", "unique_id": "macro.dbt.drop_materialized_view", "macro_sql": "{% macro drop_materialized_view(relation) -%}\n {{ return(adapter.dispatch('drop_materialized_view', 'dbt')(relation)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3241892, "supported_languages": null}, "macro.dbt.default__drop_materialized_view": {"name": "default__drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/drop.sql", "original_file_path": "macros/relations/materialized_view/drop.sql", "unique_id": "macro.dbt.default__drop_materialized_view", "macro_sql": "{% macro default__drop_materialized_view(relation) -%}\n drop materialized view if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3244295, "supported_languages": null}, "macro.dbt.get_create_materialized_view_as_sql": {"name": "get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/create.sql", "original_file_path": "macros/relations/materialized_view/create.sql", "unique_id": "macro.dbt.get_create_materialized_view_as_sql", "macro_sql": "{% macro get_create_materialized_view_as_sql(relation, sql) -%}\n {{- adapter.dispatch('get_create_materialized_view_as_sql', 'dbt')(relation, sql) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3250413, "supported_languages": null}, "macro.dbt.default__get_create_materialized_view_as_sql": {"name": "default__get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/create.sql", "original_file_path": "macros/relations/materialized_view/create.sql", "unique_id": "macro.dbt.default__get_create_materialized_view_as_sql", "macro_sql": "{% macro default__get_create_materialized_view_as_sql(relation, sql) -%}\n {{ exceptions.raise_compiler_error(\n \"`get_create_materialized_view_as_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3253703, "supported_languages": null}, "macro.dbt.get_alter_materialized_view_as_sql": {"name": "get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.get_alter_materialized_view_as_sql", "macro_sql": "{% macro get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{- log('Applying ALTER to: ' ~ relation) -}}\n {{- adapter.dispatch('get_alter_materialized_view_as_sql', 'dbt')(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n ) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3266082, "supported_languages": null}, "macro.dbt.default__get_alter_materialized_view_as_sql": {"name": "default__get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.default__get_alter_materialized_view_as_sql", "macro_sql": "{% macro default__get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3270187, "supported_languages": null}, "macro.dbt.get_materialized_view_configuration_changes": {"name": "get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.get_materialized_view_configuration_changes", "macro_sql": "{% macro get_materialized_view_configuration_changes(existing_relation, new_config) %}\n /* {#\n It's recommended that configuration changes be formatted as follows:\n {\"\": [{\"action\": \"\", \"context\": ...}]}\n\n For example:\n {\n \"indexes\": [\n {\"action\": \"drop\", \"context\": \"index_abc\"},\n {\"action\": \"create\", \"context\": {\"columns\": [\"column_1\", \"column_2\"], \"type\": \"hash\", \"unique\": True}},\n ],\n }\n\n Either way, `get_materialized_view_configuration_changes` needs to align with `get_alter_materialized_view_as_sql`.\n #} */\n {{- log('Determining configuration changes on: ' ~ existing_relation) -}}\n {%- do return(adapter.dispatch('get_materialized_view_configuration_changes', 'dbt')(existing_relation, new_config)) -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_materialized_view_configuration_changes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3276181, "supported_languages": null}, "macro.dbt.default__get_materialized_view_configuration_changes": {"name": "default__get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.default__get_materialized_view_configuration_changes", "macro_sql": "{% macro default__get_materialized_view_configuration_changes(existing_relation, new_config) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3279335, "supported_languages": null}, "macro.dbt.get_replace_materialized_view_sql": {"name": "get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/replace.sql", "original_file_path": "macros/relations/materialized_view/replace.sql", "unique_id": "macro.dbt.get_replace_materialized_view_sql", "macro_sql": "{% macro get_replace_materialized_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_materialized_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3284802, "supported_languages": null}, "macro.dbt.default__get_replace_materialized_view_sql": {"name": "default__get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/replace.sql", "original_file_path": "macros/relations/materialized_view/replace.sql", "unique_id": "macro.dbt.default__get_replace_materialized_view_sql", "macro_sql": "{% macro default__get_replace_materialized_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.32884, "supported_languages": null}, "macro.dbt.get_rename_materialized_view_sql": {"name": "get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/rename.sql", "original_file_path": "macros/relations/materialized_view/rename.sql", "unique_id": "macro.dbt.get_rename_materialized_view_sql", "macro_sql": "{% macro get_rename_materialized_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_materialized_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3296802, "supported_languages": null}, "macro.dbt.default__get_rename_materialized_view_sql": {"name": "default__get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/rename.sql", "original_file_path": "macros/relations/materialized_view/rename.sql", "unique_id": "macro.dbt.default__get_rename_materialized_view_sql", "macro_sql": "{% macro default__get_rename_materialized_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3301973, "supported_languages": null}, "macro.dbt.get_table_columns_and_constraints": {"name": "get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.get_table_columns_and_constraints", "macro_sql": "{%- macro get_table_columns_and_constraints() -%}\n {{ adapter.dispatch('get_table_columns_and_constraints', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3319643, "supported_languages": null}, "macro.dbt.default__get_table_columns_and_constraints": {"name": "default__get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_table_columns_and_constraints", "macro_sql": "{% macro default__get_table_columns_and_constraints() -%}\n {{ return(table_columns_and_constraints()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3322341, "supported_languages": null}, "macro.dbt.table_columns_and_constraints": {"name": "table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.table_columns_and_constraints", "macro_sql": "{% macro table_columns_and_constraints() %}\n {# loop through user_provided_columns to create DDL with data types and constraints #}\n {%- set raw_column_constraints = adapter.render_raw_columns_constraints(raw_columns=model['columns']) -%}\n {%- set raw_model_constraints = adapter.render_raw_model_constraints(raw_constraints=model['constraints']) -%}\n (\n {% for c in raw_column_constraints -%}\n {{ c }}{{ \",\" if not loop.last or raw_model_constraints }}\n {% endfor %}\n {% for c in raw_model_constraints -%}\n {{ c }}{{ \",\" if not loop.last }}\n {% endfor -%}\n )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3336046, "supported_languages": null}, "macro.dbt.get_assert_columns_equivalent": {"name": "get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.get_assert_columns_equivalent", "macro_sql": "\n\n{%- macro get_assert_columns_equivalent(sql) -%}\n {{ adapter.dispatch('get_assert_columns_equivalent', 'dbt')(sql) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3339689, "supported_languages": null}, "macro.dbt.default__get_assert_columns_equivalent": {"name": "default__get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_assert_columns_equivalent", "macro_sql": "{% macro default__get_assert_columns_equivalent(sql) -%}\n {{ return(assert_columns_equivalent(sql)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.33427, "supported_languages": null}, "macro.dbt.assert_columns_equivalent": {"name": "assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.assert_columns_equivalent", "macro_sql": "{% macro assert_columns_equivalent(sql) %}\n\n {#-- First ensure the user has defined 'columns' in yaml specification --#}\n {%- set user_defined_columns = model['columns'] -%}\n {%- if not user_defined_columns -%}\n {{ exceptions.raise_contract_error([], []) }}\n {%- endif -%}\n\n {#-- Obtain the column schema provided by sql file. #}\n {%- set sql_file_provided_columns = get_column_schema_from_query(sql, config.get('sql_header', none)) -%}\n {#--Obtain the column schema provided by the schema file by generating an 'empty schema' query from the model's columns. #}\n {%- set schema_file_provided_columns = get_column_schema_from_query(get_empty_schema_sql(user_defined_columns)) -%}\n\n {#-- create dictionaries with name and formatted data type and strings for exception #}\n {%- set sql_columns = format_columns(sql_file_provided_columns) -%}\n {%- set yaml_columns = format_columns(schema_file_provided_columns) -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- for sql_col in sql_columns -%}\n {%- set yaml_col = [] -%}\n {%- for this_col in yaml_columns -%}\n {%- if this_col['name'] == sql_col['name'] -%}\n {%- do yaml_col.append(this_col) -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if not yaml_col -%}\n {#-- Column with name not found in yaml #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- if sql_col['formatted'] != yaml_col[0]['formatted'] -%}\n {#-- Column data types don't match #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- endfor -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_column_schema_from_query", "macro.dbt.get_empty_schema_sql", "macro.dbt.format_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3369842, "supported_languages": null}, "macro.dbt.format_columns": {"name": "format_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.format_columns", "macro_sql": "{% macro format_columns(columns) %}\n {% set formatted_columns = [] %}\n {% for column in columns %}\n {%- set formatted_column = adapter.dispatch('format_column', 'dbt')(column) -%}\n {%- do formatted_columns.append(formatted_column) -%}\n {% endfor %}\n {{ return(formatted_columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.format_column", "macro.dbt.default__format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3378038, "supported_languages": null}, "macro.dbt.default__format_column": {"name": "default__format_column", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__format_column", "macro_sql": "{% macro default__format_column(column) -%}\n {% set data_type = column.dtype %}\n {% set formatted = column.column.lower() ~ \" \" ~ data_type %}\n {{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3385222, "supported_languages": null}, "macro.dbt.drop_view": {"name": "drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt.drop_view", "macro_sql": "{% macro drop_view(relation) -%}\n {{ return(adapter.dispatch('drop_view', 'dbt')(relation)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.339056, "supported_languages": null}, "macro.dbt.default__drop_view": {"name": "default__drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt.default__drop_view", "macro_sql": "{% macro default__drop_view(relation) -%}\n drop view if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3392837, "supported_languages": null}, "macro.dbt.get_create_view_as_sql": {"name": "get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.get_create_view_as_sql", "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3400555, "supported_languages": null}, "macro.dbt.default__get_create_view_as_sql": {"name": "default__get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.default__get_create_view_as_sql", "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3403924, "supported_languages": null}, "macro.dbt.create_view_as": {"name": "create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.create_view_as", "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3408103, "supported_languages": null}, "macro.dbt.default__create_view_as": {"name": "default__create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.default__create_view_as", "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced %}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3417222, "supported_languages": null}, "macro.dbt.get_replace_view_sql": {"name": "get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.get_replace_view_sql", "macro_sql": "{% macro get_replace_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3431466, "supported_languages": null}, "macro.dbt.default__get_replace_view_sql": {"name": "default__get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.default__get_replace_view_sql", "macro_sql": "{% macro default__get_replace_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.343467, "supported_languages": null}, "macro.dbt.create_or_replace_view": {"name": "create_or_replace_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.create_or_replace_view", "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3458807, "supported_languages": null}, "macro.dbt.handle_existing_table": {"name": "handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.handle_existing_table", "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__handle_existing_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3463078, "supported_languages": null}, "macro.dbt.default__handle_existing_table": {"name": "default__handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.default__handle_existing_table", "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3467777, "supported_languages": null}, "macro.dbt.get_rename_view_sql": {"name": "get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt.get_rename_view_sql", "macro_sql": "{% macro get_rename_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3473287, "supported_languages": null}, "macro.dbt.default__get_rename_view_sql": {"name": "default__get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt.default__get_rename_view_sql", "macro_sql": "{% macro default__get_rename_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3476443, "supported_languages": null}, "macro.dbt.drop_table": {"name": "drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt.drop_table", "macro_sql": "{% macro drop_table(relation) -%}\n {{ return(adapter.dispatch('drop_table', 'dbt')(relation)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.348162, "supported_languages": null}, "macro.dbt.default__drop_table": {"name": "default__drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt.default__drop_table", "macro_sql": "{% macro default__drop_table(relation) -%}\n drop table if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3483942, "supported_languages": null}, "macro.dbt.get_create_table_as_sql": {"name": "get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.get_create_table_as_sql", "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.349948, "supported_languages": null}, "macro.dbt.default__get_create_table_as_sql": {"name": "default__get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_create_table_as_sql", "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3503497, "supported_languages": null}, "macro.dbt.create_table_as": {"name": "create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.create_table_as", "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3514638, "supported_languages": null}, "macro.dbt.default__create_table_as": {"name": "default__create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__create_table_as", "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced and (not temporary) %}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {%- set sql = get_select_subquery(sql) %}\n {% endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt.get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3529706, "supported_languages": null}, "macro.dbt.default__get_column_names": {"name": "default__get_column_names", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_column_names", "macro_sql": "{% macro default__get_column_names() %}\n {#- loop through user_provided_columns to get column names -#}\n {%- set user_provided_columns = model['columns'] -%}\n {%- for i in user_provided_columns %}\n {%- set col = user_provided_columns[i] -%}\n {%- set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] -%}\n {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3539588, "supported_languages": null}, "macro.dbt.get_select_subquery": {"name": "get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.get_select_subquery", "macro_sql": "{% macro get_select_subquery(sql) %}\n {{ return(adapter.dispatch('get_select_subquery', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.354375, "supported_languages": null}, "macro.dbt.default__get_select_subquery": {"name": "default__get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_select_subquery", "macro_sql": "{% macro default__get_select_subquery(sql) %}\n select {{ adapter.dispatch('get_column_names', 'dbt')() }}\n from (\n {{ sql }}\n ) as model_subq\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_column_names"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3547535, "supported_languages": null}, "macro.dbt.get_replace_table_sql": {"name": "get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt.get_replace_table_sql", "macro_sql": "{% macro get_replace_table_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_table_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3553045, "supported_languages": null}, "macro.dbt.default__get_replace_table_sql": {"name": "default__get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt.default__get_replace_table_sql", "macro_sql": "{% macro default__get_replace_table_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.355618, "supported_languages": null}, "macro.dbt.get_rename_table_sql": {"name": "get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt.get_rename_table_sql", "macro_sql": "{% macro get_rename_table_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_table_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3561683, "supported_languages": null}, "macro.dbt.default__get_rename_table_sql": {"name": "default__get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt.default__get_rename_table_sql", "macro_sql": "{% macro default__get_rename_table_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3564866, "supported_languages": null}, "macro.dbt.set_sql_header": {"name": "set_sql_header", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.set_sql_header", "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3572307, "supported_languages": null}, "macro.dbt.should_full_refresh": {"name": "should_full_refresh", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.should_full_refresh", "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3578997, "supported_languages": null}, "macro.dbt.should_store_failures": {"name": "should_store_failures", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.should_store_failures", "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.358578, "supported_languages": null}, "macro.dbt.run_hooks": {"name": "run_hooks", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.run_hooks", "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.360725, "supported_languages": null}, "macro.dbt.make_hook_config": {"name": "make_hook_config", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.make_hook_config", "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3611586, "supported_languages": null}, "macro.dbt.before_begin": {"name": "before_begin", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.before_begin", "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3614762, "supported_languages": null}, "macro.dbt.in_transaction": {"name": "in_transaction", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.in_transaction", "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.361794, "supported_languages": null}, "macro.dbt.after_commit": {"name": "after_commit", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.after_commit", "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3621087, "supported_languages": null}, "macro.dbt.materialization_seed_default": {"name": "materialization_seed_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/seed.sql", "original_file_path": "macros/materializations/seeds/seed.sql", "unique_id": "macro.dbt.materialization_seed_default", "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparison later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation)) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.run_hooks", "macro.dbt.reset_csv_table", "macro.dbt.create_csv_table", "macro.dbt.load_csv_rows", "macro.dbt.noop_statement", "macro.dbt.get_csv_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3688397, "supported_languages": ["sql"]}, "macro.dbt.create_csv_table": {"name": "create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.create_csv_table", "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3755176, "supported_languages": null}, "macro.dbt.default__create_csv_table": {"name": "default__create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__create_csv_table", "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3774843, "supported_languages": null}, "macro.dbt.reset_csv_table": {"name": "reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.reset_csv_table", "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__reset_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3779843, "supported_languages": null}, "macro.dbt.default__reset_csv_table": {"name": "default__reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__reset_csv_table", "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.378999, "supported_languages": null}, "macro.dbt.get_csv_sql": {"name": "get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_csv_sql", "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_csv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.379403, "supported_languages": null}, "macro.dbt.default__get_csv_sql": {"name": "default__get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_csv_sql", "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3796988, "supported_languages": null}, "macro.dbt.get_binding_char": {"name": "get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_binding_char", "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.380004, "supported_languages": null}, "macro.dbt.default__get_binding_char": {"name": "default__get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_binding_char", "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3802574, "supported_languages": null}, "macro.dbt.get_batch_size": {"name": "get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_batch_size", "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_batch_size"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3805926, "supported_languages": null}, "macro.dbt.default__get_batch_size": {"name": "default__get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_batch_size", "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3808897, "supported_languages": null}, "macro.dbt.get_seed_column_quoted_csv": {"name": "get_seed_column_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_seed_column_quoted_csv", "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3819437, "supported_languages": null}, "macro.dbt.load_csv_rows": {"name": "load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.load_csv_rows", "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__load_csv_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.382339, "supported_languages": null}, "macro.dbt.default__load_csv_rows": {"name": "default__load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__load_csv_rows", "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv", "macro.dbt.get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.38509, "supported_languages": null}, "macro.dbt.materialization_view_default": {"name": "materialization_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/view.sql", "original_file_path": "macros/materializations/models/view.sql", "unique_id": "macro.dbt.materialization_view_default", "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.3903534, "supported_languages": ["sql"]}, "macro.dbt.materialization_table_default": {"name": "materialization_table_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/table.sql", "original_file_path": "macros/materializations/models/table.sql", "unique_id": "macro.dbt.materialization_table_default", "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.create_indexes", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.395651, "supported_languages": ["sql"]}, "macro.dbt.materialization_materialized_view_default": {"name": "materialization_materialized_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialization_materialized_view_default", "macro_sql": "{% materialization materialized_view, default %}\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.MaterializedView) %}\n {% set intermediate_relation = make_intermediate_relation(target_relation) %}\n {% set backup_relation_type = target_relation.MaterializedView if existing_relation is none else existing_relation.type %}\n {% set backup_relation = make_backup_relation(target_relation, backup_relation_type) %}\n\n {{ materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) }}\n\n {% set build_sql = materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% if build_sql == '' %}\n {{ materialized_view_execute_no_op(target_relation) }}\n {% else %}\n {{ materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) }}\n {% endif %}\n\n {{ materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.materialized_view_setup", "macro.dbt.materialized_view_get_build_sql", "macro.dbt.materialized_view_execute_no_op", "macro.dbt.materialized_view_execute_build_sql", "macro.dbt.materialized_view_teardown"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4030128, "supported_languages": ["sql"]}, "macro.dbt.materialized_view_setup": {"name": "materialized_view_setup", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_setup", "macro_sql": "{% macro materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) %}\n\n -- backup_relation and intermediate_relation should not already exist in the database\n -- it's possible these exist because of a previous run that exited unexpectedly\n {% set preexisting_backup_relation = load_cached_relation(backup_relation) %}\n {% set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4038339, "supported_languages": null}, "macro.dbt.materialized_view_teardown": {"name": "materialized_view_teardown", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_teardown", "macro_sql": "{% macro materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) %}\n\n -- drop the temp relations if they exist to leave the database clean for the next run\n {{ drop_relation_if_exists(backup_relation) }}\n {{ drop_relation_if_exists(intermediate_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4043698, "supported_languages": null}, "macro.dbt.materialized_view_get_build_sql": {"name": "materialized_view_get_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_get_build_sql", "macro_sql": "{% macro materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_materialized_view_as_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_materialized_view %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = get_materialized_view_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = refresh_materialized_view(target_relation) %}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = get_alter_materialized_view_as_sql(target_relation, configuration_changes, sql, existing_relation, backup_relation, intermediate_relation) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'skip', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.get_create_materialized_view_as_sql", "macro.dbt.get_replace_sql", "macro.dbt.get_materialized_view_configuration_changes", "macro.dbt.refresh_materialized_view", "macro.dbt.get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4070768, "supported_languages": null}, "macro.dbt.materialized_view_execute_no_op": {"name": "materialized_view_execute_no_op", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_no_op", "macro_sql": "{% macro materialized_view_execute_no_op(target_relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ target_relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4075708, "supported_languages": null}, "macro.dbt.materialized_view_execute_build_sql": {"name": "materialized_view_execute_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_build_sql", "macro_sql": "{% macro materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) %}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4089904, "supported_languages": null}, "macro.dbt.can_clone_table": {"name": "can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/can_clone_table.sql", "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", "unique_id": "macro.dbt.can_clone_table", "macro_sql": "{% macro can_clone_table() %}\n {{ return(adapter.dispatch('can_clone_table', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__can_clone_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4094872, "supported_languages": null}, "macro.dbt.default__can_clone_table": {"name": "default__can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/can_clone_table.sql", "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", "unique_id": "macro.dbt.default__can_clone_table", "macro_sql": "{% macro default__can_clone_table() %}\n {{ return(False) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4097419, "supported_languages": null}, "macro.dbt.materialization_clone_default": {"name": "materialization_clone_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/clone.sql", "original_file_path": "macros/materializations/models/clone/clone.sql", "unique_id": "macro.dbt.materialization_clone_default", "macro_sql": "{%- materialization clone, default -%}\n\n {%- set relations = {'relations': []} -%}\n\n {%- if not defer_relation -%}\n -- nothing to do\n {{ log(\"No relation found in state manifest for \" ~ model.unique_id, info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n\n {%- if existing_relation and not flags.FULL_REFRESH -%}\n -- noop!\n {{ log(\"Relation \" ~ existing_relation ~ \" already exists\", info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set other_existing_relation = load_cached_relation(defer_relation) -%}\n\n -- If this is a database that can do zero-copy cloning of tables, and the other relation is a table, then this will be a table\n -- Otherwise, this will be a view\n\n {% set can_clone_table = can_clone_table() %}\n\n {%- if other_existing_relation and other_existing_relation.type == 'table' and can_clone_table -%}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {% if existing_relation is not none and not existing_relation.is_table %}\n {{ log(\"Dropping relation \" ~ existing_relation ~ \" because it is of type \" ~ existing_relation.type) }}\n {{ drop_relation_if_exists(existing_relation) }}\n {% endif %}\n\n -- as a general rule, data platforms that can clone tables can also do atomic 'create or replace'\n {% call statement('main') %}\n {% if target_relation and defer_relation and target_relation == defer_relation %}\n {{ log(\"Target relation and defer relation are the same, skipping clone for relation: \" ~ target_relation) }}\n {% else %}\n {{ create_or_replace_clone(target_relation, defer_relation) }}\n {% endif %}\n\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n {% do persist_docs(target_relation, model) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n {%- else -%}\n\n {%- set target_relation = this.incorporate(type='view') -%}\n\n -- reuse the view materialization\n -- TODO: support actual dispatch for materialization macros\n -- Tracking ticket: https://github.com/dbt-labs/dbt-core/issues/7799\n {% set search_name = \"materialization_view_\" ~ adapter.type() %}\n {% if not search_name in context %}\n {% set search_name = \"materialization_view_default\" %}\n {% endif %}\n {% set materialization_macro = context[search_name] %}\n {% set relations = materialization_macro() %}\n {{ return(relations) }}\n\n {%- endif -%}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.can_clone_table", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_or_replace_clone", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4163365, "supported_languages": ["sql"]}, "macro.dbt.create_or_replace_clone": {"name": "create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/create_or_replace_clone.sql", "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", "unique_id": "macro.dbt.create_or_replace_clone", "macro_sql": "{% macro create_or_replace_clone(this_relation, defer_relation) %}\n {{ return(adapter.dispatch('create_or_replace_clone', 'dbt')(this_relation, defer_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_or_replace_clone"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4169834, "supported_languages": null}, "macro.dbt.default__create_or_replace_clone": {"name": "default__create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/create_or_replace_clone.sql", "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", "unique_id": "macro.dbt.default__create_or_replace_clone", "macro_sql": "{% macro default__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace table {{ this_relation }} clone {{ defer_relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4172823, "supported_languages": null}, "macro.dbt.materialization_incremental_default": {"name": "materialization_incremental_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/incremental.sql", "original_file_path": "macros/materializations/models/incremental/incremental.sql", "unique_id": "macro.dbt.materialization_incremental_default", "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_temp_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.get_create_table_as_sql", "macro.dbt.run_query", "macro.dbt.process_schema_changes", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.426705, "supported_languages": ["sql"]}, "macro.dbt.get_merge_sql": {"name": "get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_merge_sql", "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n -- back compat for old kwarg name\n {% set incremental_predicates = kwargs.get('predicates', incremental_predicates) %}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4352508, "supported_languages": null}, "macro.dbt.default__get_merge_sql": {"name": "default__get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_merge_sql", "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n {%- set predicates = [] if incremental_predicates is none else [] + incremental_predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{\"(\" ~ predicates | join(\") and (\") ~ \")\"}}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.438639, "supported_languages": null}, "macro.dbt.get_delete_insert_merge_sql": {"name": "get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_delete_insert_merge_sql", "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.439177, "supported_languages": null}, "macro.dbt.default__get_delete_insert_merge_sql": {"name": "default__get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_delete_insert_merge_sql", "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last}}\n {% endfor %}\n {% if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {% endif %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n )\n {%- if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {%- endif -%};\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4413106, "supported_languages": null}, "macro.dbt.get_insert_overwrite_merge_sql": {"name": "get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_insert_overwrite_merge_sql", "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.441862, "supported_languages": null}, "macro.dbt.default__get_insert_overwrite_merge_sql": {"name": "default__get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4431977, "supported_languages": null}, "macro.dbt.get_quoted_csv": {"name": "get_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.get_quoted_csv", "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4457943, "supported_languages": null}, "macro.dbt.diff_columns": {"name": "diff_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.diff_columns", "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4469721, "supported_languages": null}, "macro.dbt.diff_column_data_types": {"name": "diff_column_data_types", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.diff_column_data_types", "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4483914, "supported_languages": null}, "macro.dbt.get_merge_update_columns": {"name": "get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.get_merge_update_columns", "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4489076, "supported_languages": null}, "macro.dbt.default__get_merge_update_columns": {"name": "default__get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.default__get_merge_update_columns", "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4504478, "supported_languages": null}, "macro.dbt.is_incremental": {"name": "is_incremental", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/is_incremental.sql", "original_file_path": "macros/materializations/models/incremental/is_incremental.sql", "unique_id": "macro.dbt.is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4517102, "supported_languages": null}, "macro.dbt.get_incremental_append_sql": {"name": "get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_append_sql", "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4532592, "supported_languages": null}, "macro.dbt.default__get_incremental_append_sql": {"name": "default__get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_append_sql", "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_into_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4537663, "supported_languages": null}, "macro.dbt.get_incremental_delete_insert_sql": {"name": "get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_delete_insert_sql", "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_delete_insert_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4541836, "supported_languages": null}, "macro.dbt.default__get_incremental_delete_insert_sql": {"name": "default__get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4548125, "supported_languages": null}, "macro.dbt.get_incremental_merge_sql": {"name": "get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_merge_sql", "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4552124, "supported_languages": null}, "macro.dbt.default__get_incremental_merge_sql": {"name": "default__get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_merge_sql", "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4558322, "supported_languages": null}, "macro.dbt.get_incremental_insert_overwrite_sql": {"name": "get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_insert_overwrite_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4562228, "supported_languages": null}, "macro.dbt.default__get_incremental_insert_overwrite_sql": {"name": "default__get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4568946, "supported_languages": null}, "macro.dbt.get_incremental_default_sql": {"name": "get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_default_sql", "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_default_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4572976, "supported_languages": null}, "macro.dbt.default__get_incremental_default_sql": {"name": "default__get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_default_sql", "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4576232, "supported_languages": null}, "macro.dbt.get_insert_into_sql": {"name": "get_insert_into_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_insert_into_sql", "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.458294, "supported_languages": null}, "macro.dbt.incremental_validate_on_schema_change": {"name": "incremental_validate_on_schema_change", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.incremental_validate_on_schema_change", "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.465941, "supported_languages": null}, "macro.dbt.check_for_schema_changes": {"name": "check_for_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.check_for_schema_changes", "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.diff_columns", "macro.dbt.diff_column_data_types"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4686704, "supported_languages": null}, "macro.dbt.sync_column_schemas": {"name": "sync_column_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.sync_column_schemas", "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.alter_relation_add_remove_columns", "macro.dbt.alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.471342, "supported_languages": null}, "macro.dbt.process_schema_changes": {"name": "process_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.process_schema_changes", "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.check_for_schema_changes", "macro.dbt.sync_column_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4732609, "supported_languages": null}, "macro.dbt.create_columns": {"name": "create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.create_columns", "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4788017, "supported_languages": null}, "macro.dbt.default__create_columns": {"name": "default__create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__create_columns", "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.479455, "supported_languages": null}, "macro.dbt.post_snapshot": {"name": "post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.post_snapshot", "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4798346, "supported_languages": null}, "macro.dbt.default__post_snapshot": {"name": "default__post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__post_snapshot", "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.480046, "supported_languages": null}, "macro.dbt.get_true_sql": {"name": "get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.get_true_sql", "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_true_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.480368, "supported_languages": null}, "macro.dbt.default__get_true_sql": {"name": "default__get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__get_true_sql", "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4806259, "supported_languages": null}, "macro.dbt.snapshot_staging_table": {"name": "snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.snapshot_staging_table", "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_staging_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4810836, "supported_languages": null}, "macro.dbt.default__snapshot_staging_table": {"name": "default__snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__snapshot_staging_table", "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4829195, "supported_languages": null}, "macro.dbt.build_snapshot_table": {"name": "build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.build_snapshot_table", "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__build_snapshot_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4833212, "supported_languages": null}, "macro.dbt.default__build_snapshot_table": {"name": "default__build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__build_snapshot_table", "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4838629, "supported_languages": null}, "macro.dbt.build_snapshot_staging_table": {"name": "build_snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4847999, "supported_languages": null}, "macro.dbt.materialization_snapshot_default": {"name": "materialization_snapshot_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot.sql", "original_file_path": "macros/materializations/snapshots/snapshot.sql", "unique_id": "macro.dbt.materialization_snapshot_default", "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.get_or_create_relation", "macro.dbt.run_hooks", "macro.dbt.strategy_dispatch", "macro.dbt.build_snapshot_table", "macro.dbt.create_table_as", "macro.dbt.build_snapshot_staging_table", "macro.dbt.create_columns", "macro.dbt.snapshot_merge_sql", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes", "macro.dbt.post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4955666, "supported_languages": ["sql"]}, "macro.dbt.snapshot_merge_sql": {"name": "snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "unique_id": "macro.dbt.snapshot_merge_sql", "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__snapshot_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4964278, "supported_languages": null}, "macro.dbt.default__snapshot_merge_sql": {"name": "default__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "unique_id": "macro.dbt.default__snapshot_merge_sql", "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.4970355, "supported_languages": null}, "macro.dbt.strategy_dispatch": {"name": "strategy_dispatch", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.strategy_dispatch", "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5029442, "supported_languages": null}, "macro.dbt.snapshot_hash_arguments": {"name": "snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_hash_arguments", "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.503319, "supported_languages": null}, "macro.dbt.default__snapshot_hash_arguments": {"name": "default__snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.default__snapshot_hash_arguments", "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5038195, "supported_languages": null}, "macro.dbt.snapshot_timestamp_strategy": {"name": "snapshot_timestamp_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_timestamp_strategy", "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.505372, "supported_languages": null}, "macro.dbt.snapshot_string_as_time": {"name": "snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_string_as_time", "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__snapshot_string_as_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5057275, "supported_languages": null}, "macro.dbt.default__snapshot_string_as_time": {"name": "default__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.default__snapshot_string_as_time", "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5061057, "supported_languages": null}, "macro.dbt.snapshot_check_all_get_existing_columns": {"name": "snapshot_check_all_get_existing_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n {#-- N.B. The whitespace below is necessary to avoid edge case issue with comments --#}\n {#-- See: https://github.com/dbt-labs/dbt-core/issues/6781 --#}\n select {{ check_cols_config | join(', ') }} from (\n {{ node['compiled_code'] }}\n ) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.509079, "supported_languages": null}, "macro.dbt.snapshot_check_strategy": {"name": "snapshot_check_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_check_strategy", "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n {% set updated_at = config.get('updated_at', snapshot_get_time()) %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt.snapshot_check_all_get_existing_columns", "macro.dbt.get_true_sql", "macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.51196, "supported_languages": null}, "macro.dbt.get_test_sql": {"name": "get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.get_test_sql", "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5128467, "supported_languages": null}, "macro.dbt.default__get_test_sql": {"name": "default__get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.default__get_test_sql", "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.513516, "supported_languages": null}, "macro.dbt.get_where_subquery": {"name": "get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "unique_id": "macro.dbt.get_where_subquery", "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_where_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5142486, "supported_languages": null}, "macro.dbt.default__get_where_subquery": {"name": "default__get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "unique_id": "macro.dbt.default__get_where_subquery", "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5150654, "supported_languages": null}, "macro.dbt.materialization_test_default": {"name": "materialization_test_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/test.sql", "original_file_path": "macros/materializations/tests/test.sql", "unique_id": "macro.dbt.materialization_test_default", "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% set store_failures_as = config.get('store_failures_as') %}\n -- if `--store-failures` is invoked via command line and `store_failures_as` is not set,\n -- config.get('store_failures_as', 'table') returns None, not 'table'\n {% if store_failures_as == none %}{% set store_failures_as = 'table' %}{% endif %}\n {% if store_failures_as not in ['table', 'view'] %}\n {{ exceptions.raise_compiler_error(\n \"'\" ~ store_failures_as ~ \"' is not a valid value for `store_failures_as`. \"\n \"Accepted values are: ['ephemeral', 'table', 'view']\"\n ) }}\n {% endif %}\n\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type=store_failures_as) -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ get_create_sql(target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.should_store_failures", "macro.dbt.statement", "macro.dbt.get_create_sql", "macro.dbt.get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5202222, "supported_languages": ["sql"]}, "macro.dbt.datediff": {"name": "datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "unique_id": "macro.dbt.datediff", "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5209477, "supported_languages": null}, "macro.dbt.default__datediff": {"name": "default__datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "unique_id": "macro.dbt.default__datediff", "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.521312, "supported_languages": null}, "macro.dbt.date_trunc": {"name": "date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "unique_id": "macro.dbt.date_trunc", "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.521877, "supported_languages": null}, "macro.dbt.default__date_trunc": {"name": "default__date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "unique_id": "macro.dbt.default__date_trunc", "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5221725, "supported_languages": null}, "macro.dbt.cast_bool_to_text": {"name": "cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "unique_id": "macro.dbt.cast_bool_to_text", "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5229013, "supported_languages": null}, "macro.dbt.default__cast_bool_to_text": {"name": "default__cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "unique_id": "macro.dbt.default__cast_bool_to_text", "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5232866, "supported_languages": null}, "macro.dbt.listagg": {"name": "listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "unique_id": "macro.dbt.listagg", "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__listagg"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5244217, "supported_languages": null}, "macro.dbt.default__listagg": {"name": "default__listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "unique_id": "macro.dbt.default__listagg", "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5253587, "supported_languages": null}, "macro.dbt.length": {"name": "length", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "unique_id": "macro.dbt.length", "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__length"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5259006, "supported_languages": null}, "macro.dbt.default__length": {"name": "default__length", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "unique_id": "macro.dbt.default__length", "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.526133, "supported_languages": null}, "macro.dbt.type_string": {"name": "type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_string", "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.527739, "supported_languages": null}, "macro.dbt.default__type_string": {"name": "default__type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_string", "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5280766, "supported_languages": null}, "macro.dbt.type_timestamp": {"name": "type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_timestamp", "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.528433, "supported_languages": null}, "macro.dbt.default__type_timestamp": {"name": "default__type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.528805, "supported_languages": null}, "macro.dbt.type_float": {"name": "type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_float", "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_float"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.529166, "supported_languages": null}, "macro.dbt.default__type_float": {"name": "default__type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_float", "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5296502, "supported_languages": null}, "macro.dbt.type_numeric": {"name": "type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_numeric", "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5301108, "supported_languages": null}, "macro.dbt.default__type_numeric": {"name": "default__type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_numeric", "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5307481, "supported_languages": null}, "macro.dbt.type_bigint": {"name": "type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_bigint", "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5313308, "supported_languages": null}, "macro.dbt.default__type_bigint": {"name": "default__type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_bigint", "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5319338, "supported_languages": null}, "macro.dbt.type_int": {"name": "type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_int", "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5325465, "supported_languages": null}, "macro.dbt.default__type_int": {"name": "default__type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_int", "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5330243, "supported_languages": null}, "macro.dbt.type_boolean": {"name": "type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_boolean", "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_boolean"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5336323, "supported_languages": null}, "macro.dbt.default__type_boolean": {"name": "default__type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_boolean", "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5341444, "supported_languages": null}, "macro.dbt.concat": {"name": "concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "unique_id": "macro.dbt.concat", "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5349443, "supported_languages": null}, "macro.dbt.default__concat": {"name": "default__concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "unique_id": "macro.dbt.default__concat", "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5353897, "supported_languages": null}, "macro.dbt.position": {"name": "position", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "unique_id": "macro.dbt.position", "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__position"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.536282, "supported_languages": null}, "macro.dbt.default__position": {"name": "default__position", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "unique_id": "macro.dbt.default__position", "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5368245, "supported_languages": null}, "macro.dbt.bool_or": {"name": "bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt.bool_or", "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__bool_or"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5376904, "supported_languages": null}, "macro.dbt.default__bool_or": {"name": "default__bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt.default__bool_or", "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5380304, "supported_languages": null}, "macro.dbt.array_concat": {"name": "array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "unique_id": "macro.dbt.array_concat", "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__array_concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5389857, "supported_languages": null}, "macro.dbt.default__array_concat": {"name": "default__array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "unique_id": "macro.dbt.default__array_concat", "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5395234, "supported_languages": null}, "macro.dbt.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.541102, "supported_languages": null}, "macro.dbt.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5420587, "supported_languages": null}, "macro.dbt.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5424829, "supported_languages": null}, "macro.dbt.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5437477, "supported_languages": null}, "macro.dbt.any_value": {"name": "any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "unique_id": "macro.dbt.any_value", "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__any_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5442863, "supported_languages": null}, "macro.dbt.default__any_value": {"name": "default__any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "unique_id": "macro.dbt.default__any_value", "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5445228, "supported_languages": null}, "macro.dbt.intersect": {"name": "intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "unique_id": "macro.dbt.intersect", "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__intersect"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5450284, "supported_languages": null}, "macro.dbt.default__intersect": {"name": "default__intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "unique_id": "macro.dbt.default__intersect", "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5452075, "supported_languages": null}, "macro.dbt.split_part": {"name": "split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt.split_part", "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5461283, "supported_languages": null}, "macro.dbt.default__split_part": {"name": "default__split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt.default__split_part", "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5464919, "supported_languages": null}, "macro.dbt._split_part_negative": {"name": "_split_part_negative", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt._split_part_negative", "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 + {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5469797, "supported_languages": null}, "macro.dbt.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5482075, "supported_languages": null}, "macro.dbt.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.549546, "supported_languages": null}, "macro.dbt.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5500424, "supported_languages": null}, "macro.dbt.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n {# call as follows:\n\n date_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n ) #}\n\n\n with rawdata as (\n\n {{dbt.generate_series(\n dbt.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n ),\n\n all_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n ),\n\n filtered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n )\n\n select * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.generate_series", "macro.dbt.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5508041, "supported_languages": null}, "macro.dbt.right": {"name": "right", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt.right", "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__right"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.55139, "supported_languages": null}, "macro.dbt.default__right": {"name": "default__right", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt.default__right", "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5516875, "supported_languages": null}, "macro.dbt.array_construct": {"name": "array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt.array_construct", "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__array_construct"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.552441, "supported_languages": null}, "macro.dbt.default__array_construct": {"name": "default__array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt.default__array_construct", "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5530233, "supported_languages": null}, "macro.dbt.escape_single_quotes": {"name": "escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt.escape_single_quotes", "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__escape_single_quotes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.553569, "supported_languages": null}, "macro.dbt.default__escape_single_quotes": {"name": "default__escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt.default__escape_single_quotes", "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.553872, "supported_languages": null}, "macro.dbt.dateadd": {"name": "dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "unique_id": "macro.dbt.dateadd", "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5545425, "supported_languages": null}, "macro.dbt.default__dateadd": {"name": "default__dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "unique_id": "macro.dbt.default__dateadd", "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.554911, "supported_languages": null}, "macro.dbt.string_literal": {"name": "string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "unique_id": "macro.dbt.string_literal", "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5554159, "supported_languages": null}, "macro.dbt.default__string_literal": {"name": "default__string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "unique_id": "macro.dbt.default__string_literal", "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5556538, "supported_languages": null}, "macro.dbt.last_day": {"name": "last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.last_day", "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5568156, "supported_languages": null}, "macro.dbt.default_last_day": {"name": "default_last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.default_last_day", "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5574787, "supported_languages": null}, "macro.dbt.default__last_day": {"name": "default__last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.default__last_day", "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default_last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5577962, "supported_languages": null}, "macro.dbt.safe_cast": {"name": "safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt.safe_cast", "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5583785, "supported_languages": null}, "macro.dbt.default__safe_cast": {"name": "default__safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt.default__safe_cast", "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5586843, "supported_languages": null}, "macro.dbt.array_append": {"name": "array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "unique_id": "macro.dbt.array_append", "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__array_append"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5592425, "supported_languages": null}, "macro.dbt.default__array_append": {"name": "default__array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "unique_id": "macro.dbt.default__array_append", "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.559529, "supported_languages": null}, "macro.dbt.except": {"name": "except", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "unique_id": "macro.dbt.except", "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5599818, "supported_languages": null}, "macro.dbt.default__except": {"name": "default__except", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "unique_id": "macro.dbt.default__except", "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5601497, "supported_languages": null}, "macro.dbt.replace": {"name": "replace", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "unique_id": "macro.dbt.replace", "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__replace"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5608206, "supported_languages": null}, "macro.dbt.default__replace": {"name": "default__replace", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "unique_id": "macro.dbt.default__replace", "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.56119, "supported_languages": null}, "macro.dbt.hash": {"name": "hash", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "unique_id": "macro.dbt.hash", "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__hash"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5617056, "supported_languages": null}, "macro.dbt.default__hash": {"name": "default__hash", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "unique_id": "macro.dbt.default__hash", "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.562094, "supported_languages": null}, "macro.dbt.alter_column_comment": {"name": "alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.alter_column_comment", "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5633638, "supported_languages": null}, "macro.dbt.default__alter_column_comment": {"name": "default__alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__alter_column_comment", "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5637414, "supported_languages": null}, "macro.dbt.alter_relation_comment": {"name": "alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.alter_relation_comment", "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__alter_relation_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5641835, "supported_languages": null}, "macro.dbt.default__alter_relation_comment": {"name": "default__alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__alter_relation_comment", "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5645783, "supported_languages": null}, "macro.dbt.persist_docs": {"name": "persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.persist_docs", "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5652022, "supported_languages": null}, "macro.dbt.default__persist_docs": {"name": "default__persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__persist_docs", "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.alter_relation_comment", "macro.dbt.alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5662591, "supported_languages": null}, "macro.dbt.get_create_index_sql": {"name": "get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_create_index_sql", "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5676792, "supported_languages": null}, "macro.dbt.default__get_create_index_sql": {"name": "default__get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_create_index_sql", "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5679824, "supported_languages": null}, "macro.dbt.create_indexes": {"name": "create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.create_indexes", "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5683262, "supported_languages": null}, "macro.dbt.default__create_indexes": {"name": "default__create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__create_indexes", "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_create_index_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.569422, "supported_languages": null}, "macro.dbt.get_drop_index_sql": {"name": "get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_drop_index_sql", "macro_sql": "{% macro get_drop_index_sql(relation, index_name) -%}\n {{ adapter.dispatch('get_drop_index_sql', 'dbt')(relation, index_name) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_drop_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.569825, "supported_languages": null}, "macro.dbt.default__get_drop_index_sql": {"name": "default__get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_drop_index_sql", "macro_sql": "{% macro default__get_drop_index_sql(relation, index_name) -%}\n {{ exceptions.raise_compiler_error(\"`get_drop_index_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5701256, "supported_languages": null}, "macro.dbt.get_show_indexes_sql": {"name": "get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_show_indexes_sql", "macro_sql": "{% macro get_show_indexes_sql(relation) -%}\n {{ adapter.dispatch('get_show_indexes_sql', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_show_indexes_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.570463, "supported_languages": null}, "macro.dbt.default__get_show_indexes_sql": {"name": "default__get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_show_indexes_sql", "macro_sql": "{% macro default__get_show_indexes_sql(relation) -%}\n {{ exceptions.raise_compiler_error(\"`get_show_indexes_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5707374, "supported_languages": null}, "macro.dbt.get_columns_in_relation": {"name": "get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_columns_in_relation", "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.574223, "supported_languages": null}, "macro.dbt.default__get_columns_in_relation": {"name": "default__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_columns_in_relation", "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5745783, "supported_languages": null}, "macro.dbt.sql_convert_columns_in_relation": {"name": "sql_convert_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.sql_convert_columns_in_relation", "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5752368, "supported_languages": null}, "macro.dbt.get_empty_subquery_sql": {"name": "get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_empty_subquery_sql", "macro_sql": "{% macro get_empty_subquery_sql(select_sql, select_sql_header=none) -%}\n {{ return(adapter.dispatch('get_empty_subquery_sql', 'dbt')(select_sql, select_sql_header)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5756922, "supported_languages": null}, "macro.dbt.default__get_empty_subquery_sql": {"name": "default__get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_empty_subquery_sql", "macro_sql": "{% macro default__get_empty_subquery_sql(select_sql, select_sql_header=none) %}\n {%- if select_sql_header is not none -%}\n {{ select_sql_header }}\n {%- endif -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.576142, "supported_languages": null}, "macro.dbt.get_empty_schema_sql": {"name": "get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_empty_schema_sql", "macro_sql": "{% macro get_empty_schema_sql(columns) -%}\n {{ return(adapter.dispatch('get_empty_schema_sql', 'dbt')(columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_schema_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5765321, "supported_languages": null}, "macro.dbt.default__get_empty_schema_sql": {"name": "default__get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_empty_schema_sql", "macro_sql": "{% macro default__get_empty_schema_sql(columns) %}\n {%- set col_err = [] -%}\n {%- set col_naked_numeric = [] -%}\n select\n {% for i in columns %}\n {%- set col = columns[i] -%}\n {%- if col['data_type'] is not defined -%}\n {%- do col_err.append(col['name']) -%}\n {#-- If this column's type is just 'numeric' then it is missing precision/scale, raise a warning --#}\n {%- elif col['data_type'].strip().lower() in ('numeric', 'decimal', 'number') -%}\n {%- do col_naked_numeric.append(col['name']) -%}\n {%- endif -%}\n {% set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] %}\n cast(null as {{ col['data_type'] }}) as {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n {%- if (col_err | length) > 0 -%}\n {{ exceptions.column_type_missing(column_names=col_err) }}\n {%- elif (col_naked_numeric | length) > 0 -%}\n {{ exceptions.warn(\"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: \" ~ col_naked_numeric ~ \"`\") }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5790176, "supported_languages": null}, "macro.dbt.get_column_schema_from_query": {"name": "get_column_schema_from_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_column_schema_from_query", "macro_sql": "{% macro get_column_schema_from_query(select_sql, select_sql_header=none) -%}\n {% set columns = [] %}\n {# -- Using an 'empty subquery' here to get the same schema as the given select_sql statement, without necessitating a data scan.#}\n {% set sql = get_empty_subquery_sql(select_sql, select_sql_header) %}\n {% set column_schema = adapter.get_column_schema_from_query(sql) %}\n {{ return(column_schema) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5797563, "supported_languages": null}, "macro.dbt.get_columns_in_query": {"name": "get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_columns_in_query", "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.580142, "supported_languages": null}, "macro.dbt.default__get_columns_in_query": {"name": "default__get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_columns_in_query", "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n {{ get_empty_subquery_sql(select_sql) }}\n {% endcall %}\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.580922, "supported_languages": null}, "macro.dbt.alter_column_type": {"name": "alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.alter_column_type", "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.58141, "supported_languages": null}, "macro.dbt.default__alter_column_type": {"name": "default__alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__alter_column_type", "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5826838, "supported_languages": null}, "macro.dbt.alter_relation_add_remove_columns": {"name": "alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.alter_relation_add_remove_columns", "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__alter_relation_add_remove_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5832155, "supported_languages": null}, "macro.dbt.default__alter_relation_add_remove_columns": {"name": "default__alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__alter_relation_add_remove_columns", "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5853553, "supported_languages": null}, "macro.dbt.validate_sql": {"name": "validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/validate_sql.sql", "original_file_path": "macros/adapters/validate_sql.sql", "unique_id": "macro.dbt.validate_sql", "macro_sql": "{% macro validate_sql(sql) -%}\n {{ return(adapter.dispatch('validate_sql', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__validate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5859978, "supported_languages": null}, "macro.dbt.default__validate_sql": {"name": "default__validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/validate_sql.sql", "original_file_path": "macros/adapters/validate_sql.sql", "unique_id": "macro.dbt.default__validate_sql", "macro_sql": "{% macro default__validate_sql(sql) -%}\n {% call statement('validate_sql') -%}\n explain {{ sql }}\n {% endcall %}\n {{ return(load_result('validate_sql')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5865204, "supported_languages": null}, "macro.dbt.copy_grants": {"name": "copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.copy_grants", "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5893853, "supported_languages": null}, "macro.dbt.default__copy_grants": {"name": "default__copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__copy_grants", "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5896623, "supported_languages": null}, "macro.dbt.support_multiple_grantees_per_dcl_statement": {"name": "support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5900345, "supported_languages": null}, "macro.dbt.default__support_multiple_grantees_per_dcl_statement": {"name": "default__support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5902827, "supported_languages": null}, "macro.dbt.should_revoke": {"name": "should_revoke", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.should_revoke", "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5910304, "supported_languages": null}, "macro.dbt.get_show_grant_sql": {"name": "get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_show_grant_sql", "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_show_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5914385, "supported_languages": null}, "macro.dbt.default__get_show_grant_sql": {"name": "default__get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_show_grant_sql", "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5916693, "supported_languages": null}, "macro.dbt.get_grant_sql": {"name": "get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_grant_sql", "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5921526, "supported_languages": null}, "macro.dbt.default__get_grant_sql": {"name": "default__get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_grant_sql", "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5925586, "supported_languages": null}, "macro.dbt.get_revoke_sql": {"name": "get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_revoke_sql", "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_revoke_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.593107, "supported_languages": null}, "macro.dbt.default__get_revoke_sql": {"name": "default__get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_revoke_sql", "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5935245, "supported_languages": null}, "macro.dbt.get_dcl_statement_list": {"name": "get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_dcl_statement_list", "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_dcl_statement_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.594009, "supported_languages": null}, "macro.dbt.default__get_dcl_statement_list": {"name": "default__get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_dcl_statement_list", "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5954413, "supported_languages": null}, "macro.dbt.call_dcl_statements": {"name": "call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.call_dcl_statements", "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5959141, "supported_languages": null}, "macro.dbt.default__call_dcl_statements": {"name": "default__call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__call_dcl_statements", "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.596457, "supported_languages": null}, "macro.dbt.apply_grants": {"name": "apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.apply_grants", "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.596986, "supported_languages": null}, "macro.dbt.default__apply_grants": {"name": "default__apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__apply_grants", "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.get_show_grant_sql", "macro.dbt.get_dcl_statement_list", "macro.dbt.call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.5996163, "supported_languages": null}, "macro.dbt.collect_freshness": {"name": "collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "unique_id": "macro.dbt.collect_freshness", "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__collect_freshness"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.600555, "supported_languages": null}, "macro.dbt.default__collect_freshness": {"name": "default__collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "unique_id": "macro.dbt.default__collect_freshness", "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6015685, "supported_languages": null}, "macro.dbt.make_intermediate_relation": {"name": "make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_intermediate_relation", "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_intermediate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6046822, "supported_languages": null}, "macro.dbt.default__make_intermediate_relation": {"name": "default__make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_intermediate_relation", "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.60513, "supported_languages": null}, "macro.dbt.make_temp_relation": {"name": "make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_temp_relation", "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.605625, "supported_languages": null}, "macro.dbt.default__make_temp_relation": {"name": "default__make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_temp_relation", "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.606273, "supported_languages": null}, "macro.dbt.make_backup_relation": {"name": "make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_backup_relation", "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_backup_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6068044, "supported_languages": null}, "macro.dbt.default__make_backup_relation": {"name": "default__make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_backup_relation", "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.607488, "supported_languages": null}, "macro.dbt.truncate_relation": {"name": "truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6078796, "supported_languages": null}, "macro.dbt.default__truncate_relation": {"name": "default__truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__truncate_relation", "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6082358, "supported_languages": null}, "macro.dbt.get_or_create_relation": {"name": "get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.get_or_create_relation", "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_or_create_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6088119, "supported_languages": null}, "macro.dbt.default__get_or_create_relation": {"name": "default__get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__get_or_create_relation", "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.610021, "supported_languages": null}, "macro.dbt.load_cached_relation": {"name": "load_cached_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.load_cached_relation", "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6105118, "supported_languages": null}, "macro.dbt.load_relation": {"name": "load_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.load_relation", "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.610821, "supported_languages": null}, "macro.dbt.current_timestamp": {"name": "current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp", "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6117337, "supported_languages": null}, "macro.dbt.default__current_timestamp": {"name": "default__current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6120682, "supported_languages": null}, "macro.dbt.snapshot_get_time": {"name": "snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.snapshot_get_time", "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6123762, "supported_languages": null}, "macro.dbt.default__snapshot_get_time": {"name": "default__snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__snapshot_get_time", "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6126118, "supported_languages": null}, "macro.dbt.current_timestamp_backcompat": {"name": "current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp_backcompat", "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6130376, "supported_languages": null}, "macro.dbt.default__current_timestamp_backcompat": {"name": "default__current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_backcompat", "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6132243, "supported_languages": null}, "macro.dbt.current_timestamp_in_utc_backcompat": {"name": "current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__current_timestamp_in_utc_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6135805, "supported_languages": null}, "macro.dbt.default__current_timestamp_in_utc_backcompat": {"name": "default__current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp_backcompat", "macro.dbt.default__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6141, "supported_languages": null}, "macro.dbt.create_schema": {"name": "create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.create_schema", "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__create_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6148415, "supported_languages": null}, "macro.dbt.default__create_schema": {"name": "default__create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.default__create_schema", "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6152434, "supported_languages": null}, "macro.dbt.drop_schema": {"name": "drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.drop_schema", "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__drop_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6155899, "supported_languages": null}, "macro.dbt.default__drop_schema": {"name": "default__drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.default__drop_schema", "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6159894, "supported_languages": null}, "macro.dbt.get_catalog_relations": {"name": "get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog_relations", "macro_sql": "{% macro get_catalog_relations(information_schema, relations) -%}\n {{ return(adapter.dispatch('get_catalog_relations', 'dbt')(information_schema, relations)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_catalog_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6200604, "supported_languages": null}, "macro.dbt.default__get_catalog_relations": {"name": "default__get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog_relations", "macro_sql": "{% macro default__get_catalog_relations(information_schema, relations) -%}\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog_relations not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6206305, "supported_languages": null}, "macro.dbt.get_catalog": {"name": "get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog", "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_catalog"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6211329, "supported_languages": null}, "macro.dbt.default__get_catalog": {"name": "default__get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog", "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6217086, "supported_languages": null}, "macro.dbt.information_schema_name": {"name": "information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.information_schema_name", "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__information_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6221058, "supported_languages": null}, "macro.dbt.default__information_schema_name": {"name": "default__information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__information_schema_name", "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6224494, "supported_languages": null}, "macro.dbt.list_schemas": {"name": "list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.list_schemas", "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__list_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6228337, "supported_languages": null}, "macro.dbt.default__list_schemas": {"name": "default__list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__list_schemas", "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.information_schema_name", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6233673, "supported_languages": null}, "macro.dbt.check_schema_exists": {"name": "check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.check_schema_exists", "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__check_schema_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6238027, "supported_languages": null}, "macro.dbt.default__check_schema_exists": {"name": "default__check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__check_schema_exists", "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6244774, "supported_languages": null}, "macro.dbt.list_relations_without_caching": {"name": "list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.list_relations_without_caching", "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__list_relations_without_caching"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6249464, "supported_languages": null}, "macro.dbt.default__list_relations_without_caching": {"name": "default__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__list_relations_without_caching", "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.625312, "supported_languages": null}, "macro.dbt.get_relations": {"name": "get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_relations", "macro_sql": "{% macro get_relations() %}\n {{ return(adapter.dispatch('get_relations', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6256654, "supported_languages": null}, "macro.dbt.default__get_relations": {"name": "default__get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_relations", "macro_sql": "{% macro default__get_relations() %}\n {{ exceptions.raise_not_implemented(\n 'get_relations macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6260083, "supported_languages": null}, "macro.dbt.get_relation_last_modified": {"name": "get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_relation_last_modified", "macro_sql": "{% macro get_relation_last_modified(information_schema, relations) %}\n {{ return(adapter.dispatch('get_relation_last_modified', 'dbt')(information_schema, relations)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_relation_last_modified"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.626553, "supported_languages": null}, "macro.dbt.default__get_relation_last_modified": {"name": "default__get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_relation_last_modified", "macro_sql": "{% macro default__get_relation_last_modified(information_schema, relations) %}\n {{ exceptions.raise_not_implemented(\n 'get_relation_last_modified macro not implemented for adapter ' + adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6270638, "supported_languages": null}, "macro.dbt.get_show_sql": {"name": "get_show_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.get_show_sql", "macro_sql": "{% macro get_show_sql(compiled_code, sql_header, limit) -%}\n {%- if sql_header -%}\n {{ sql_header }}\n {%- endif -%}\n {%- if limit is not none -%}\n {{ get_limit_subquery_sql(compiled_code, limit) }}\n {%- else -%}\n {{ compiled_code }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_limit_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6280875, "supported_languages": null}, "macro.dbt.get_limit_subquery_sql": {"name": "get_limit_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.get_limit_subquery_sql", "macro_sql": "{% macro get_limit_subquery_sql(sql, limit) %}\n {{ adapter.dispatch('get_limit_subquery_sql', 'dbt')(sql, limit) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_limit_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6285005, "supported_languages": null}, "macro.dbt.default__get_limit_subquery_sql": {"name": "default__get_limit_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.default__get_limit_subquery_sql", "macro_sql": "{% macro default__get_limit_subquery_sql(sql, limit) %}\n select *\n from (\n {{ sql }}\n ) as model_limit_subq\n limit {{ limit }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.628845, "supported_languages": null}, "macro.dbt.resolve_model_name": {"name": "resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.resolve_model_name", "macro_sql": "{% macro resolve_model_name(input_model_name) %}\n {{ return(adapter.dispatch('resolve_model_name', 'dbt')(input_model_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6313503, "supported_languages": null}, "macro.dbt.default__resolve_model_name": {"name": "default__resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.default__resolve_model_name", "macro_sql": "\n\n{%- macro default__resolve_model_name(input_model_name) -%}\n {{ input_model_name | string | replace('\"', '\\\"') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.631692, "supported_languages": null}, "macro.dbt.build_ref_function": {"name": "build_ref_function", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_ref_function", "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {% set _ref_args = [_ref.get('package'), _ref['name']] if _ref.get('package') else [_ref['name'],] %}\n {%- set resolved = ref(*_ref_args, v=_ref.get('version')) -%}\n {%- if _ref.get('version') -%}\n {% do _ref_args.extend([\"v\" ~ _ref['version']]) %}\n {%- endif -%}\n {%- do ref_dict.update({_ref_args | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef ref(*args, **kwargs):\n refs = {{ ref_dict | tojson }}\n key = '.'.join(args)\n version = kwargs.get(\"v\") or kwargs.get(\"version\")\n if version:\n key += f\".v{version}\"\n dbt_load_df_function = kwargs.get(\"dbt_load_df_function\")\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.633538, "supported_languages": null}, "macro.dbt.build_source_function": {"name": "build_source_function", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_source_function", "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = '.'.join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6344447, "supported_languages": null}, "macro.dbt.build_config_dict": {"name": "build_config_dict", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_config_dict", "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {% set config_dbt_used = zip(model.config.config_keys_used, model.config.config_keys_defaults) | list %}\n {%- for key, default in config_dbt_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == \"language\" -%}\n {%- set value = \"python\" -%}\n {%- endif -%}\n {%- set value = model.config.get(key, default) -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6357079, "supported_languages": null}, "macro.dbt.py_script_postfix": {"name": "py_script_postfix", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.py_script_postfix", "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = \"{{ this.database }}\"\n schema = \"{{ this.schema }}\"\n identifier = \"{{ this.identifier }}\"\n {% set this_relation_name = resolve_model_name(this) %}\n def __repr__(self):\n return '{{ this_relation_name }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args, **kwargs: ref(*args, **kwargs, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.build_ref_function", "macro.dbt.build_source_function", "macro.dbt.build_config_dict", "macro.dbt.resolve_model_name", "macro.dbt.is_incremental", "macro.dbt.py_script_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.636739, "supported_languages": null}, "macro.dbt.py_script_comment": {"name": "py_script_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6369352, "supported_languages": null}, "macro.dbt.convert_datetime": {"name": "convert_datetime", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.convert_datetime", "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6398156, "supported_languages": null}, "macro.dbt.dates_in_range": {"name": "dates_in_range", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.dates_in_range", "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partition start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.convert_datetime"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6423898, "supported_languages": null}, "macro.dbt.partition_range": {"name": "partition_range", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.partition_range", "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dates_in_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6441243, "supported_languages": null}, "macro.dbt.py_current_timestring": {"name": "py_current_timestring", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.py_current_timestring", "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6446345, "supported_languages": null}, "macro.dbt.statement": {"name": "statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.statement", "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6475687, "supported_languages": null}, "macro.dbt.noop_statement": {"name": "noop_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.noop_statement", "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6488123, "supported_languages": null}, "macro.dbt.run_query": {"name": "run_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.run_query", "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6494582, "supported_languages": null}, "macro.dbt.generate_database_name": {"name": "generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "unique_id": "macro.dbt.generate_database_name", "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__generate_database_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6502366, "supported_languages": null}, "macro.dbt.default__generate_database_name": {"name": "default__generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "unique_id": "macro.dbt.default__generate_database_name", "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.650791, "supported_languages": null}, "macro.dbt.generate_schema_name": {"name": "generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6517572, "supported_languages": null}, "macro.dbt.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.652323, "supported_languages": null}, "macro.dbt.generate_schema_name_for_env": {"name": "generate_schema_name_for_env", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name_for_env", "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6529872, "supported_languages": null}, "macro.dbt.generate_alias_name": {"name": "generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "unique_id": "macro.dbt.generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_alias_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6537995, "supported_languages": null}, "macro.dbt.default__generate_alias_name": {"name": "default__generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "unique_id": "macro.dbt.default__generate_alias_name", "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name -%}\n\n {{ custom_alias_name | trim }}\n\n {%- elif node.version -%}\n\n {{ return(node.name ~ \"_v\" ~ (node.version | replace(\".\", \"_\"))) }}\n\n {%- else -%}\n\n {{ node.name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6546059, "supported_languages": null}, "macro.dbt.test_unique": {"name": "test_unique", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_unique", "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_unique"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.655553, "supported_languages": null}, "macro.dbt.test_not_null": {"name": "test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_not_null", "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.656047, "supported_languages": null}, "macro.dbt.test_accepted_values": {"name": "test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_accepted_values", "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.656647, "supported_languages": null}, "macro.dbt.test_relationships": {"name": "test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_relationships", "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__test_relationships"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6572714, "supported_languages": null}, "macro.codegen.generate_base_model": {"name": "generate_base_model", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_base_model.sql", "original_file_path": "macros/generate_base_model.sql", "unique_id": "macro.codegen.generate_base_model", "macro_sql": "{% macro generate_base_model(source_name, table_name, leading_commas=False, case_sensitive_cols=False, materialized=None) %}\n\n{%- set source_relation = source(source_name, table_name) -%}\n\n{%- set columns = adapter.get_columns_in_relation(source_relation) -%}\n{% set column_names=columns | map(attribute='name') %}\n{% set base_model_sql %}\n\n{%- if materialized is not none -%}\n {{ \"{{ config(materialized='\" ~ materialized ~ \"') }}\" }}\n{%- endif %}\n\nwith source as (\n\n select * from {% raw %}{{ source({% endraw %}'{{ source_name }}', '{{ table_name }}'{% raw %}) }}{% endraw %}\n\n),\n\nrenamed as (\n\n select\n {%- if leading_commas -%}\n {%- for column in column_names %}\n {{\", \" if not loop.first}}{% if not case_sensitive_cols %}{{ column | lower }}{% elif target.type == \"bigquery\" %}{{ column }}{% else %}{{ \"\\\"\" ~ column ~ \"\\\"\" }}{% endif %}\n {%- endfor %}\n {%- else -%}\n {%- for column in column_names %}\n {% if not case_sensitive_cols %}{{ column | lower }}{% elif target.type == \"bigquery\" %}{{ column }}{% else %}{{ \"\\\"\" ~ column ~ \"\\\"\" }}{% endif %}{{\",\" if not loop.last}}\n {%- endfor -%}\n {%- endif %}\n\n from source\n\n)\n\nselect * from renamed\n{% endset %}\n\n{% if execute %}\n\n{{ log(base_model_sql, info=True) }}\n{% do return(base_model_sql) %}\n\n{% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6616354, "supported_languages": null}, "macro.codegen.create_base_models": {"name": "create_base_models", "resource_type": "macro", "package_name": "codegen", "path": "macros/create_base_models.sql", "original_file_path": "macros/create_base_models.sql", "unique_id": "macro.codegen.create_base_models", "macro_sql": "{% macro create_base_models(source_name, tables) %}\n\n{% set source_name = \"\"~ source_name ~\"\" %}\n\n{% set zsh_command_models = \"source dbt_packages/codegen/bash_scripts/base_model_creation.sh \"\"\"~ source_name ~\"\"\" \" %}\n\n{%- set models_array = [] -%}\n\n{% for t in tables %}\n {% set help_command = zsh_command_models + t %}\n {{ models_array.append(help_command) }}\n{% endfor %}\n\n{{ log(\"Run these commands in your shell to generate the models:\\n\" ~ models_array|join(' && \\n'), info=True) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6630478, "supported_languages": null}, "macro.codegen.generate_model_import_ctes": {"name": "generate_model_import_ctes", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_model_import_ctes.sql", "original_file_path": "macros/generate_model_import_ctes.sql", "unique_id": "macro.codegen.generate_model_import_ctes", "macro_sql": "{% macro generate_model_import_ctes(model_name, leading_commas = false) %}\n\n {%- if execute -%}\n {%- set nodes = graph.nodes.values() -%}\n\n {%- set model = (nodes\n | selectattr('name', 'equalto', model_name) \n | selectattr('resource_type', 'equalto', 'model')\n | list).pop() -%}\n\n {%- set model_raw_sql = model.raw_sql or model.raw_code -%}\n {%- else -%}\n {%- set model_raw_sql = '' -%}\n {%- endif -%}\n\n {#-\n\n REGEX Explanations\n\n # with_regex\n - matches (start of file followed by anything then whitespace\n or whitespace\n or a comma) followed by the word with then a space \n\n # from_ref \n - matches (from or join) followed by some spaces and then {{ref()}}\n\n # from_source \n - matches (from or join) followed by some spaces and then {{source(,)}}\n\n # from_var_1\n - matches (from or join) followed by some spaces and then {{var()}}\n\n # from_var_2\n - matches (from or join) followed by some spaces and then {{var(,)}}\n\n # from_table_1\n - matches (from or join) followed by some spaces and then .\n where each is enclosed by (` or [ or \" or ' or nothing)\n\n # from_table_2\n - matches (from or join) followed by some spaces and then ..\n where each is enclosed by (` or [ or \" or ' or nothing)\n\n # from_table_3\n - matches (from or join) followed by some spaces and then \n where is enclosed by (` or [ or \" or ')\n\n # config block\n - matches the start of the file followed by anything and then {{config()}}\n\n -#}\n\n {%- set re = modules.re -%}\n\n {%- set with_regex = '(?i)(?s)(^.*\\s*|\\s+|,)with\\s' -%}\n {%- set does_raw_sql_contain_cte = re.search(with_regex, model_raw_sql) -%}\n\n {%- set from_regexes = {\n 'from_ref':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character\n (from|join)\\s+\n\n # second matching group\n # opening {{, 0 or more whitespace character(s), ref, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark\n ({{\\s*ref\\s*\\(\\s*[\\'\\\"]?)\n \n # third matching group\n # at least 1 of anything except a parenthesis or quotation mark\n ([^)\\'\\\"]+)\n \n # fourth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # fifth matching group\n # a closing parenthesis, 0 or more whitespace character(s), closing }}\n (\\)\\s*}})\n \n ',\n 'from_source':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character\n (from|join)\\s+\n\n # second matching group\n # opening {{, 0 or more whitespace character(s), source, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark\n ({{\\s*source\\s*\\(\\s*[\\'\\\"]?)\n\n # third matching group\n # at least 1 of anything except a parenthesis or quotation mark\n ([^)\\'\\\"]+)\n\n # fourth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # fifth matching group\n # a comma\n (,)\n\n # sixth matching group\n # 0 or more whitespace character(s), 1 or 0 quotation mark\n (\\s*[\\'\\\"]?)\n\n # seventh matching group\n # at least 1 of anything except a parenthesis or quotation mark\n ([^)\\'\\\"]+)\n\n # eighth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # ninth matching group\n # a closing parenthesis, 0 or more whitespace character(s), closing }}\n (\\)\\s*}})\n\n ',\n 'from_var_1':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character\n (from|join)\\s+\n\n # second matching group\n # opening {{, 0 or more whitespace character(s), var, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark\n ({{\\s*var\\s*\\(\\s*[\\'\\\"]?)\n\n # third matching group\n # at least 1 of anything except a parenthesis or quotation mark\n ([^)\\'\\\"]+)\n\n # fourth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # fifth matching group\n # a closing parenthesis, 0 or more whitespace character(s), closing }}\n (\\)\\s*}})\n \n ',\n 'from_var_2':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character\n (from|join)\\s+\n \n # second matching group\n # opening {{, 0 or more whitespace character(s), var, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark\n ({{\\s*var\\s*\\(\\s*[\\'\\\"]?)\n\n # third matching group\n # at least 1 of anything except a parenthesis or quotation mark \n ([^)\\'\\\"]+)\n \n # fourth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # fifth matching group\n # a comma\n (,)\n\n # sixth matching group\n # 0 or more whitespace character(s), 1 or 0 quotation mark \n (\\s*[\\'\\\"]?)\n\n # seventh matching group\n # at least 1 of anything except a parenthesis or quotation mark \n ([^)\\'\\\"]+)\n\n # eighth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s) \n ([\\'\\\"]?\\s*)\n\n # ninth matching group\n # a closing parenthesis, 0 or more whitespace character(s), closing }} \n (\\)\\s*}})\n \n ',\n 'from_table_1':\n '(?ix)\n \n # first matching group\n # from or join followed by at least 1 whitespace character \n (from|join)\\s+\n \n # second matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark)\n ([\\[`\\\"\\']?)\n \n # third matching group\n # at least 1 word character\n (\\w+)\n \n # fouth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark)\n ([\\]`\\\"\\']?)\n \n # fifth matching group\n # a period\n (\\.)\n \n # sixth matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark)\n ([\\[`\\\"\\']?)\n \n # seventh matching group\n # at least 1 word character\n (\\w+)\n \n # eighth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string\n ([\\]`\\\"\\']?)(?=\\s|$)\n \n ',\n 'from_table_2':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character \n (from|join)\\s+\n \n # second matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark) \n ([\\[`\\\"\\']?)\n \n # third matching group\n # at least 1 word character\n (\\w+)\n\n # fouth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) \n ([\\]`\\\"\\']?)\n \n # fifth matching group\n # a period \n (\\.)\n \n # sixth matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark)\n ([\\[`\\\"\\']?)\n\n # seventh matching group\n # at least 1 word character \n (\\w+)\n \n # eighth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) \n ([\\]`\\\"\\']?)\n \n # ninth matching group\n # a period \n (\\.)\n \n # tenth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) \n ([\\[`\\\"\\']?)\n \n # eleventh matching group\n # at least 1 word character \n (\\w+)\n\n # twelfth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string\n ([\\]`\\\"\\']?)(?=\\s|$)\n \n ',\n 'from_table_3':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character \n (from|join)\\s+\n \n # second matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark) \n ([\\[`\\\"\\'])\n \n # third matching group\n # at least 1 word character or space \n ([\\w ]+)\n\n # fourth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string\n ([\\]`\\\"\\'])(?=\\s|$)\n \n ',\n 'config_block':'(?i)(?s)^.*{{\\s*config\\s*\\([^)]+\\)\\s*}}'\n } -%}\n\n {%- set from_list = [] -%}\n {%- set config_list = [] -%}\n {%- set ns = namespace(model_sql = model_raw_sql) -%}\n\n {%- for regex_name, regex_pattern in from_regexes.items() -%}\n\n {%- set all_regex_matches = re.findall(regex_pattern, model_raw_sql) -%}\n\n {%- for match in all_regex_matches -%}\n\n {%- if regex_name == 'config_block' -%}\n {%- set match_tuple = (match|trim, regex_name) -%}\n {%- do config_list.append(match_tuple) -%}\n {%- elif regex_name == 'from_source' -%} \n {%- set full_from_clause = match[1:]|join|trim -%}\n {%- set cte_name = 'source_' + match[6]|lower -%}\n {%- set match_tuple = (cte_name, full_from_clause, regex_name) -%}\n {%- do from_list.append(match_tuple) -%} \n {%- elif regex_name == 'from_table_1' -%}\n {%- set full_from_clause = match[1:]|join()|trim -%}\n {%- set cte_name = match[2]|lower + '_' + match[6]|lower -%}\n {%- set match_tuple = (cte_name, full_from_clause, regex_name) -%}\n {%- do from_list.append(match_tuple) -%} \n {%- elif regex_name == 'from_table_2' -%}\n {%- set full_from_clause = match[1:]|join()|trim -%}\n {%- set cte_name = match[2]|lower + '_' + match[6]|lower + '_' + match[10]|lower -%}\n {%- set match_tuple = (cte_name, full_from_clause, regex_name) -%}\n {%- do from_list.append(match_tuple) -%} \n {%- else -%}\n {%- set full_from_clause = match[1:]|join|trim -%}\n {%- set cte_name = match[2]|trim|lower -%}\n {%- set match_tuple = (cte_name, full_from_clause, regex_name) -%}\n {%- do from_list.append(match_tuple) -%}\n {%- endif -%}\n\n {%- endfor -%}\n\n {%- if regex_name == 'config_block' -%}\n {%- elif regex_name == 'from_source' -%}\n {%- set ns.model_sql = re.sub(regex_pattern, '\\g<1> source_\\g<7>', ns.model_sql) -%} \n {%- elif regex_name == 'from_table_1' -%}\n {%- set ns.model_sql = re.sub(regex_pattern, '\\g<1> \\g<3>_\\g<7>', ns.model_sql) -%} \n {%- elif regex_name == 'from_table_2' -%}\n {%- set ns.model_sql = re.sub(regex_pattern, '\\g<1> \\g<3>_\\g<7>_\\g<11>', ns.model_sql) -%} \n {%- else -%} \n {%- set ns.model_sql = re.sub(regex_pattern, '\\g<1> \\g<3>', ns.model_sql) -%} \n {% endif %}\n\n {%- endfor -%}\n\n{%- if from_list|length > 0 -%}\n\n{%- set model_import_ctes -%}\n\n {%- for config_obj in config_list -%}\n\n {%- set ns.model_sql = ns.model_sql|replace(config_obj[0], '') -%}\n\n{{ config_obj[0] }}\n\n{% endfor -%}\n\n {%- for from_obj in from_list|unique|sort -%}\n\n{%- if loop.first -%}with {% else -%}{%- if leading_commas -%},{%- endif -%}{%- endif -%}{{ from_obj[0] }} as (\n\n select * from {{ from_obj[1] }}\n {%- if from_obj[2] == 'from_source' and from_list|length > 1 %} \n -- CAUTION: It's best practice to create staging layer for raw sources\n {%- elif from_obj[2] == 'from_table_1' or from_obj[2] == 'from_table_2' or from_obj[2] == 'from_table_3' %}\n -- CAUTION: It's best practice to use the ref or source function instead of a direct reference\n {%- elif from_obj[2] == 'from_var_1' or from_obj[2] == 'from_var_2' %}\n -- CAUTION: It's best practice to use the ref or source function instead of a var\n {%- endif %}\n \n){%- if ((loop.last and does_raw_sql_contain_cte) or (not loop.last)) and not leading_commas -%},{%- endif %}\n\n{% endfor -%}\n\n{%- if does_raw_sql_contain_cte -%}\n {%- if leading_commas -%}\n {%- set replace_with = '\\g<1>,' -%}\n {%- else -%}\n {%- set replace_with = '\\g<1>' -%}\n {%- endif -%}\n{{ re.sub(with_regex, replace_with, ns.model_sql, 1)|trim }}\n{%- else -%}\n{{ ns.model_sql|trim }}\n{%- endif -%}\n\n{%- endset -%}\n\n{%- else -%}\n\n{% set model_import_ctes = model_raw_sql %}\n\n{%- endif -%}\n\n{%- if execute -%}\n\n{{ log(model_import_ctes, info=True) }}\n{% do return(model_import_ctes) %}\n\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6833742, "supported_languages": null}, "macro.codegen.generate_column_yaml": {"name": "generate_column_yaml", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_model_yaml.sql", "original_file_path": "macros/generate_model_yaml.sql", "unique_id": "macro.codegen.generate_column_yaml", "macro_sql": "{% macro generate_column_yaml(column, model_yaml, column_desc_dict, include_data_types, parent_column_name=\"\") %}\n {% if parent_column_name %}\n {% set column_name = parent_column_name ~ \".\" ~ column.name %}\n {% else %}\n {% set column_name = column.name %}\n {% endif %}\n\n {% do model_yaml.append(' - name: ' ~ column_name | lower ) %}\n {% if include_data_types %}\n {% do model_yaml.append(' data_type: ' ~ codegen.data_type_format_model(column)) %}\n {% endif %}\n {% do model_yaml.append(' description: \"' ~ column_desc_dict.get(column.name | lower,'') ~ '\"') %}\n {% do model_yaml.append('') %}\n\n {% if column.fields|length > 0 %}\n {% for child_column in column.fields %}\n {% set model_yaml = codegen.generate_column_yaml(child_column, model_yaml, column_desc_dict, include_data_types, parent_column_name=column_name) %}\n {% endfor %}\n {% endif %}\n {% do return(model_yaml) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.data_type_format_model", "macro.codegen.generate_column_yaml"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.687815, "supported_languages": null}, "macro.codegen.generate_model_yaml": {"name": "generate_model_yaml", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_model_yaml.sql", "original_file_path": "macros/generate_model_yaml.sql", "unique_id": "macro.codegen.generate_model_yaml", "macro_sql": "{% macro generate_model_yaml(model_names=[], upstream_descriptions=False, include_data_types=True) %}\n\n {% set model_yaml=[] %}\n\n {% do model_yaml.append('version: 2') %}\n {% do model_yaml.append('') %}\n {% do model_yaml.append('models:') %}\n\n {% if model_names is string %}\n {{ exceptions.raise_compiler_error(\"The `model_names` argument must always be a list, even if there is only one model.\") }}\n {% else %}\n {% for model in model_names %}\n {% do model_yaml.append(' - name: ' ~ model | lower) %}\n {% do model_yaml.append(' description: \"\"') %}\n {% do model_yaml.append(' columns:') %}\n\n {% set relation=ref(model) %}\n {%- set columns = adapter.get_columns_in_relation(relation) -%}\n {% set column_desc_dict = codegen.build_dict_column_descriptions(model) if upstream_descriptions else {} %}\n\n {% for column in columns %}\n {% set model_yaml = codegen.generate_column_yaml(column, model_yaml, column_desc_dict, include_data_types) %}\n {% endfor %}\n {% endfor %}\n {% endif %}\n\n{% if execute %}\n\n {% set joined = model_yaml | join ('\\n') %}\n {{ log(joined, info=True) }}\n {% do return(joined) %}\n\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.build_dict_column_descriptions", "macro.codegen.generate_column_yaml"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6907203, "supported_languages": null}, "macro.codegen.get_tables_in_schema": {"name": "get_tables_in_schema", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_source.sql", "original_file_path": "macros/generate_source.sql", "unique_id": "macro.codegen.get_tables_in_schema", "macro_sql": "{% macro get_tables_in_schema(schema_name, database_name=target.database, table_pattern='%', exclude='') %}\n \n {% set tables=dbt_utils.get_relations_by_pattern(\n schema_pattern=schema_name,\n database=database_name,\n table_pattern=table_pattern,\n exclude=exclude\n ) %}\n\n {% set table_list= tables | map(attribute='identifier') %}\n\n {{ return(table_list | sort) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_relations_by_pattern"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.69439, "supported_languages": null}, "macro.codegen.generate_source": {"name": "generate_source", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_source.sql", "original_file_path": "macros/generate_source.sql", "unique_id": "macro.codegen.generate_source", "macro_sql": "{% macro generate_source(schema_name, database_name=target.database, generate_columns=False, include_descriptions=False, include_data_types=True, table_pattern='%', exclude='', name=schema_name, table_names=None, include_database=False, include_schema=False) %}\n\n{% set sources_yaml=[] %}\n{% do sources_yaml.append('version: 2') %}\n{% do sources_yaml.append('') %}\n{% do sources_yaml.append('sources:') %}\n{% do sources_yaml.append(' - name: ' ~ name | lower) %}\n\n{% if include_descriptions %}\n {% do sources_yaml.append(' description: \"\"' ) %}\n{% endif %}\n\n{% if database_name != target.database or include_database %}\n{% do sources_yaml.append(' database: ' ~ database_name | lower) %}\n{% endif %}\n\n{% if schema_name != name or include_schema %}\n{% do sources_yaml.append(' schema: ' ~ schema_name | lower) %}\n{% endif %}\n\n{% do sources_yaml.append(' tables:') %}\n\n{% if table_names is none %}\n{% set tables=codegen.get_tables_in_schema(schema_name, database_name, table_pattern, exclude) %}\n{% else %}\n{% set tables = table_names %}\n{% endif %}\n\n{% for table in tables %}\n {% do sources_yaml.append(' - name: ' ~ table | lower ) %}\n {% if include_descriptions %}\n {% do sources_yaml.append(' description: \"\"' ) %}\n {% endif %}\n {% if generate_columns %}\n {% do sources_yaml.append(' columns:') %}\n\n {% set table_relation=api.Relation.create(\n database=database_name,\n schema=schema_name,\n identifier=table\n ) %}\n\n {% set columns=adapter.get_columns_in_relation(table_relation) %}\n\n {% for column in columns %}\n {% do sources_yaml.append(' - name: ' ~ column.name | lower ) %}\n {% if include_data_types %}\n {% do sources_yaml.append(' data_type: ' ~ codegen.data_type_format_source(column)) %}\n {% endif %}\n {% if include_descriptions %}\n {% do sources_yaml.append(' description: \"\"' ) %}\n {% endif %}\n {% endfor %}\n {% do sources_yaml.append('') %}\n\n {% endif %}\n\n{% endfor %}\n\n{% if execute %}\n\n {% set joined = sources_yaml | join ('\\n') %}\n {{ log(joined, info=True) }}\n {% do return(joined) %}\n\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.get_tables_in_schema", "macro.codegen.data_type_format_source"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.6997592, "supported_languages": null}, "macro.codegen.format_column": {"name": "format_column", "resource_type": "macro", "package_name": "codegen", "path": "macros/vendored/dbt_core/format_column.sql", "original_file_path": "macros/vendored/dbt_core/format_column.sql", "unique_id": "macro.codegen.format_column", "macro_sql": "{% macro format_column(column) -%}\n {% set data_type = column.dtype %}\n {% set formatted = column.column.lower() ~ \" \" ~ data_type %}\n {{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7006593, "supported_languages": null}, "macro.codegen.get_model_dependencies": {"name": "get_model_dependencies", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.get_model_dependencies", "macro_sql": "{% macro get_model_dependencies(model_name) %}\n {% for node in graph.nodes.values() | selectattr('name', \"equalto\", model_name) %}\n {{ return(node.depends_on.nodes) }}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7029986, "supported_languages": null}, "macro.codegen.add_model_column_descriptions_to_dict": {"name": "add_model_column_descriptions_to_dict", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.add_model_column_descriptions_to_dict", "macro_sql": "{% macro add_model_column_descriptions_to_dict(model_name,dict_with_descriptions={}) %}\n {% for node in graph.nodes.values() | selectattr('name', \"equalto\", model_name) %}\n {% for col_name, col_values in node.columns.items() %}\n {% do dict_with_descriptions.update( {col_name: col_values.description} ) %}\n {% endfor %}\n {% endfor %}\n {{ return(dict_with_descriptions) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7040205, "supported_languages": null}, "macro.codegen.build_dict_column_descriptions": {"name": "build_dict_column_descriptions", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.build_dict_column_descriptions", "macro_sql": "{% macro build_dict_column_descriptions(model_name) %}\n {% if execute %}\n {% set glob_dict = {} %}\n {% for full_model in codegen.get_model_dependencies(model_name) %}\n {% do codegen.add_model_column_descriptions_to_dict(full_model.split('.')[-1],glob_dict) %}\n {% endfor %}\n {{ return(glob_dict) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.get_model_dependencies", "macro.codegen.add_model_column_descriptions_to_dict"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7049732, "supported_languages": null}, "macro.codegen.get_models": {"name": "get_models", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.get_models", "macro_sql": "{% macro get_models(directory=None, prefix=None) %}\n {% set model_names=[] %}\n {% set models = graph.nodes.values() | selectattr('resource_type', \"equalto\", 'model') %}\n {% if directory and prefix %}\n {% for model in models %}\n {% set model_path = \"/\".join(model.path.split(\"/\")[:-1]) %}\n {% if model_path == directory and model.name.startswith(prefix) %}\n {% do model_names.append(model.name) %}\n {% endif %} \n {% endfor %}\n {% elif directory %}\n {% for model in models %}\n {% set model_path = \"/\".join(model.path.split(\"/\")[:-1]) %}\n {% if model_path == directory %}\n {% do model_names.append(model.name) %}\n {% endif %}\n {% endfor %}\n {% elif prefix %}\n {% for model in models if model.name.startswith(prefix) %}\n {% do model_names.append(model.name) %}\n {% endfor %}\n {% else %}\n {% for model in models %}\n {% do model_names.append(model.name) %}\n {% endfor %}\n {% endif %}\n {{ return(model_names) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7079837, "supported_languages": null}, "macro.codegen.data_type_format_source": {"name": "data_type_format_source", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.data_type_format_source", "macro_sql": "{% macro data_type_format_source(column) -%}\n {{ return(adapter.dispatch('data_type_format_source', 'codegen')(column)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.codegen.default__data_type_format_source"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.708425, "supported_languages": null}, "macro.codegen.default__data_type_format_source": {"name": "default__data_type_format_source", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.default__data_type_format_source", "macro_sql": "{% macro default__data_type_format_source(column) %}\n {% set formatted = codegen.format_column(column) %}\n {{ return(formatted['data_type'] | lower) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7089539, "supported_languages": null}, "macro.codegen.data_type_format_model": {"name": "data_type_format_model", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.data_type_format_model", "macro_sql": "{% macro data_type_format_model(column) -%}\n {{ return(adapter.dispatch('data_type_format_model', 'codegen')(column)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.codegen.default__data_type_format_model"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7093427, "supported_languages": null}, "macro.codegen.default__data_type_format_model": {"name": "default__data_type_format_model", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.default__data_type_format_model", "macro_sql": "{% macro default__data_type_format_model(column) %}\n {% set formatted = codegen.format_column(column) %}\n {{ return(formatted['data_type'] | lower) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7098203, "supported_languages": null}, "macro.dbt_utils.pretty_log_format": {"name": "pretty_log_format", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_log_format.sql", "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", "unique_id": "macro.dbt_utils.pretty_log_format", "macro_sql": "{% macro pretty_log_format(message) %}\n {{ return(adapter.dispatch('pretty_log_format', 'dbt_utils')(message)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7104228, "supported_languages": null}, "macro.dbt_utils.default__pretty_log_format": {"name": "default__pretty_log_format", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_log_format.sql", "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", "unique_id": "macro.dbt_utils.default__pretty_log_format", "macro_sql": "{% macro default__pretty_log_format(message) %}\n {{ return( dbt_utils.pretty_time() ~ ' + ' ~ message) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7108324, "supported_languages": null}, "macro.dbt_utils.log_info": {"name": "log_info", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/log_info.sql", "original_file_path": "macros/jinja_helpers/log_info.sql", "unique_id": "macro.dbt_utils.log_info", "macro_sql": "{% macro log_info(message) %}\n {{ return(adapter.dispatch('log_info', 'dbt_utils')(message)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__log_info"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7113597, "supported_languages": null}, "macro.dbt_utils.default__log_info": {"name": "default__log_info", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/log_info.sql", "original_file_path": "macros/jinja_helpers/log_info.sql", "unique_id": "macro.dbt_utils.default__log_info", "macro_sql": "{% macro default__log_info(message) %}\n {{ log(dbt_utils.pretty_log_format(message), info=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7117276, "supported_languages": null}, "macro.dbt_utils.slugify": {"name": "slugify", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/slugify.sql", "original_file_path": "macros/jinja_helpers/slugify.sql", "unique_id": "macro.dbt_utils.slugify", "macro_sql": "{% macro slugify(string) %}\n\n{#- Lower case the string -#}\n{% set string = string | lower %}\n{#- Replace spaces and dashes with underscores -#}\n{% set string = modules.re.sub('[ -]+', '_', string) %}\n{#- Only take letters, numbers, and underscores -#}\n{% set string = modules.re.sub('[^a-z0-9_]+', '', string) %}\n{#- Prepends \"_\" if string begins with a number -#}\n{% set string = modules.re.sub('^[0-9]', '_' + string[0], string) %}\n\n{{ return(string) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7130113, "supported_languages": null}, "macro.dbt_utils.pretty_time": {"name": "pretty_time", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_time.sql", "original_file_path": "macros/jinja_helpers/pretty_time.sql", "unique_id": "macro.dbt_utils.pretty_time", "macro_sql": "{% macro pretty_time(format='%H:%M:%S') %}\n {{ return(adapter.dispatch('pretty_time', 'dbt_utils')(format)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.713578, "supported_languages": null}, "macro.dbt_utils.default__pretty_time": {"name": "default__pretty_time", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_time.sql", "original_file_path": "macros/jinja_helpers/pretty_time.sql", "unique_id": "macro.dbt_utils.default__pretty_time", "macro_sql": "{% macro default__pretty_time(format='%H:%M:%S') %}\n {{ return(modules.datetime.datetime.now().strftime(format)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.713988, "supported_languages": null}, "macro.dbt_utils._is_ephemeral": {"name": "_is_ephemeral", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/_is_ephemeral.sql", "original_file_path": "macros/jinja_helpers/_is_ephemeral.sql", "unique_id": "macro.dbt_utils._is_ephemeral", "macro_sql": "{% macro _is_ephemeral(obj, macro) %}\n {%- if obj.is_cte -%}\n {% set ephemeral_prefix = api.Relation.add_ephemeral_prefix('') %}\n {% if obj.name.startswith(ephemeral_prefix) %}\n {% set model_name = obj.name[(ephemeral_prefix|length):] %}\n {% else %}\n {% set model_name = obj.name %}\n {%- endif -%}\n {% set error_message %}\nThe `{{ macro }}` macro cannot be used with ephemeral models, as it relies on the information schema.\n\n`{{ model_name }}` is an ephemeral model. Consider making it a view or table instead.\n {% endset %}\n {%- do exceptions.raise_compiler_error(error_message) -%}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7155802, "supported_languages": null}, "macro.dbt_utils._is_relation": {"name": "_is_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/_is_relation.sql", "original_file_path": "macros/jinja_helpers/_is_relation.sql", "unique_id": "macro.dbt_utils._is_relation", "macro_sql": "{% macro _is_relation(obj, macro) %}\n {%- if not (obj is mapping and obj.get('metadata', {}).get('type', '').endswith('Relation')) -%}\n {%- do exceptions.raise_compiler_error(\"Macro \" ~ macro ~ \" expected a Relation but received the value: \" ~ obj) -%}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7164593, "supported_languages": null}, "macro.dbt_utils.get_url_path": {"name": "get_url_path", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "unique_id": "macro.dbt_utils.get_url_path", "macro_sql": "{% macro get_url_path(field) -%}\n {{ return(adapter.dispatch('get_url_path', 'dbt_utils')(field)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_path"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7173378, "supported_languages": null}, "macro.dbt_utils.default__get_url_path": {"name": "default__get_url_path", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "unique_id": "macro.dbt_utils.default__get_url_path", "macro_sql": "{% macro default__get_url_path(field) -%}\n\n {%- set stripped_url =\n dbt.replace(\n dbt.replace(field, \"'http://'\", \"''\"), \"'https://'\", \"''\")\n -%}\n\n {%- set first_slash_pos -%}\n coalesce(\n nullif({{ dbt.position(\"'/'\", stripped_url) }}, 0),\n {{ dbt.position(\"'?'\", stripped_url) }} - 1\n )\n {%- endset -%}\n\n {%- set parsed_path =\n dbt.split_part(\n dbt.right(\n stripped_url,\n dbt.length(stripped_url) ~ \"-\" ~ first_slash_pos\n ),\n \"'?'\", 1\n )\n -%}\n\n {{ dbt.safe_cast(\n parsed_path,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.position", "macro.dbt.split_part", "macro.dbt.right", "macro.dbt.length", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7188041, "supported_languages": null}, "macro.dbt_utils.get_url_host": {"name": "get_url_host", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "unique_id": "macro.dbt_utils.get_url_host", "macro_sql": "{% macro get_url_host(field) -%}\n {{ return(adapter.dispatch('get_url_host', 'dbt_utils')(field)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_host"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7194693, "supported_languages": null}, "macro.dbt_utils.default__get_url_host": {"name": "default__get_url_host", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "unique_id": "macro.dbt_utils.default__get_url_host", "macro_sql": "{% macro default__get_url_host(field) -%}\n\n{%- set parsed =\n dbt.split_part(\n dbt.split_part(\n dbt.replace(\n dbt.replace(\n dbt.replace(field, \"'android-app://'\", \"''\"\n ), \"'http://'\", \"''\"\n ), \"'https://'\", \"''\"\n ), \"'/'\", 1\n ), \"'?'\", 1\n )\n\n-%}\n\n\n {{ dbt.safe_cast(\n parsed,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.split_part", "macro.dbt.replace", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7204323, "supported_languages": null}, "macro.dbt_utils.get_url_parameter": {"name": "get_url_parameter", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "unique_id": "macro.dbt_utils.get_url_parameter", "macro_sql": "{% macro get_url_parameter(field, url_parameter) -%}\n {{ return(adapter.dispatch('get_url_parameter', 'dbt_utils')(field, url_parameter)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_parameter"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7210977, "supported_languages": null}, "macro.dbt_utils.default__get_url_parameter": {"name": "default__get_url_parameter", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "unique_id": "macro.dbt_utils.default__get_url_parameter", "macro_sql": "{% macro default__get_url_parameter(field, url_parameter) -%}\n\n{%- set formatted_url_parameter = \"'\" + url_parameter + \"='\" -%}\n\n{%- set split = dbt.split_part(dbt.split_part(field, formatted_url_parameter, 2), \"'&'\", 1) -%}\n\nnullif({{ split }},'')\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7217827, "supported_languages": null}, "macro.dbt_utils.get_single_value": {"name": "get_single_value", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_single_value.sql", "original_file_path": "macros/sql/get_single_value.sql", "unique_id": "macro.dbt_utils.get_single_value", "macro_sql": "{% macro get_single_value(query, default=none) %}\n {{ return(adapter.dispatch('get_single_value', 'dbt_utils')(query, default)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_single_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7228048, "supported_languages": null}, "macro.dbt_utils.default__get_single_value": {"name": "default__get_single_value", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_single_value.sql", "original_file_path": "macros/sql/get_single_value.sql", "unique_id": "macro.dbt_utils.default__get_single_value", "macro_sql": "{% macro default__get_single_value(query, default) %}\n\n{# This macro returns the (0, 0) record in a query, i.e. the first row of the first column #}\n\n {%- call statement('get_query_result', fetch_result=True, auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {%- if execute -%}\n\n {% set r = load_result('get_query_result').table.columns[0].values() %}\n {% if r | length == 0 %}\n {% do print('Query `' ~ query ~ '` returned no rows. Using the default value: ' ~ default) %}\n {% set sql_result = default %}\n {% else %}\n {% set sql_result = r[0] %}\n {% endif %}\n \n {%- else -%}\n \n {% set sql_result = default %}\n \n {%- endif -%}\n\n {% do return(sql_result) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7243829, "supported_languages": null}, "macro.dbt_utils.safe_subtract": {"name": "safe_subtract", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_subtract.sql", "original_file_path": "macros/sql/safe_subtract.sql", "unique_id": "macro.dbt_utils.safe_subtract", "macro_sql": "{%- macro safe_subtract(field_list) -%}\n {{ return(adapter.dispatch('safe_subtract', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_subtract"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7251716, "supported_languages": null}, "macro.dbt_utils.default__safe_subtract": {"name": "default__safe_subtract", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_subtract.sql", "original_file_path": "macros/sql/safe_subtract.sql", "unique_id": "macro.dbt_utils.default__safe_subtract", "macro_sql": "\n\n{%- macro default__safe_subtract(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_subtract` macro takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' -\\n ') }}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7263086, "supported_languages": null}, "macro.dbt_utils.deduplicate": {"name": "deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.deduplicate", "macro_sql": "{%- macro deduplicate(relation, partition_by, order_by) -%}\n {{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__deduplicate"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7275589, "supported_languages": null}, "macro.dbt_utils.default__deduplicate": {"name": "default__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.default__deduplicate", "macro_sql": "\n\n{%- macro default__deduplicate(relation, partition_by, order_by) -%}\n\n with row_numbered as (\n select\n _inner.*,\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) as rn\n from {{ relation }} as _inner\n )\n\n select\n distinct data.*\n from {{ relation }} as data\n {#\n -- Not all DBs will support natural joins but the ones that do include:\n -- Oracle, MySQL, SQLite, Redshift, Teradata, Materialize, Databricks\n -- Apache Spark, SingleStore, Vertica\n -- Those that do not appear to support natural joins include:\n -- SQLServer, Trino, Presto, Rockset, Athena\n #}\n natural join row_numbered\n where row_numbered.rn = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7280135, "supported_languages": null}, "macro.dbt_utils.redshift__deduplicate": {"name": "redshift__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.redshift__deduplicate", "macro_sql": "{% macro redshift__deduplicate(relation, partition_by, order_by) -%}\n\n {{ return(dbt_utils.default__deduplicate(relation, partition_by, order_by=order_by)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__deduplicate"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7284384, "supported_languages": null}, "macro.dbt_utils.postgres__deduplicate": {"name": "postgres__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.postgres__deduplicate", "macro_sql": "\n{%- macro postgres__deduplicate(relation, partition_by, order_by) -%}\n\n select\n distinct on ({{ partition_by }}) *\n from {{ relation }}\n order by {{ partition_by }}{{ ',' ~ order_by }}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.728892, "supported_languages": null}, "macro.dbt_utils.snowflake__deduplicate": {"name": "snowflake__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.snowflake__deduplicate", "macro_sql": "\n{%- macro snowflake__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7292616, "supported_languages": null}, "macro.dbt_utils.bigquery__deduplicate": {"name": "bigquery__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.bigquery__deduplicate", "macro_sql": "\n{%- macro bigquery__deduplicate(relation, partition_by, order_by) -%}\n\n select unique.*\n from (\n select\n array_agg (\n original\n order by {{ order_by }}\n limit 1\n )[offset(0)] unique\n from {{ relation }} original\n group by {{ partition_by }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7296312, "supported_languages": null}, "macro.dbt_utils.width_bucket": {"name": "width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.width_bucket", "macro_sql": "{% macro width_bucket(expr, min_value, max_value, num_buckets) %}\n {{ return(adapter.dispatch('width_bucket', 'dbt_utils') (expr, min_value, max_value, num_buckets)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__width_bucket"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7309012, "supported_languages": null}, "macro.dbt_utils.default__width_bucket": {"name": "default__width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.default__width_bucket", "macro_sql": "{% macro default__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is eaxtly at the bucket egde\n case\n when\n mod(\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }},\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n ) = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.safe_cast", "macro.dbt.type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7318652, "supported_languages": null}, "macro.dbt_utils.snowflake__width_bucket": {"name": "snowflake__width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.snowflake__width_bucket", "macro_sql": "{% macro snowflake__width_bucket(expr, min_value, max_value, num_buckets) %}\n width_bucket({{ expr }}, {{ min_value }}, {{ max_value }}, {{ num_buckets }} )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7322824, "supported_languages": null}, "macro.dbt_utils.safe_divide": {"name": "safe_divide", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_divide.sql", "original_file_path": "macros/sql/safe_divide.sql", "unique_id": "macro.dbt_utils.safe_divide", "macro_sql": "{% macro safe_divide(numerator, denominator) -%}\n {{ return(adapter.dispatch('safe_divide', 'dbt_utils')(numerator, denominator)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_divide"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7328777, "supported_languages": null}, "macro.dbt_utils.default__safe_divide": {"name": "default__safe_divide", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_divide.sql", "original_file_path": "macros/sql/safe_divide.sql", "unique_id": "macro.dbt_utils.default__safe_divide", "macro_sql": "{% macro default__safe_divide(numerator, denominator) %}\n ( {{ numerator }} ) / nullif( ( {{ denominator }} ), 0)\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7331789, "supported_languages": null}, "macro.dbt_utils.nullcheck_table": {"name": "nullcheck_table", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "unique_id": "macro.dbt_utils.nullcheck_table", "macro_sql": "{% macro nullcheck_table(relation) %}\n {{ return(adapter.dispatch('nullcheck_table', 'dbt_utils')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7337856, "supported_languages": null}, "macro.dbt_utils.default__nullcheck_table": {"name": "default__nullcheck_table", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "unique_id": "macro.dbt_utils.default__nullcheck_table", "macro_sql": "{% macro default__nullcheck_table(relation) %}\n\n {%- do dbt_utils._is_relation(relation, 'nullcheck_table') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'nullcheck_table') -%}\n {% set cols = adapter.get_columns_in_relation(relation) %}\n\n select {{ dbt_utils.nullcheck(cols) }}\n from {{relation}}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7346513, "supported_languages": null}, "macro.dbt_utils.pivot": {"name": "pivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "unique_id": "macro.dbt_utils.pivot", "macro_sql": "{% macro pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {{ return(adapter.dispatch('pivot', 'dbt_utils')(column, values, alias, agg, cmp, prefix, suffix, then_value, else_value, quote_identifiers, distinct)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7364647, "supported_languages": null}, "macro.dbt_utils.default__pivot": {"name": "default__pivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "unique_id": "macro.dbt_utils.default__pivot", "macro_sql": "{% macro default__pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {% for value in values %}\n {{ agg }}(\n {% if distinct %} distinct {% endif %}\n case\n when {{ column }} {{ cmp }} '{{ dbt.escape_single_quotes(value) }}'\n then {{ then_value }}\n else {{ else_value }}\n end\n )\n {% if alias %}\n {% if quote_identifiers %}\n as {{ adapter.quote(prefix ~ value ~ suffix) }}\n {% else %}\n as {{ dbt_utils.slugify(prefix ~ value ~ suffix) }}\n {% endif %}\n {% endif %}\n {% if not loop.last %},{% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.escape_single_quotes", "macro.dbt_utils.slugify"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.738293, "supported_languages": null}, "macro.dbt_utils.union_relations": {"name": "union_relations", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "unique_id": "macro.dbt_utils.union_relations", "macro_sql": "{%- macro union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n {{ return(adapter.dispatch('union_relations', 'dbt_utils')(relations, column_override, include, exclude, source_column_name, where)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__union_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.742962, "supported_languages": null}, "macro.dbt_utils.default__union_relations": {"name": "default__union_relations", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "unique_id": "macro.dbt_utils.default__union_relations", "macro_sql": "\n\n{%- macro default__union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n {%- set all_excludes = [] -%}\n {%- set all_includes = [] -%}\n\n {%- if exclude -%}\n {%- for exc in exclude -%}\n {%- do all_excludes.append(exc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if include -%}\n {%- for inc in include -%}\n {%- do all_includes.append(inc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column | lower in all_excludes -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column | lower not in all_includes -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n {%- set dbt_command = flags.WHICH -%}\n\n\n {% if dbt_command in ['run', 'build'] %}\n {% if (include | length > 0 or exclude | length > 0) and not column_superset.keys() %}\n {%- set relations_string -%}\n {%- for relation in relations -%}\n {{ relation.name }}\n {%- if not loop.last %}, {% endif -%}\n {%- endfor -%}\n {%- endset -%}\n\n {%- set error_message -%}\n There were no columns found to union for relations {{ relations_string }}\n {%- endset -%}\n\n {{ exceptions.raise_compiler_error(error_message) }}\n {%- endif -%}\n {%- endif -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n {%- if source_column_name is not none %}\n cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }},\n {%- endif %}\n\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ relation }}\n\n {% if where -%}\n where {{ where }}\n {%- endif %}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.string_literal", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.750606, "supported_languages": null}, "macro.dbt_utils.get_tables_by_prefix_sql": {"name": "get_tables_by_prefix_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "unique_id": "macro.dbt_utils.get_tables_by_prefix_sql", "macro_sql": "{% macro get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_prefix_sql', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7514386, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_prefix_sql": {"name": "default__get_tables_by_prefix_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "unique_id": "macro.dbt_utils.default__get_tables_by_prefix_sql", "macro_sql": "{% macro default__get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(\n schema_pattern = schema,\n table_pattern = prefix ~ '%',\n exclude = exclude,\n database = database\n ) }}\n \n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7520323, "supported_languages": null}, "macro.dbt_utils.get_table_types_sql": {"name": "get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.get_table_types_sql", "macro_sql": "{%- macro get_table_types_sql() -%}\n {{ return(adapter.dispatch('get_table_types_sql', 'dbt_utils')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_utils.default__get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.752928, "supported_languages": null}, "macro.dbt_utils.default__get_table_types_sql": {"name": "default__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.default__get_table_types_sql", "macro_sql": "{% macro default__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'EXTERNAL TABLE' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7532303, "supported_languages": null}, "macro.dbt_utils.postgres__get_table_types_sql": {"name": "postgres__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.postgres__get_table_types_sql", "macro_sql": "{% macro postgres__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'FOREIGN' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7535224, "supported_languages": null}, "macro.dbt_utils.databricks__get_table_types_sql": {"name": "databricks__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.databricks__get_table_types_sql", "macro_sql": "{% macro databricks__get_table_types_sql() %}\n case table_type\n when 'MANAGED' then 'table'\n when 'BASE TABLE' then 'table'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7538092, "supported_languages": null}, "macro.dbt_utils.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.755173, "supported_languages": null}, "macro.dbt_utils.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7560527, "supported_languages": null}, "macro.dbt_utils.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7564528, "supported_languages": null}, "macro.dbt_utils.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_utils.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7576087, "supported_languages": null}, "macro.dbt_utils.get_tables_by_pattern_sql": {"name": "get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.get_tables_by_pattern_sql", "macro_sql": "{% macro get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_pattern_sql', 'dbt_utils')\n (schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.760182, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_pattern_sql": {"name": "default__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.default__get_tables_by_pattern_sql", "macro_sql": "{% macro default__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from {{ database }}.information_schema.tables\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7609844, "supported_languages": null}, "macro.dbt_utils.bigquery__get_tables_by_pattern_sql": {"name": "bigquery__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.bigquery__get_tables_by_pattern_sql", "macro_sql": "{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% if '%' in schema_pattern %}\n {% set schemata=dbt_utils._bigquery__get_matching_schemata(schema_pattern, database) %}\n {% else %}\n {% set schemata=[schema_pattern] %}\n {% endif %}\n\n {% set sql %}\n {% for schema in schemata %}\n select distinct\n table_schema,\n table_name,\n {{ dbt_utils.get_table_types_sql() }}\n\n from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES\n where lower(table_name) like lower ('{{ table_pattern }}')\n and lower(table_name) not like lower ('{{ exclude }}')\n\n {% if not loop.last %} union all {% endif %}\n\n {% endfor %}\n {% endset %}\n\n {{ return(sql) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._bigquery__get_matching_schemata", "macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7625208, "supported_languages": null}, "macro.dbt_utils._bigquery__get_matching_schemata": {"name": "_bigquery__get_matching_schemata", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils._bigquery__get_matching_schemata", "macro_sql": "{% macro _bigquery__get_matching_schemata(schema_pattern, database) %}\n {% if execute %}\n\n {% set sql %}\n select schema_name from {{ adapter.quote(database) }}.INFORMATION_SCHEMA.SCHEMATA\n where lower(schema_name) like lower('{{ schema_pattern }}')\n {% endset %}\n\n {% set results=run_query(sql) %}\n\n {% set schemata=results.columns['schema_name'].values() %}\n\n {{ return(schemata) }}\n\n {% else %}\n\n {{ return([]) }}\n\n {% endif %}\n\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7636135, "supported_languages": null}, "macro.dbt_utils.get_column_values": {"name": "get_column_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "unique_id": "macro.dbt_utils.get_column_values", "macro_sql": "{% macro get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {{ return(adapter.dispatch('get_column_values', 'dbt_utils')(table, column, order_by, max_records, default, where)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_column_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7655368, "supported_languages": null}, "macro.dbt_utils.default__get_column_values": {"name": "default__get_column_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "unique_id": "macro.dbt_utils.default__get_column_values", "macro_sql": "{% macro default__get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {% set default = [] if not default %}\n {{ return(default) }}\n {% endif %}\n\n {%- do dbt_utils._is_ephemeral(table, 'get_column_values') -%}\n\n {# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #}\n {# TODO: Change the method signature in a future 0.x.0 release #}\n {%- set target_relation = table -%}\n\n {# adapter.load_relation is a convenience wrapper to avoid building a Relation when we already have one #}\n {% set relation_exists = (load_relation(target_relation)) is not none %}\n\n {%- call statement('get_column_values', fetch_result=true) %}\n\n {%- if not relation_exists and default is none -%}\n\n {{ exceptions.raise_compiler_error(\"In get_column_values(): relation \" ~ target_relation ~ \" does not exist and no default value was provided.\") }}\n\n {%- elif not relation_exists and default is not none -%}\n\n {{ log(\"Relation \" ~ target_relation ~ \" does not exist. Returning the default value: \" ~ default) }}\n\n {{ return(default) }}\n\n {%- else -%}\n\n\n select\n {{ column }} as value\n\n from {{ target_relation }}\n\n {% if where is not none %}\n where {{ where }}\n {% endif %}\n\n group by {{ column }}\n order by {{ order_by }}\n\n {% if max_records is not none %}\n limit {{ max_records }}\n {% endif %}\n\n {% endif %}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_column_values') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values) }}\n {%- else -%}\n {{ return(default) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_ephemeral", "macro.dbt.load_relation", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7688625, "supported_languages": null}, "macro.dbt_utils.degrees_to_radians": {"name": "degrees_to_radians", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.degrees_to_radians", "macro_sql": "{% macro degrees_to_radians(degrees) -%}\n acos(-1) * {{degrees}} / 180\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7705154, "supported_languages": null}, "macro.dbt_utils.haversine_distance": {"name": "haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.haversine_distance", "macro_sql": "{% macro haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n {{ return(adapter.dispatch('haversine_distance', 'dbt_utils')(lat1,lon1,lat2,lon2,unit)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__haversine_distance"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7710977, "supported_languages": null}, "macro.dbt_utils.default__haversine_distance": {"name": "default__haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.default__haversine_distance", "macro_sql": "{% macro default__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n\n 2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +\n cos(radians({{lat1}})) * cos(radians({{lat2}})) *\n power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7722893, "supported_languages": null}, "macro.dbt_utils.bigquery__haversine_distance": {"name": "bigquery__haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.bigquery__haversine_distance", "macro_sql": "{% macro bigquery__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{% set radians_lat1 = dbt_utils.degrees_to_radians(lat1) %}\n{% set radians_lat2 = dbt_utils.degrees_to_radians(lat2) %}\n{% set radians_lon1 = dbt_utils.degrees_to_radians(lon1) %}\n{% set radians_lon2 = dbt_utils.degrees_to_radians(lon2) %}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n 2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +\n cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) *\n power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.degrees_to_radians"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7740595, "supported_languages": null}, "macro.dbt_utils.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_utils')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7752638, "supported_languages": null}, "macro.dbt_utils.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.77652, "supported_languages": null}, "macro.dbt_utils.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_utils')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7770646, "supported_languages": null}, "macro.dbt_utils.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{dbt_utils.generate_series(\n dbt_utils.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.generate_series", "macro.dbt_utils.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7778363, "supported_languages": null}, "macro.dbt_utils.get_query_results_as_dict": {"name": "get_query_results_as_dict", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "unique_id": "macro.dbt_utils.get_query_results_as_dict", "macro_sql": "{% macro get_query_results_as_dict(query) %}\n {{ return(adapter.dispatch('get_query_results_as_dict', 'dbt_utils')(query)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_query_results_as_dict"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7785938, "supported_languages": null}, "macro.dbt_utils.default__get_query_results_as_dict": {"name": "default__get_query_results_as_dict", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "unique_id": "macro.dbt_utils.default__get_query_results_as_dict", "macro_sql": "{% macro default__get_query_results_as_dict(query) %}\n\n{# This macro returns a dictionary of the form {column_name: (tuple_of_results)} #}\n\n {%- call statement('get_query_results', fetch_result=True,auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {% set sql_results={} %}\n\n {%- if execute -%}\n {% set sql_results_table = load_result('get_query_results').table.columns %}\n {% for column_name, column in sql_results_table.items() %}\n {% do sql_results.update({column_name: column.values()}) %}\n {% endfor %}\n {%- endif -%}\n\n {{ return(sql_results) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7798908, "supported_languages": null}, "macro.dbt_utils.star": {"name": "star", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "unique_id": "macro.dbt_utils.star", "macro_sql": "{% macro star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix, quote_identifiers)) }}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__star"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.781991, "supported_languages": null}, "macro.dbt_utils.default__star": {"name": "default__star", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "unique_id": "macro.dbt_utils.default__star", "macro_sql": "{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {%- do dbt_utils._is_relation(from, 'star') -%}\r\n {%- do dbt_utils._is_ephemeral(from, 'star') -%}\r\n\r\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\r\n {%- if not execute -%}\r\n {% do return('*') %}\r\n {%- endif -%}\r\n\r\n {% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %}\r\n\r\n {%- if cols|length <= 0 -%}\r\n {% if flags.WHICH == 'compile' %}\r\n {% set response %}\r\n*\r\n/* No columns were returned. Maybe the relation doesn't exist yet \r\nor all columns were excluded. This star is only output during \r\ndbt compile, and exists to keep SQLFluff happy. */\r\n {% endset %}\r\n {% do return(response) %}\r\n {% else %}\r\n {% do return(\"/* no columns returned from star() macro */\") %}\r\n {% endif %}\r\n {%- else -%}\r\n {%- for col in cols %}\r\n {%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}\r\n {%- if quote_identifiers -%}\r\n {{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {%- else -%}\r\n {{ col|trim }} {%- if prefix!='' or suffix!='' %} as {{ (prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {% endif %}\r\n {%- if not loop.last %},{{ '\\n ' }}{%- endif -%}\r\n {%- endfor -%}\r\n {% endif %}\r\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7854197, "supported_languages": null}, "macro.dbt_utils.group_by": {"name": "group_by", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "unique_id": "macro.dbt_utils.group_by", "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_utils')(n)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__group_by"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.786018, "supported_languages": null}, "macro.dbt_utils.default__group_by": {"name": "default__group_by", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "unique_id": "macro.dbt_utils.default__group_by", "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }} \n {%- endfor -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7865582, "supported_languages": null}, "macro.dbt_utils.get_relations_by_prefix": {"name": "get_relations_by_prefix", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "unique_id": "macro.dbt_utils.get_relations_by_prefix", "macro_sql": "{% macro get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_prefix', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_prefix"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.787867, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_prefix": {"name": "default__get_relations_by_prefix", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "unique_id": "macro.dbt_utils.default__get_relations_by_prefix", "macro_sql": "{% macro default__get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_prefix_sql(schema, prefix, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7898276, "supported_languages": null}, "macro.dbt_utils.nullcheck": {"name": "nullcheck", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "unique_id": "macro.dbt_utils.nullcheck", "macro_sql": "{% macro nullcheck(cols) %}\n {{ return(adapter.dispatch('nullcheck', 'dbt_utils')(cols)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.79063, "supported_languages": null}, "macro.dbt_utils.default__nullcheck": {"name": "default__nullcheck", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "unique_id": "macro.dbt_utils.default__nullcheck", "macro_sql": "{% macro default__nullcheck(cols) %}\n{%- for col in cols %}\n\n {% if col.is_string() -%}\n\n nullif({{col.name}},'') as {{col.name}}\n\n {%- else -%}\n\n {{col.name}}\n\n {%- endif -%}\n\n{%- if not loop.last -%} , {%- endif -%}\n\n{%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7916057, "supported_languages": null}, "macro.dbt_utils.surrogate_key": {"name": "surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "unique_id": "macro.dbt_utils.surrogate_key", "macro_sql": "{%- macro surrogate_key(field_list) -%}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('surrogate_key', 'dbt_utils')(field_list, *varargs)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7929351, "supported_languages": null}, "macro.dbt_utils.default__surrogate_key": {"name": "default__surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "unique_id": "macro.dbt_utils.default__surrogate_key", "macro_sql": "\n\n{%- macro default__surrogate_key(field_list) -%}\n\n{%- set error_message = '\nWarning: `dbt_utils.surrogate_key` has been replaced by \\\n`dbt_utils.generate_surrogate_key`. The new macro treats null values \\\ndifferently to empty strings. To restore the behaviour of the original \\\nmacro, add a global variable in dbt_project.yml called \\\n`surrogate_key_treat_nulls_as_empty_strings` to your \\\ndbt_project.yml file with a value of True. \\\nThe {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7938886, "supported_languages": null}, "macro.dbt_utils.get_filtered_columns_in_relation": {"name": "get_filtered_columns_in_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_filtered_columns_in_relation.sql", "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", "unique_id": "macro.dbt_utils.get_filtered_columns_in_relation", "macro_sql": "{% macro get_filtered_columns_in_relation(from, except=[]) -%}\n {{ return(adapter.dispatch('get_filtered_columns_in_relation', 'dbt_utils')(from, except)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7954156, "supported_languages": null}, "macro.dbt_utils.default__get_filtered_columns_in_relation": {"name": "default__get_filtered_columns_in_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_filtered_columns_in_relation.sql", "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", "unique_id": "macro.dbt_utils.default__get_filtered_columns_in_relation", "macro_sql": "{% macro default__get_filtered_columns_in_relation(from, except=[]) -%}\n {%- do dbt_utils._is_relation(from, 'get_filtered_columns_in_relation') -%}\n {%- do dbt_utils._is_ephemeral(from, 'get_filtered_columns_in_relation') -%}\n\n {# -- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n\n {%- set include_cols = [] %}\n {%- set cols = adapter.get_columns_in_relation(from) -%}\n {%- set except = except | map(\"lower\") | list %}\n {%- for col in cols -%}\n {%- if col.column|lower not in except -%}\n {% do include_cols.append(col.column) %}\n {%- endif %}\n {%- endfor %}\n\n {{ return(include_cols) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7977629, "supported_languages": null}, "macro.dbt_utils.generate_surrogate_key": {"name": "generate_surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_surrogate_key.sql", "original_file_path": "macros/sql/generate_surrogate_key.sql", "unique_id": "macro.dbt_utils.generate_surrogate_key", "macro_sql": "{%- macro generate_surrogate_key(field_list) -%}\n {{ return(adapter.dispatch('generate_surrogate_key', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__generate_surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.7986975, "supported_languages": null}, "macro.dbt_utils.default__generate_surrogate_key": {"name": "default__generate_surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_surrogate_key.sql", "original_file_path": "macros/sql/generate_surrogate_key.sql", "unique_id": "macro.dbt_utils.default__generate_surrogate_key", "macro_sql": "\n\n{%- macro default__generate_surrogate_key(field_list) -%}\n\n{%- if var('surrogate_key_treat_nulls_as_empty_strings', False) -%}\n {%- set default_null_value = \"\" -%}\n{%- else -%}\n {%- set default_null_value = '_dbt_utils_surrogate_key_null_' -%}\n{%- endif -%}\n\n{%- set fields = [] -%}\n\n{%- for field in field_list -%}\n\n {%- do fields.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ dbt.type_string() ~ \"), '\" ~ default_null_value ~\"')\"\n ) -%}\n\n {%- if not loop.last %}\n {%- do fields.append(\"'-'\") -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{{ dbt.hash(dbt.concat(fields)) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.hash", "macro.dbt.concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.800392, "supported_languages": null}, "macro.dbt_utils.get_relations_by_pattern": {"name": "get_relations_by_pattern", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "unique_id": "macro.dbt_utils.get_relations_by_pattern", "macro_sql": "{% macro get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_pattern', 'dbt_utils')(schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_pattern"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8022976, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_pattern": {"name": "default__get_relations_by_pattern", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "unique_id": "macro.dbt_utils.default__get_relations_by_pattern", "macro_sql": "{% macro default__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8052301, "supported_languages": null}, "macro.dbt_utils.unpivot": {"name": "unpivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "unique_id": "macro.dbt_utils.unpivot", "macro_sql": "{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n {{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__unpivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8078556, "supported_languages": null}, "macro.dbt_utils.default__unpivot": {"name": "default__unpivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "unique_id": "macro.dbt_utils.default__unpivot", "macro_sql": "{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n\n {% if not relation %}\n {{ exceptions.raise_compiler_error(\"Error: argument `relation` is required for `unpivot` macro.\") }}\n {% endif %}\n\n {%- set exclude = exclude if exclude is not none else [] %}\n {%- set remove = remove if remove is not none else [] %}\n\n {%- set include_cols = [] %}\n\n {%- set table_columns = {} %}\n\n {%- do table_columns.update({relation: []}) %}\n\n {%- do dbt_utils._is_relation(relation, 'unpivot') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'unpivot') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) %}\n\n {%- for col in cols -%}\n {%- if col.column.lower() not in remove|map('lower') and col.column.lower() not in exclude|map('lower') -%}\n {% do include_cols.append(col) %}\n {%- endif %}\n {%- endfor %}\n\n\n {%- for col in include_cols -%}\n select\n {%- for exclude_col in exclude %}\n {{ exclude_col }},\n {%- endfor %}\n\n cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ field_name }},\n cast( {% if col.data_type == 'boolean' %}\n {{ dbt.cast_bool_to_text(col.column) }}\n {% else %}\n {{ col.column }}\n {% endif %}\n as {{ cast_to }}) as {{ value_name }}\n\n from {{ relation }}\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.type_string", "macro.dbt.cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.813203, "supported_languages": null}, "macro.dbt_utils.safe_add": {"name": "safe_add", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "unique_id": "macro.dbt_utils.safe_add", "macro_sql": "{%- macro safe_add(field_list) -%}\n {{ return(adapter.dispatch('safe_add', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_add"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8142872, "supported_languages": null}, "macro.dbt_utils.default__safe_add": {"name": "default__safe_add", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "unique_id": "macro.dbt_utils.default__safe_add", "macro_sql": "\n\n{%- macro default__safe_add(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_add` macro now takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.warn(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' +\\n ') }}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.816121, "supported_languages": null}, "macro.dbt_utils.test_not_null_proportion": {"name": "test_not_null_proportion", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_null_proportion.sql", "original_file_path": "macros/generic_tests/not_null_proportion.sql", "unique_id": "macro.dbt_utils.test_not_null_proportion", "macro_sql": "{% macro test_not_null_proportion(model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_null_proportion', 'dbt_utils')(model, group_by_columns, **kwargs)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_null_proportion"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8177807, "supported_languages": null}, "macro.dbt_utils.default__test_not_null_proportion": {"name": "default__test_not_null_proportion", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_null_proportion.sql", "original_file_path": "macros/generic_tests/not_null_proportion.sql", "unique_id": "macro.dbt_utils.default__test_not_null_proportion", "macro_sql": "{% macro default__test_not_null_proportion(model, group_by_columns) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n{% set at_least = kwargs.get('at_least', kwargs.get('arg')) %}\n{% set at_most = kwargs.get('at_most', kwargs.get('arg', 1)) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith validation as (\n select\n {{select_gb_cols}}\n sum(case when {{ column_name }} is null then 0 else 1 end) / cast(count(*) as numeric) as not_null_proportion\n from {{ model }}\n {{groupby_gb_cols}}\n),\nvalidation_errors as (\n select\n {{select_gb_cols}}\n not_null_proportion\n from validation\n where not_null_proportion < {{ at_least }} or not_null_proportion > {{ at_most }}\n)\nselect\n *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8205376, "supported_languages": null}, "macro.dbt_utils.test_mutually_exclusive_ranges": {"name": "test_mutually_exclusive_ranges", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", "unique_id": "macro.dbt_utils.test_mutually_exclusive_ranges", "macro_sql": "{% test mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n {{ return(adapter.dispatch('test_mutually_exclusive_ranges', 'dbt_utils')(model, lower_bound_column, upper_bound_column, partition_by, gaps, zero_length_range_allowed)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_mutually_exclusive_ranges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8266082, "supported_languages": null}, "macro.dbt_utils.default__test_mutually_exclusive_ranges": {"name": "default__test_mutually_exclusive_ranges", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", "unique_id": "macro.dbt_utils.default__test_mutually_exclusive_ranges", "macro_sql": "{% macro default__test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n{% if gaps == 'not_allowed' %}\n {% set allow_gaps_operator='=' %}\n {% set allow_gaps_operator_in_words='equal_to' %}\n{% elif gaps == 'allowed' %}\n {% set allow_gaps_operator='<=' %}\n {% set allow_gaps_operator_in_words='less_than_or_equal_to' %}\n{% elif gaps == 'required' %}\n {% set allow_gaps_operator='<' %}\n {% set allow_gaps_operator_in_words='less_than' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '\" ~ gaps ~\"'.'\"\n ) }}\n{% endif %}\n{% if not zero_length_range_allowed %}\n {% set allow_zero_length_operator='<' %}\n {% set allow_zero_length_operator_in_words='less_than' %}\n{% elif zero_length_range_allowed %}\n {% set allow_zero_length_operator='<=' %}\n {% set allow_zero_length_operator_in_words='less_than_or_equal_to' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`zero_length_range_allowed` argument for mutually_exclusive_ranges test must be one of [true, false] Got: '\" ~ zero_length_range_allowed ~\"'.'\"\n ) }}\n{% endif %}\n\n{% set partition_clause=\"partition by \" ~ partition_by if partition_by else '' %}\n\nwith window_functions as (\n\n select\n {% if partition_by %}\n {{ partition_by }} as partition_by_col,\n {% endif %}\n {{ lower_bound_column }} as lower_bound,\n {{ upper_bound_column }} as upper_bound,\n\n lead({{ lower_bound_column }}) over (\n {{ partition_clause }}\n order by {{ lower_bound_column }}, {{ upper_bound_column }}\n ) as next_lower_bound,\n\n row_number() over (\n {{ partition_clause }}\n order by {{ lower_bound_column }} desc, {{ upper_bound_column }} desc\n ) = 1 as is_last_record\n\n from {{ model }}\n\n),\n\ncalc as (\n -- We want to return records where one of our assumptions fails, so we'll use\n -- the `not` function with `and` statements so we can write our assumptions more cleanly\n select\n *,\n\n -- For each record: lower_bound should be < upper_bound.\n -- Coalesce it to return an error on the null case (implicit assumption\n -- these columns are not_null)\n coalesce(\n lower_bound {{ allow_zero_length_operator }} upper_bound,\n false\n ) as lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound,\n\n -- For each record: upper_bound {{ allow_gaps_operator }} the next lower_bound.\n -- Coalesce it to handle null cases for the last record.\n coalesce(\n upper_bound {{ allow_gaps_operator }} next_lower_bound,\n is_last_record,\n false\n ) as upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n\n from window_functions\n\n),\n\nvalidation_errors as (\n\n select\n *\n from calc\n\n where not(\n -- THE FOLLOWING SHOULD BE TRUE --\n lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound\n and upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n )\n)\n\nselect * from validation_errors\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8321385, "supported_languages": null}, "macro.dbt_utils.test_expression_is_true": {"name": "test_expression_is_true", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/expression_is_true.sql", "original_file_path": "macros/generic_tests/expression_is_true.sql", "unique_id": "macro.dbt_utils.test_expression_is_true", "macro_sql": "{% test expression_is_true(model, expression, column_name=None) %}\n {{ return(adapter.dispatch('test_expression_is_true', 'dbt_utils')(model, expression, column_name)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.833668, "supported_languages": null}, "macro.dbt_utils.default__test_expression_is_true": {"name": "default__test_expression_is_true", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/expression_is_true.sql", "original_file_path": "macros/generic_tests/expression_is_true.sql", "unique_id": "macro.dbt_utils.default__test_expression_is_true", "macro_sql": "{% macro default__test_expression_is_true(model, expression, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else \"1\" %}\n\nselect\n {{ column_list }}\nfrom {{ model }}\n{% if column_name is none %}\nwhere not({{ expression }})\n{%- else %}\nwhere not({{ column_name }} {{ expression }})\n{%- endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.834706, "supported_languages": null}, "macro.dbt_utils.test_recency": {"name": "test_recency", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/recency.sql", "original_file_path": "macros/generic_tests/recency.sql", "unique_id": "macro.dbt_utils.test_recency", "macro_sql": "{% test recency(model, field, datepart, interval, ignore_time_component=False, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_recency', 'dbt_utils')(model, field, datepart, interval, ignore_time_component, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_recency"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.836373, "supported_languages": null}, "macro.dbt_utils.default__test_recency": {"name": "default__test_recency", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/recency.sql", "original_file_path": "macros/generic_tests/recency.sql", "unique_id": "macro.dbt_utils.default__test_recency", "macro_sql": "{% macro default__test_recency(model, field, datepart, interval, ignore_time_component, group_by_columns) %}\n\n{% set threshold = 'cast(' ~ dbt.dateadd(datepart, interval * -1, dbt.current_timestamp()) ~ ' as ' ~ ('date' if ignore_time_component else dbt.type_timestamp()) ~ ')' %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nwith recency as (\n\n select \n\n {{ select_gb_cols }}\n {% if ignore_time_component %}\n cast(max({{ field }}) as date) as most_recent\n {%- else %}\n max({{ field }}) as most_recent\n {%- endif %}\n\n from {{ model }}\n\n {{ groupby_gb_cols }}\n\n)\n\nselect\n\n {{ select_gb_cols }}\n most_recent,\n {{ threshold }} as threshold\n\nfrom recency\nwhere most_recent < {{ threshold }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.current_timestamp", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8394396, "supported_languages": null}, "macro.dbt_utils.test_not_accepted_values": {"name": "test_not_accepted_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_accepted_values.sql", "original_file_path": "macros/generic_tests/not_accepted_values.sql", "unique_id": "macro.dbt_utils.test_not_accepted_values", "macro_sql": "{% test not_accepted_values(model, column_name, values, quote=True) %}\n {{ return(adapter.dispatch('test_not_accepted_values', 'dbt_utils')(model, column_name, values, quote)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8411312, "supported_languages": null}, "macro.dbt_utils.default__test_not_accepted_values": {"name": "default__test_not_accepted_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_accepted_values.sql", "original_file_path": "macros/generic_tests/not_accepted_values.sql", "unique_id": "macro.dbt_utils.default__test_not_accepted_values", "macro_sql": "{% macro default__test_not_accepted_values(model, column_name, values, quote=True) %}\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8425117, "supported_languages": null}, "macro.dbt_utils.test_cardinality_equality": {"name": "test_cardinality_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/cardinality_equality.sql", "original_file_path": "macros/generic_tests/cardinality_equality.sql", "unique_id": "macro.dbt_utils.test_cardinality_equality", "macro_sql": "{% test cardinality_equality(model, column_name, to, field) %}\n {{ return(adapter.dispatch('test_cardinality_equality', 'dbt_utils')(model, column_name, to, field)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_cardinality_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8441408, "supported_languages": null}, "macro.dbt_utils.default__test_cardinality_equality": {"name": "default__test_cardinality_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/cardinality_equality.sql", "original_file_path": "macros/generic_tests/cardinality_equality.sql", "unique_id": "macro.dbt_utils.default__test_cardinality_equality", "macro_sql": "{% macro default__test_cardinality_equality(model, column_name, to, field) %}\n\n{# T-SQL does not let you use numbers as aliases for columns #}\n{# Thus, no \"GROUP BY 1\" #}\n\nwith table_a as (\nselect\n {{ column_name }},\n count(*) as num_rows\nfrom {{ model }}\ngroup by {{ column_name }}\n),\n\ntable_b as (\nselect\n {{ field }},\n count(*) as num_rows\nfrom {{ to }}\ngroup by {{ field }}\n),\n\nexcept_a as (\n select *\n from table_a\n {{ dbt.except() }}\n select *\n from table_b\n),\n\nexcept_b as (\n select *\n from table_b\n {{ dbt.except() }}\n select *\n from table_a\n),\n\nunioned as (\n select *\n from except_a\n union all\n select *\n from except_b\n)\n\nselect *\nfrom unioned\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8451207, "supported_languages": null}, "macro.dbt_utils.test_at_least_one": {"name": "test_at_least_one", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/at_least_one.sql", "original_file_path": "macros/generic_tests/at_least_one.sql", "unique_id": "macro.dbt_utils.test_at_least_one", "macro_sql": "{% test at_least_one(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_at_least_one', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_at_least_one"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8466818, "supported_languages": null}, "macro.dbt_utils.default__test_at_least_one": {"name": "default__test_at_least_one", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/at_least_one.sql", "original_file_path": "macros/generic_tests/at_least_one.sql", "unique_id": "macro.dbt_utils.default__test_at_least_one", "macro_sql": "{% macro default__test_at_least_one(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nselect *\nfrom (\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count({{ column_name }}) as filler_column\n\n from {{ model }}\n\n {{groupby_gb_cols}}\n\n having count({{ column_name }}) = 0\n\n) validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8484728, "supported_languages": null}, "macro.dbt_utils.test_unique_combination_of_columns": {"name": "test_unique_combination_of_columns", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/unique_combination_of_columns.sql", "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", "unique_id": "macro.dbt_utils.test_unique_combination_of_columns", "macro_sql": "{% test unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n {{ return(adapter.dispatch('test_unique_combination_of_columns', 'dbt_utils')(model, combination_of_columns, quote_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_unique_combination_of_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.850366, "supported_languages": null}, "macro.dbt_utils.default__test_unique_combination_of_columns": {"name": "default__test_unique_combination_of_columns", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/unique_combination_of_columns.sql", "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", "unique_id": "macro.dbt_utils.default__test_unique_combination_of_columns", "macro_sql": "{% macro default__test_unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n\n{% if not quote_columns %}\n {%- set column_list=combination_of_columns %}\n{% elif quote_columns %}\n {%- set column_list=[] %}\n {% for column in combination_of_columns -%}\n {% set column_list = column_list.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set columns_csv=column_list | join(', ') %}\n\n\nwith validation_errors as (\n\n select\n {{ columns_csv }}\n from {{ model }}\n group by {{ columns_csv }}\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.853139, "supported_languages": null}, "macro.dbt_utils.test_accepted_range": {"name": "test_accepted_range", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/accepted_range.sql", "original_file_path": "macros/generic_tests/accepted_range.sql", "unique_id": "macro.dbt_utils.test_accepted_range", "macro_sql": "{% test accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n {{ return(adapter.dispatch('test_accepted_range', 'dbt_utils')(model, column_name, min_value, max_value, inclusive)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_accepted_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.855082, "supported_languages": null}, "macro.dbt_utils.default__test_accepted_range": {"name": "default__test_accepted_range", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/accepted_range.sql", "original_file_path": "macros/generic_tests/accepted_range.sql", "unique_id": "macro.dbt_utils.default__test_accepted_range", "macro_sql": "{% macro default__test_accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n\nwith meet_condition as(\n select *\n from {{ model }}\n),\n\nvalidation_errors as (\n select *\n from meet_condition\n where\n -- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds\n 1 = 2\n\n {%- if min_value is not none %}\n -- records with a value >= min_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} > {{- \"=\" if inclusive }} {{ min_value }}\n {%- endif %}\n\n {%- if max_value is not none %}\n -- records with a value <= max_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} < {{- \"=\" if inclusive }} {{ max_value }}\n {%- endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8569262, "supported_languages": null}, "macro.dbt_utils.test_equality": {"name": "test_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equality.sql", "original_file_path": "macros/generic_tests/equality.sql", "unique_id": "macro.dbt_utils.test_equality", "macro_sql": "{% test equality(model, compare_model, compare_columns=None) %}\n {{ return(adapter.dispatch('test_equality', 'dbt_utils')(model, compare_model, compare_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8592806, "supported_languages": null}, "macro.dbt_utils.default__test_equality": {"name": "default__test_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equality.sql", "original_file_path": "macros/generic_tests/equality.sql", "unique_id": "macro.dbt_utils.default__test_equality", "macro_sql": "{% macro default__test_equality(model, compare_model, compare_columns=None) %}\n\n{% set set_diff %}\n count(*) + coalesce(abs(\n sum(case when which_diff = 'a_minus_b' then 1 else 0 end) -\n sum(case when which_diff = 'b_minus_a' then 1 else 0 end)\n ), 0)\n{% endset %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = set_diff) }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n-- setup\n{%- do dbt_utils._is_relation(model, 'test_equality') -%}\n\n{#-\nIf the compare_cols arg is provided, we can run this test without querying the\ninformation schema\u00a0\u2014 this allows the model to be an ephemeral model\n-#}\n\n{%- if not compare_columns -%}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%}\n{%- endif -%}\n\n{% set compare_cols_csv = compare_columns | join(', ') %}\n\nwith a as (\n\n select * from {{ model }}\n\n),\n\nb as (\n\n select * from {{ compare_model }}\n\n),\n\na_minus_b as (\n\n select {{compare_cols_csv}} from a\n {{ dbt.except() }}\n select {{compare_cols_csv}} from b\n\n),\n\nb_minus_a as (\n\n select {{compare_cols_csv}} from b\n {{ dbt.except() }}\n select {{compare_cols_csv}} from a\n\n),\n\nunioned as (\n\n select 'a_minus_b' as which_diff, a_minus_b.* from a_minus_b\n union all\n select 'b_minus_a' as which_diff, b_minus_a.* from b_minus_a\n\n)\n\nselect * from unioned\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.862718, "supported_languages": null}, "macro.dbt_utils.test_not_empty_string": {"name": "test_not_empty_string", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_empty_string.sql", "original_file_path": "macros/generic_tests/not_empty_string.sql", "unique_id": "macro.dbt_utils.test_not_empty_string", "macro_sql": "{% test not_empty_string(model, column_name, trim_whitespace=true) %}\n\n {{ return(adapter.dispatch('test_not_empty_string', 'dbt_utils')(model, column_name, trim_whitespace)) }}\n\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_empty_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8643706, "supported_languages": null}, "macro.dbt_utils.default__test_not_empty_string": {"name": "default__test_not_empty_string", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_empty_string.sql", "original_file_path": "macros/generic_tests/not_empty_string.sql", "unique_id": "macro.dbt_utils.default__test_not_empty_string", "macro_sql": "{% macro default__test_not_empty_string(model, column_name, trim_whitespace=true) %}\n\n with\n \n all_values as (\n\n select \n\n\n {% if trim_whitespace == true -%}\n\n trim({{ column_name }}) as {{ column_name }}\n\n {%- else -%}\n\n {{ column_name }}\n\n {%- endif %}\n \n from {{ model }}\n\n ),\n\n errors as (\n\n select * from all_values\n where {{ column_name }} = ''\n\n )\n\n select * from errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.865537, "supported_languages": null}, "macro.dbt_utils.test_relationships_where": {"name": "test_relationships_where", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/relationships_where.sql", "original_file_path": "macros/generic_tests/relationships_where.sql", "unique_id": "macro.dbt_utils.test_relationships_where", "macro_sql": "{% test relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n {{ return(adapter.dispatch('test_relationships_where', 'dbt_utils')(model, column_name, to, field, from_condition, to_condition)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_relationships_where"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8675516, "supported_languages": null}, "macro.dbt_utils.default__test_relationships_where": {"name": "default__test_relationships_where", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/relationships_where.sql", "original_file_path": "macros/generic_tests/relationships_where.sql", "unique_id": "macro.dbt_utils.default__test_relationships_where", "macro_sql": "{% macro default__test_relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n\nwith left_table as (\n\n select\n {{column_name}} as id\n\n from {{model}}\n\n where {{column_name}} is not null\n and {{from_condition}}\n\n),\n\nright_table as (\n\n select\n {{field}} as id\n\n from {{to}}\n\n where {{field}} is not null\n and {{to_condition}}\n\n),\n\nexceptions as (\n\n select\n left_table.id,\n right_table.id as right_id\n\n from left_table\n\n left join right_table\n on left_table.id = right_table.id\n\n where right_table.id is null\n\n)\n\nselect * from exceptions\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8688958, "supported_languages": null}, "macro.dbt_utils.test_sequential_values": {"name": "test_sequential_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/sequential_values.sql", "original_file_path": "macros/generic_tests/sequential_values.sql", "unique_id": "macro.dbt_utils.test_sequential_values", "macro_sql": "{% test sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n {{ return(adapter.dispatch('test_sequential_values', 'dbt_utils')(model, column_name, interval, datepart, group_by_columns)) }}\n\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_sequential_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8712804, "supported_languages": null}, "macro.dbt_utils.default__test_sequential_values": {"name": "default__test_sequential_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/sequential_values.sql", "original_file_path": "macros/generic_tests/sequential_values.sql", "unique_id": "macro.dbt_utils.default__test_sequential_values", "macro_sql": "{% macro default__test_sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n{% set previous_column_name = \"previous_\" ~ dbt_utils.slugify(column_name) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(',') + ', ' %}\n {% set partition_gb_cols = 'partition by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith windowed as (\n\n select\n {{ select_gb_cols }}\n {{ column_name }},\n lag({{ column_name }}) over (\n {{partition_gb_cols}}\n order by {{ column_name }}\n ) as {{ previous_column_name }}\n from {{ model }}\n),\n\nvalidation_errors as (\n select\n *\n from windowed\n {% if datepart %}\n where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, previous_column_name) }} as {{ dbt.type_timestamp() }}))\n {% else %}\n where not({{ column_name }} = {{ previous_column_name }} + {{ interval }})\n {% endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.slugify", "macro.dbt.type_timestamp", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8741727, "supported_languages": null}, "macro.dbt_utils.test_not_constant": {"name": "test_not_constant", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_constant.sql", "original_file_path": "macros/generic_tests/not_constant.sql", "unique_id": "macro.dbt_utils.test_not_constant", "macro_sql": "{% test not_constant(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_constant', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_constant"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8754454, "supported_languages": null}, "macro.dbt_utils.default__test_not_constant": {"name": "default__test_not_constant", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_constant.sql", "original_file_path": "macros/generic_tests/not_constant.sql", "unique_id": "macro.dbt_utils.default__test_not_constant", "macro_sql": "{% macro default__test_not_constant(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nselect\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count(distinct {{ column_name }}) as filler_column\n\nfrom {{ model }}\n\n {{groupby_gb_cols}}\n\nhaving count(distinct {{ column_name }}) = 1\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8769164, "supported_languages": null}, "macro.dbt_utils.test_equal_rowcount": {"name": "test_equal_rowcount", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equal_rowcount.sql", "original_file_path": "macros/generic_tests/equal_rowcount.sql", "unique_id": "macro.dbt_utils.test_equal_rowcount", "macro_sql": "{% test equal_rowcount(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_equal_rowcount', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_equal_rowcount"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.879138, "supported_languages": null}, "macro.dbt_utils.default__test_equal_rowcount": {"name": "default__test_equal_rowcount", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equal_rowcount.sql", "original_file_path": "macros/generic_tests/equal_rowcount.sql", "unique_id": "macro.dbt_utils.default__test_equal_rowcount", "macro_sql": "{% macro default__test_equal_rowcount(model, compare_model, group_by_columns) %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(', ') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in fewer_rows_than. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_equal_rowcount'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_a \n from {{ model }}\n {{groupby_gb_cols}}\n\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_b \n from {{ compare_model }}\n {{groupby_gb_cols}}\n\n),\nfinal as (\n\n select\n \n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_a,\n count_b,\n abs(count_a - count_b) as diff_count\n\n from a\n full join b\n on\n a.id_dbtutils_test_equal_rowcount = b.id_dbtutils_test_equal_rowcount\n {{join_gb_cols}}\n\n\n)\n\nselect * from final\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8825464, "supported_languages": null}, "macro.dbt_utils.test_fewer_rows_than": {"name": "test_fewer_rows_than", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/fewer_rows_than.sql", "original_file_path": "macros/generic_tests/fewer_rows_than.sql", "unique_id": "macro.dbt_utils.test_fewer_rows_than", "macro_sql": "{% test fewer_rows_than(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_fewer_rows_than', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_fewer_rows_than"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8851564, "supported_languages": null}, "macro.dbt_utils.default__test_fewer_rows_than": {"name": "default__test_fewer_rows_than", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/fewer_rows_than.sql", "original_file_path": "macros/generic_tests/fewer_rows_than.sql", "unique_id": "macro.dbt_utils.default__test_fewer_rows_than", "macro_sql": "{% macro default__test_fewer_rows_than(model, compare_model, group_by_columns) %}\n\n{{ config(fail_calc = 'sum(coalesce(row_count_delta, 0))') }}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in equal_rowcount. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_fewer_rows_than'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_our_model \n from {{ model }}\n {{ groupby_gb_cols }}\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_comparison_model \n from {{ compare_model }}\n {{ groupby_gb_cols }}\n\n),\ncounts as (\n\n select\n\n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_our_model,\n count_comparison_model\n from a\n full join b on \n a.id_dbtutils_test_fewer_rows_than = b.id_dbtutils_test_fewer_rows_than\n {{ join_gb_cols }}\n\n),\nfinal as (\n\n select *,\n case\n -- fail the test if we have more rows than the reference model and return the row count delta\n when count_our_model > count_comparison_model then (count_our_model - count_comparison_model)\n -- fail the test if they are the same number\n when count_our_model = count_comparison_model then 1\n -- pass the test if the delta is positive (i.e. return the number 0)\n else 0\n end as row_count_delta\n from counts\n\n)\n\nselect * from final\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1705094500.8883965, "supported_languages": null}}, "docs": {"doc.dbt.__overview__": {"name": "__overview__", "resource_type": "doc", "package_name": "dbt", "path": "overview.md", "original_file_path": "docs/overview.md", "unique_id": "doc.dbt.__overview__", "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion"}}, "exposures": {}, "metrics": {}, "groups": {}, "selectors": {}, "disabled": {}, "parent_map": {"model.aspects.dim_course_blocks": ["source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names"], "model.aspects.xapi_events_all_parsed": ["source.aspects.xapi.xapi_events_all"], "model.aspects.forum_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_forum_interactions": ["model.aspects.forum_events", "source.aspects.event_sink.course_names"], "model.aspects.fact_grades": ["model.aspects.grading_events", "source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names"], "model.aspects.grading_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_video_plays": ["model.aspects.dim_course_blocks", "model.aspects.video_playback_events"], "model.aspects.video_transcript_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_transcript_usage": ["model.aspects.dim_course_blocks", "model.aspects.video_transcript_events"], "model.aspects.video_playback_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_problem_responses": ["model.aspects.dim_course_blocks", "model.aspects.problem_events"], "model.aspects.int_problem_hints": ["model.aspects.dim_course_blocks", "model.aspects.problem_events"], "model.aspects.problem_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_learner_problem_summary": ["model.aspects.int_problem_hints", "model.aspects.int_problem_results"], "model.aspects.int_problem_results": ["model.aspects.fact_problem_responses"], "model.aspects.fact_enrollments": ["model.aspects.enrollment_events", "source.aspects.event_sink.course_names"], "model.aspects.enrollment_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_navigation": ["model.aspects.dim_course_blocks", "model.aspects.navigation_events"], "model.aspects.navigation_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_completions": ["model.aspects.completion_events", "source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names"], "model.aspects.completion_events": ["model.aspects.xapi_events_all_parsed"], "test.aspects.learner_problem_summary_uniqueness": ["model.aspects.fact_learner_problem_summary"], "test.aspects.problem_results_uniqueness": ["model.aspects.int_problem_results"], "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f": ["model.aspects.fact_grades"], "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da": ["model.aspects.fact_learner_problem_summary"], "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b": ["model.aspects.fact_learner_problem_summary"], "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4": ["model.aspects.fact_enrollments"], "source.aspects.xapi.xapi_events_all": [], "source.aspects.event_sink.course_block_names": [], "source.aspects.event_sink.course_names": []}, "child_map": {"model.aspects.dim_course_blocks": ["model.aspects.fact_navigation", "model.aspects.fact_problem_responses", "model.aspects.fact_transcript_usage", "model.aspects.fact_video_plays", "model.aspects.int_problem_hints"], "model.aspects.xapi_events_all_parsed": ["model.aspects.completion_events", "model.aspects.enrollment_events", "model.aspects.forum_events", "model.aspects.grading_events", "model.aspects.navigation_events", "model.aspects.problem_events", "model.aspects.video_playback_events", "model.aspects.video_transcript_events"], "model.aspects.forum_events": ["model.aspects.fact_forum_interactions"], "model.aspects.fact_forum_interactions": [], "model.aspects.fact_grades": ["test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f"], "model.aspects.grading_events": ["model.aspects.fact_grades"], "model.aspects.fact_video_plays": [], "model.aspects.video_transcript_events": ["model.aspects.fact_transcript_usage"], "model.aspects.fact_transcript_usage": [], "model.aspects.video_playback_events": ["model.aspects.fact_video_plays"], "model.aspects.fact_problem_responses": ["model.aspects.int_problem_results"], "model.aspects.int_problem_hints": ["model.aspects.fact_learner_problem_summary"], "model.aspects.problem_events": ["model.aspects.fact_problem_responses", "model.aspects.int_problem_hints"], "model.aspects.fact_learner_problem_summary": ["test.aspects.learner_problem_summary_uniqueness", "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b", "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da"], "model.aspects.int_problem_results": ["model.aspects.fact_learner_problem_summary", "test.aspects.problem_results_uniqueness"], "model.aspects.fact_enrollments": ["test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4"], "model.aspects.enrollment_events": ["model.aspects.fact_enrollments"], "model.aspects.fact_navigation": [], "model.aspects.navigation_events": ["model.aspects.fact_navigation"], "model.aspects.fact_completions": [], "model.aspects.completion_events": ["model.aspects.fact_completions"], "test.aspects.learner_problem_summary_uniqueness": [], "test.aspects.problem_results_uniqueness": [], "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f": [], "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da": [], "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b": [], "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4": [], "source.aspects.xapi.xapi_events_all": ["model.aspects.xapi_events_all_parsed"], "source.aspects.event_sink.course_block_names": ["model.aspects.dim_course_blocks", "model.aspects.fact_completions", "model.aspects.fact_grades"], "source.aspects.event_sink.course_names": ["model.aspects.dim_course_blocks", "model.aspects.fact_completions", "model.aspects.fact_enrollments", "model.aspects.fact_forum_interactions", "model.aspects.fact_grades"]}, "group_map": {}, "saved_queries": {}, "semantic_models": {}} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v11.json", "dbt_version": "1.7.0", "generated_at": "2024-01-29T17:33:02.991961Z", "invocation_id": "23109c69-1db3-40c3-b53f-036608b155d3", "env": {}, "project_name": "aspects", "project_id": "9074d4992d118978696669561f06dfcc", "user_id": "4f69d9cd-192f-48bd-ae43-3801313a8e0b", "send_anonymous_usage_stats": true, "adapter_type": "clickhouse"}, "nodes": {"model.aspects.enrollment_events": {"database": "", "schema": "xapi", "name": "enrollment_events", "resource_type": "model", "package_name": "aspects", "path": "enrollment/enrollment_events.sql", "original_file_path": "models/enrollment/enrollment_events.sql", "unique_id": "model.aspects.enrollment_events", "fqn": ["aspects", "enrollment", "enrollment_events"], "alias": "enrollment_events", "checksum": {"name": "sha256", "checksum": "f220df242d47ad3a43273adda9ae7d19c10eb18ab120cc841c1a895e3eb510bc"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, emission_time, actor_id, enrollment_mode, event_id)", "primary_key": "(org, course_key)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key)", "order_by": "(org, course_key, emission_time, actor_id, enrollment_mode, event_id)"}, "created_at": 1706549584.4673948, "relation_name": "`xapi`.`enrollment_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key)',\n order_by='(org, course_key, emission_time, actor_id, enrollment_mode, event_id)'\n ) }}\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.object.definition.extensions.\"https://w3id.org/xapi/acrossx/extensions/type\"') AS enrollment_mode\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE verb_id IN (\n 'http://adlnet.gov/expapi/verbs/registered',\n 'http://id.tincanapi.com/verb/unregistered'\n)", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/enrollment/enrollment_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.object.definition.extensions.\"https://w3id.org/xapi/acrossx/extensions/type\"') AS enrollment_mode\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN (\n 'http://adlnet.gov/expapi/verbs/registered',\n 'http://id.tincanapi.com/verb/unregistered'\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_enrollments": {"database": "", "schema": "xapi", "name": "fact_enrollments", "resource_type": "model", "package_name": "aspects", "path": "enrollment/fact_enrollments.sql", "original_file_path": "models/enrollment/fact_enrollments.sql", "unique_id": "model.aspects.fact_enrollments", "fqn": ["aspects", "enrollment", "fact_enrollments"], "alias": "fact_enrollments", "checksum": {"name": "sha256", "checksum": "9b892578d56e433cab6a0206b773cf5d32c6787b76401c0f2bb1029a551e7217"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "A record for each enrollment event", "columns": {"emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "DateTime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "enrollment_mode": {"name": "enrollment_mode", "description": "", "meta": {}, "data_type": "LowCardinality(String)", "constraints": [], "quote": null, "tags": []}, "enrollment_status": {"name": "enrollment_status", "description": "Whether a learner is actively enrolled in a course", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/enrollment/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {"materialized": "view"}, "created_at": 1706549584.7683928, "relation_name": "`xapi`.`fact_enrollments`", "raw_code": "with enrollments as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n enrollment_mode,\n splitByString('/', verb_id)[-1] as enrollment_status\n from\n {{ ref('enrollment_events') }}\n)\n\nselect\n enrollments.emission_time as emission_time,\n enrollments.org as org,\n enrollments.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n enrollments.actor_id as actor_id,\n enrollments.enrollment_mode as enrollment_mode,\n enrollments.enrollment_status as enrollment_status\nfrom\n enrollments\n join {{ source('event_sink', 'course_names')}} courses\n on enrollments.course_key = courses.course_key", "language": "sql", "refs": [{"name": "enrollment_events", "package": null, "version": null}], "sources": [["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_names", "model.aspects.enrollment_events"]}, "compiled_path": "target/compiled/aspects/models/enrollment/fact_enrollments.sql", "compiled": true, "compiled_code": "with enrollments as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n enrollment_mode,\n splitByString('/', verb_id)[-1] as enrollment_status\n from\n `xapi`.`enrollment_events`\n)\n\nselect\n enrollments.emission_time as emission_time,\n enrollments.org as org,\n enrollments.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n enrollments.actor_id as actor_id,\n enrollments.enrollment_mode as enrollment_mode,\n enrollments.enrollment_status as enrollment_status\nfrom\n enrollments\n join `event_sink`.`course_names` courses\n on enrollments.course_key = courses.course_key", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.xapi_events_all_parsed": {"database": "", "schema": "xapi", "name": "xapi_events_all_parsed", "resource_type": "model", "package_name": "aspects", "path": "base/xapi_events_all_parsed.sql", "original_file_path": "models/base/xapi_events_all_parsed.sql", "unique_id": "model.aspects.xapi_events_all_parsed", "fqn": ["aspects", "base", "xapi_events_all_parsed"], "alias": "xapi_events_all_parsed", "checksum": {"name": "sha256", "checksum": "bc75f27652fca5fe6b09326e5cbcd26094962794d08bbe451b4661383dc717ef"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [{"sql": "OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL", "transaction": true, "index": null}], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_id, verb_id, actor_id, emission_time, event_id)", "primary_key": "(org, course_id, verb_id, actor_id, emission_time, event_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_id, verb_id, actor_id, emission_time, event_id)", "order_by": "(org, course_id, verb_id, actor_id, emission_time, event_id)", "post-hook": ["OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL"]}, "created_at": 1706549584.492997, "relation_name": "`xapi`.`xapi_events_all_parsed`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_id, verb_id, actor_id, emission_time, event_id)',\n order_by='(org, course_id, verb_id, actor_id, emission_time, event_id)',\n post_hook='OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL'\n ) }}\n\nSELECT\n event_id as event_id,\n JSON_VALUE(event::String, '$.verb.id') as verb_id,\n COALESCE(\n NULLIF(JSON_VALUE(event::String, '$.actor.account.name'), ''),\n NULLIF(JSON_VALUE(event::String, '$.actor.mbox'), ''),\n JSON_VALUE(event::String, '$.actor.mbox_sha1sum')\n ) as actor_id,\n JSON_VALUE(event::String, '$.object.id') as object_id,\n -- If the contextActivities parent is a course, use that. It can be a \"course\"\n -- type, or a \"cmi.interaction\" type for multiple question problem submissions.\n -- Otherwise use the object id for the course id.\n multiIf(\n -- If the contextActivities parent is a course, use that\n JSON_VALUE(\n event::String,\n '$.context.contextActivities.parent[0].definition.type'\n ) = 'http://adlnet.gov/expapi/activities/course',\n JSON_VALUE(event::String, '$.context.contextActivities.parent[0].id'),\n -- Else if the contextActivities parent is a GroupActivity, it's a multi\n -- question problem and we use the grouping id\n JSON_VALUE(\n event::String,\n '$.context.contextActivities.parent[0].objectType'\n ) in ('Activity', 'GroupActivity'),\n JSON_VALUE(event::String, '$.context.contextActivities.grouping[0].id'),\n -- Otherwise use the object id\n JSON_VALUE(event::String, '$.object.id')\n ) as course_id,\n coalesce(get_org_from_course_url(course_id), '') as org,\n emission_time as emission_time,\n event::String as event\nFROM {{ source('xapi', 'xapi_events_all') }}", "language": "sql", "refs": [], "sources": [["xapi", "xapi_events_all"]], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine", "macro.aspects.on_cluster"], "nodes": ["source.aspects.xapi.xapi_events_all"]}, "compiled_path": "target/compiled/aspects/models/base/xapi_events_all_parsed.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id as event_id,\n JSON_VALUE(event::String, '$.verb.id') as verb_id,\n COALESCE(\n NULLIF(JSON_VALUE(event::String, '$.actor.account.name'), ''),\n NULLIF(JSON_VALUE(event::String, '$.actor.mbox'), ''),\n JSON_VALUE(event::String, '$.actor.mbox_sha1sum')\n ) as actor_id,\n JSON_VALUE(event::String, '$.object.id') as object_id,\n -- If the contextActivities parent is a course, use that. It can be a \"course\"\n -- type, or a \"cmi.interaction\" type for multiple question problem submissions.\n -- Otherwise use the object id for the course id.\n multiIf(\n -- If the contextActivities parent is a course, use that\n JSON_VALUE(\n event::String,\n '$.context.contextActivities.parent[0].definition.type'\n ) = 'http://adlnet.gov/expapi/activities/course',\n JSON_VALUE(event::String, '$.context.contextActivities.parent[0].id'),\n -- Else if the contextActivities parent is a GroupActivity, it's a multi\n -- question problem and we use the grouping id\n JSON_VALUE(\n event::String,\n '$.context.contextActivities.parent[0].objectType'\n ) in ('Activity', 'GroupActivity'),\n JSON_VALUE(event::String, '$.context.contextActivities.grouping[0].id'),\n -- Otherwise use the object id\n JSON_VALUE(event::String, '$.object.id')\n ) as course_id,\n coalesce(get_org_from_course_url(course_id), '') as org,\n emission_time as emission_time,\n event::String as event\nFROM `xapi`.`xapi_events_all`", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.dim_course_blocks": {"database": "", "schema": "xapi", "name": "dim_course_blocks", "resource_type": "model", "package_name": "aspects", "path": "base/dim_course_blocks.sql", "original_file_path": "models/base/dim_course_blocks.sql", "unique_id": "model.aspects.dim_course_blocks", "fqn": ["aspects", "base", "dim_course_blocks"], "alias": "dim_course_blocks", "checksum": {"name": "sha256", "checksum": "82ae5386fcd742cd5b4a90c135161d8c0fb8ca5577e0689ca229d7869d5d047c"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "A denormalized table of course block information", "columns": {"org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "block_id": {"name": "block_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "block_name": {"name": "block_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "display_name_with_location": {"name": "display_name_with_location", "description": "The block's display name with section, subsection, and unit prepended to the name. This provides additional context when looking at block names and can help data consumers understand which block they are analyzing", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/base/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.923969, "relation_name": "`xapi`.`dim_course_blocks`", "raw_code": "select\n courses.org as org,\n courses.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n blocks.location as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as display_name_with_location\nfrom\n {{ source('event_sink', 'course_block_names') }} blocks\n join {{ source('event_sink', 'course_names')}} courses\n on blocks.course_key = courses.course_key\nsettings join_algorithm='direct'", "language": "sql", "refs": [], "sources": [["event_sink", "course_block_names"], ["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names"]}, "compiled_path": "target/compiled/aspects/models/base/dim_course_blocks.sql", "compiled": true, "compiled_code": "select\n courses.org as org,\n courses.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n blocks.location as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as display_name_with_location\nfrom\n `event_sink`.`course_block_names` blocks\n join `event_sink`.`course_names` courses\n on blocks.course_key = courses.course_key\nsettings join_algorithm='direct'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.navigation_events": {"database": "", "schema": "xapi", "name": "navigation_events", "resource_type": "model", "package_name": "aspects", "path": "navigation/navigation_events.sql", "original_file_path": "models/navigation/navigation_events.sql", "unique_id": "model.aspects.navigation_events", "fqn": ["aspects", "navigation", "navigation_events"], "alias": "navigation_events", "checksum": {"name": "sha256", "checksum": "07c1ee6c6339059591d94374af07063c74550ec1a68d84067b1cac8e3728522d"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, object_type, emission_time, actor_id, starting_position, event_id)", "primary_key": "(org, course_key, object_type)"}, "tags": [], "description": "A materialized view for xAPI events related to course navigation", "columns": {"event_id": {"name": "event_id", "description": "", "meta": {}, "data_type": "uuid", "constraints": [], "quote": null, "tags": []}, "emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "datetime", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "block_id": {"name": "block_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "verb_id": {"name": "verb_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "object_type": {"name": "object_type", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "starting_position": {"name": "starting_position", "description": "The tab in the unit navigation bar that the learner was viewing before clicking a link", "meta": {}, "data_type": "int64", "constraints": [], "quote": null, "tags": []}, "ending_point": {"name": "ending_point", "description": "The tab in the unit navigation bar that the learner selected to navigate to", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/navigation/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, object_type)", "order_by": "(org, course_key, object_type, emission_time, actor_id, starting_position, event_id)"}, "created_at": 1706549584.9277332, "relation_name": "`xapi`.`navigation_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, object_type)',\n order_by='(org, course_key, object_type, emission_time, actor_id, starting_position, event_id)'\n ) }}\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n splitByString('/xblock/', object_id)[-1] as block_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractString(event, 'object', 'definition', 'type') AS object_type,\n -- clicking a link and selecting a module outline have no starting-position field\n if (\n object_type in (\n 'http://adlnet.gov/expapi/activities/link',\n 'http://adlnet.gov/expapi/activities/module'\n ),\n 0,\n JSONExtractInt(\n event,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/starting-position'\n )\n ) AS starting_position,\n JSONExtractString(\n event,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/ending-point'\n ) AS ending_point\nFROM\n {{ ref('xapi_events_all_parsed') }}\nWHERE verb_id IN (\n 'https://w3id.org/xapi/dod-isd/verbs/navigated'\n)", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/navigation/navigation_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n splitByString('/xblock/', object_id)[-1] as block_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractString(event, 'object', 'definition', 'type') AS object_type,\n -- clicking a link and selecting a module outline have no starting-position field\n if (\n object_type in (\n 'http://adlnet.gov/expapi/activities/link',\n 'http://adlnet.gov/expapi/activities/module'\n ),\n 0,\n JSONExtractInt(\n event,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/starting-position'\n )\n ) AS starting_position,\n JSONExtractString(\n event,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/ending-point'\n ) AS ending_point\nFROM\n `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN (\n 'https://w3id.org/xapi/dod-isd/verbs/navigated'\n)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_navigation": {"database": "", "schema": "xapi", "name": "fact_navigation", "resource_type": "model", "package_name": "aspects", "path": "navigation/fact_navigation.sql", "original_file_path": "models/navigation/fact_navigation.sql", "unique_id": "model.aspects.fact_navigation", "fqn": ["aspects", "navigation", "fact_navigation"], "alias": "fact_navigation", "checksum": {"name": "sha256", "checksum": "3e0c52c42cac487e47832f166410ceea1c8253ef99357cd1f3e3de372248d87d"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "A view of navigation_events enriched with course and block metadata", "columns": {"emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "datetime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "block_id": {"name": "block_id", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "block_name": {"name": "block_name", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "block_name_with_location": {"name": "block_name_with_location", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "object_type": {"name": "object_type", "description": "", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}, "starting_position": {"name": "starting_position", "description": "The tab in the unit navigation bar that the learner was viewing before clicking a link", "meta": {}, "data_type": "int64", "constraints": [], "quote": null, "tags": []}, "ending_point": {"name": "ending_point", "description": "The tab in the unit navigation bar that the learner selected to navigate to", "meta": {}, "data_type": "string", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/navigation/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9291945, "relation_name": "`xapi`.`fact_navigation`", "raw_code": "select\n navigation.emission_time as emission_time,\n navigation.org as org,\n navigation.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n navigation.actor_id as actor_id,\n navigation.block_id as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as block_name_with_location,\n navigation.object_type as object_type,\n navigation.starting_position as starting_position,\n navigation.ending_point as ending_point\nfrom\n {{ ref('navigation_events') }} navigation\n join {{ ref('dim_course_blocks') }} blocks\n on (navigation.course_key = blocks.course_key\n and navigation.block_id = blocks.block_id)", "language": "sql", "refs": [{"name": "navigation_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.navigation_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/navigation/fact_navigation.sql", "compiled": true, "compiled_code": "select\n navigation.emission_time as emission_time,\n navigation.org as org,\n navigation.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n navigation.actor_id as actor_id,\n navigation.block_id as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as block_name_with_location,\n navigation.object_type as object_type,\n navigation.starting_position as starting_position,\n navigation.ending_point as ending_point\nfrom\n `xapi`.`navigation_events` navigation\n join `xapi`.`dim_course_blocks` blocks\n on (navigation.course_key = blocks.course_key\n and navigation.block_id = blocks.block_id)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.completion_events": {"database": "", "schema": "xapi", "name": "completion_events", "resource_type": "model", "package_name": "aspects", "path": "completion/completion_events.sql", "original_file_path": "models/completion/completion_events.sql", "unique_id": "model.aspects.completion_events", "fqn": ["aspects", "completion", "completion_events"], "alias": "completion_events", "checksum": {"name": "sha256", "checksum": "857872d68f6b9149a87a6f46fd9a6bcb023c67c4def38e49ea9fe826ccdb79ca"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)"}, "created_at": 1706549584.5139112, "relation_name": "`xapi`.`completion_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)'\n ) }}\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/cmi5/result/extensions/progress\"') AS progress_percent\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE verb_id = 'http://adlnet.gov/expapi/verbs/progressed'", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/completion/completion_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/cmi5/result/extensions/progress\"') AS progress_percent\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id = 'http://adlnet.gov/expapi/verbs/progressed'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_completions": {"database": "", "schema": "xapi", "name": "fact_completions", "resource_type": "model", "package_name": "aspects", "path": "completion/fact_completions.sql", "original_file_path": "models/completion/fact_completions.sql", "unique_id": "model.aspects.fact_completions", "fqn": ["aspects", "completion", "fact_completions"], "alias": "fact_completions", "checksum": {"name": "sha256", "checksum": "e6a57f59728805c8e854fa05615b69fb3ebd0b4d1531b3441bfe5cf2dcd75627"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record per completion events for component", "columns": {"emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "DateTime64(3)", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_id": {"name": "entity_id", "description": "The block ID or course key for the graded entity", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_name": {"name": "entity_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_name_with_location": {"name": "entity_name_with_location", "description": "", "meta": {}, "data_type": "Nullable(String)", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "scaled_progress": {"name": "scaled_progress", "description": "A ratio between 0 and 1, inclusive, of the learner's progress", "meta": {}, "data_type": "Float32", "constraints": [], "quote": null, "tags": []}, "completion_bucket": {"name": "completion_bucket", "description": "A displayable value of progress sorted into 10% buckets. Useful for grouping progress together to show high-level learner performance", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/completion/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9342628, "relation_name": "`xapi`.`fact_completions`", "raw_code": "with completions as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n progress_percent,\n if(\n object_id like '%/course/%',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n cast(progress_percent as Float)/100 as scaled_progress\n from\n {{ ref('completion_events') }}\n)\n\nselect\n completions.emission_time as emission_time,\n completions.org as org,\n completions.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n completions.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n completions.actor_id as actor_id,\n cast(completions.scaled_progress as Float) as scaled_progress,\n case\n when scaled_progress >= 0.9 then '90-100%'\n when scaled_progress >= 0.8 and scaled_progress < 0.9 then '80-89%'\n when scaled_progress >= 0.7 and scaled_progress < 0.8 then '70-79%'\n when scaled_progress >= 0.6 and scaled_progress < 0.7 then '60-69%'\n when scaled_progress >= 0.5 and scaled_progress < 0.6 then '50-59%'\n when scaled_progress >= 0.4 and scaled_progress < 0.5 then '40-49%'\n when scaled_progress >= 0.3 and scaled_progress < 0.4 then '30-39%'\n when scaled_progress >= 0.2 and scaled_progress < 0.3 then '20-29%'\n when scaled_progress >= 0.1 and scaled_progress < 0.2 then '10-19%'\n else '0-9%'\n end as completion_bucket\nfrom\n completions\n join {{ source('event_sink', 'course_names')}} courses\n on completions.course_key = courses.course_key\n left join {{ source('event_sink', 'course_block_names') }} blocks\n on completions.entity_id = blocks.location", "language": "sql", "refs": [{"name": "completion_events", "package": null, "version": null}], "sources": [["event_sink", "course_block_names"], ["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names", "model.aspects.completion_events"]}, "compiled_path": "target/compiled/aspects/models/completion/fact_completions.sql", "compiled": true, "compiled_code": "with completions as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n progress_percent,\n if(\n object_id like '%/course/%',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n cast(progress_percent as Float)/100 as scaled_progress\n from\n `xapi`.`completion_events`\n)\n\nselect\n completions.emission_time as emission_time,\n completions.org as org,\n completions.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n completions.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n completions.actor_id as actor_id,\n cast(completions.scaled_progress as Float) as scaled_progress,\n case\n when scaled_progress >= 0.9 then '90-100%'\n when scaled_progress >= 0.8 and scaled_progress < 0.9 then '80-89%'\n when scaled_progress >= 0.7 and scaled_progress < 0.8 then '70-79%'\n when scaled_progress >= 0.6 and scaled_progress < 0.7 then '60-69%'\n when scaled_progress >= 0.5 and scaled_progress < 0.6 then '50-59%'\n when scaled_progress >= 0.4 and scaled_progress < 0.5 then '40-49%'\n when scaled_progress >= 0.3 and scaled_progress < 0.4 then '30-39%'\n when scaled_progress >= 0.2 and scaled_progress < 0.3 then '20-29%'\n when scaled_progress >= 0.1 and scaled_progress < 0.2 then '10-19%'\n else '0-9%'\n end as completion_bucket\nfrom\n completions\n join `event_sink`.`course_names` courses\n on completions.course_key = courses.course_key\n left join `event_sink`.`course_block_names` blocks\n on completions.entity_id = blocks.location", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_forum_interactions": {"database": "", "schema": "xapi", "name": "fact_forum_interactions", "resource_type": "model", "package_name": "aspects", "path": "forum/fact_forum_interactions.sql", "original_file_path": "models/forum/fact_forum_interactions.sql", "unique_id": "model.aspects.fact_forum_interactions", "fqn": ["aspects", "forum", "fact_forum_interactions"], "alias": "fact_forum_interactions", "checksum": {"name": "sha256", "checksum": "64122e4345ea67b2f12cae9c50211fb8fe952b5069b84f420ae6620d72e584a4"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record per forum interaction", "columns": {"event_id": {"name": "event_id", "description": "", "meta": {}, "data_type": "UUID", "constraints": [], "quote": null, "tags": []}, "emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": "DateTime64(3)", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "object_id": {"name": "object_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "verb_id": {"name": "verb_id", "description": "", "meta": {}, "data_type": "LowCardinality(String)", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/forum/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.935978, "relation_name": "`xapi`.`fact_forum_interactions`", "raw_code": "select\n forum.event_id as event_id,\n forum.emission_time as emission_time,\n forum.org as org,\n forum.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n forum.object_id as object_id,\n forum.actor_id as actor_id,\n forum.verb_id as verb_id\nfrom\n {{ ref('forum_events') }} forum\n join {{ source('event_sink', 'course_names') }} courses\n on (forum.course_key = courses.course_key)", "language": "sql", "refs": [{"name": "forum_events", "package": null, "version": null}], "sources": [["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_names", "model.aspects.forum_events"]}, "compiled_path": "target/compiled/aspects/models/forum/fact_forum_interactions.sql", "compiled": true, "compiled_code": "select\n forum.event_id as event_id,\n forum.emission_time as emission_time,\n forum.org as org,\n forum.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n forum.object_id as object_id,\n forum.actor_id as actor_id,\n forum.verb_id as verb_id\nfrom\n `xapi`.`forum_events` forum\n join `event_sink`.`course_names` courses\n on (forum.course_key = courses.course_key)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.forum_events": {"database": "", "schema": "xapi", "name": "forum_events", "resource_type": "model", "package_name": "aspects", "path": "forum/forum_events.sql", "original_file_path": "models/forum/forum_events.sql", "unique_id": "model.aspects.forum_events", "fqn": ["aspects", "forum", "forum_events"], "alias": "forum_events", "checksum": {"name": "sha256", "checksum": "3e4d47a2eba1170921892e49b3663ed60d3678dcc9c1cc1b7020b9ac0502bd27"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)"}, "created_at": 1706549584.525926, "relation_name": "`xapi`.`forum_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, event_id)'\n ) }}\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n object_id,\n actor_id,\n verb_id\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE JSON_VALUE(event, '$.object.definition.type') = 'http://id.tincanapi.com/activitytype/discussion'", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/forum/forum_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n object_id,\n actor_id,\n verb_id\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE JSON_VALUE(event, '$.object.definition.type') = 'http://id.tincanapi.com/activitytype/discussion'", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.grading_events": {"database": "", "schema": "xapi", "name": "grading_events", "resource_type": "model", "package_name": "aspects", "path": "grading/grading_events.sql", "original_file_path": "models/grading/grading_events.sql", "unique_id": "model.aspects.grading_events", "fqn": ["aspects", "grading", "grading_events"], "alias": "grading_events", "checksum": {"name": "sha256", "checksum": "e61ea79ae4c49bf00c964ea3621cf87615f41c8d8b1ee301b4bd54918d102a7e"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, scaled_score, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, scaled_score, event_id)"}, "created_at": 1706549584.5322459, "relation_name": "`xapi`.`grading_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, scaled_score, event_id)'\n ) }}\n\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractFloat(event, 'result', 'score', 'scaled') AS scaled_score\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE verb_id IN ('http://id.tincanapi.com/verb/earned', 'https://w3id.org/xapi/acrossx/verbs/evaluated')", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/grading/grading_events.sql", "compiled": true, "compiled_code": "\n\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractFloat(event, 'result', 'score', 'scaled') AS scaled_score\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN ('http://id.tincanapi.com/verb/earned', 'https://w3id.org/xapi/acrossx/verbs/evaluated')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_grades": {"database": "", "schema": "xapi", "name": "fact_grades", "resource_type": "model", "package_name": "aspects", "path": "grading/fact_grades.sql", "original_file_path": "models/grading/fact_grades.sql", "unique_id": "model.aspects.fact_grades", "fqn": ["aspects", "grading", "fact_grades"], "alias": "fact_grades", "checksum": {"name": "sha256", "checksum": "8d4335b0eb71644c3210ff16c0ff1bf882579ab0947e9ba3d89a889cade23720"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record per grading event for courses, subsections, and problems", "columns": {"emission_time": {"name": "emission_time", "description": "Timestamp, to the second, of when this event was emitted", "meta": {}, "data_type": "DateTime64(3)", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_id": {"name": "entity_id", "description": "The block ID or course key for the graded entity", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_name": {"name": "entity_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "entity_name_with_location": {"name": "entity_name_with_location", "description": "", "meta": {}, "data_type": "Nullable(String)", "constraints": [], "quote": null, "tags": []}, "grade_type": {"name": "grade_type", "description": "The type of object graded", "meta": {}, "data_type": "Nullable(String)", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "scaled_score": {"name": "scaled_score", "description": "A ratio between 0 and 1, inclusive, of the learner's grade", "meta": {}, "data_type": "Float32", "constraints": [], "quote": null, "tags": []}, "grade_bucket": {"name": "grade_bucket", "description": "A displayable value of grades sorted into 10% buckets. Useful for grouping grades together to show high-level learner performance", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/grading/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9382606, "relation_name": "`xapi`.`fact_grades`", "raw_code": "with grades as (\n select\n emission_time,\n org,\n course_key,\n case\n when object_id like '%/course/%' then 'course'\n when object_id like '%@sequential+block@%' then 'subsection'\n when object_id like '%@problem+block@%' then 'problem'\n end as grade_type,\n if(\n grade_type = 'course',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n actor_id,\n scaled_score\n from\n {{ ref('grading_events') }}\n)\n\nselect\n grades.emission_time as emission_time,\n grades.org as org,\n grades.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n grades.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n grades.grade_type as grade_type,\n grades.actor_id as actor_id,\n grades.scaled_score as scaled_score,\n case\n when scaled_score >= 0.9 then '90-100%'\n when scaled_score >= 0.8 and scaled_score < 0.9 then '80-89%'\n when scaled_score >= 0.7 and scaled_score < 0.8 then '70-79%'\n when scaled_score >= 0.6 and scaled_score < 0.7 then '60-69%'\n when scaled_score >= 0.5 and scaled_score < 0.6 then '50-59%'\n when scaled_score >= 0.4 and scaled_score < 0.5 then '40-49%'\n when scaled_score >= 0.3 and scaled_score < 0.4 then '30-39%'\n when scaled_score >= 0.2 and scaled_score < 0.3 then '20-29%'\n when scaled_score >= 0.1 and scaled_score < 0.2 then '10-19%'\n else '0-9%'\n end as grade_bucket\nfrom\n grades\n join {{ source('event_sink', 'course_names')}} courses\n on grades.course_key = courses.course_key\n left join {{ source('event_sink', 'course_block_names') }} blocks\n on grades.entity_id = blocks.location", "language": "sql", "refs": [{"name": "grading_events", "package": null, "version": null}], "sources": [["event_sink", "course_block_names"], ["event_sink", "course_names"]], "metrics": [], "depends_on": {"macros": [], "nodes": ["source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names", "model.aspects.grading_events"]}, "compiled_path": "target/compiled/aspects/models/grading/fact_grades.sql", "compiled": true, "compiled_code": "with grades as (\n select\n emission_time,\n org,\n course_key,\n case\n when object_id like '%/course/%' then 'course'\n when object_id like '%@sequential+block@%' then 'subsection'\n when object_id like '%@problem+block@%' then 'problem'\n end as grade_type,\n if(\n grade_type = 'course',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n actor_id,\n scaled_score\n from\n `xapi`.`grading_events`\n)\n\nselect\n grades.emission_time as emission_time,\n grades.org as org,\n grades.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n grades.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n grades.grade_type as grade_type,\n grades.actor_id as actor_id,\n grades.scaled_score as scaled_score,\n case\n when scaled_score >= 0.9 then '90-100%'\n when scaled_score >= 0.8 and scaled_score < 0.9 then '80-89%'\n when scaled_score >= 0.7 and scaled_score < 0.8 then '70-79%'\n when scaled_score >= 0.6 and scaled_score < 0.7 then '60-69%'\n when scaled_score >= 0.5 and scaled_score < 0.6 then '50-59%'\n when scaled_score >= 0.4 and scaled_score < 0.5 then '40-49%'\n when scaled_score >= 0.3 and scaled_score < 0.4 then '30-39%'\n when scaled_score >= 0.2 and scaled_score < 0.3 then '20-29%'\n when scaled_score >= 0.1 and scaled_score < 0.2 then '10-19%'\n else '0-9%'\n end as grade_bucket\nfrom\n grades\n join `event_sink`.`course_names` courses\n on grades.course_key = courses.course_key\n left join `event_sink`.`course_block_names` blocks\n on grades.entity_id = blocks.location", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.int_problem_hints": {"database": "", "schema": "xapi", "name": "int_problem_hints", "resource_type": "model", "package_name": "aspects", "path": "problems/int_problem_hints.sql", "original_file_path": "models/problems/int_problem_hints.sql", "unique_id": "model.aspects.int_problem_hints", "fqn": ["aspects", "problems", "int_problem_hints"], "alias": "int_problem_hints", "checksum": {"name": "sha256", "checksum": "4a8a288769d2f6fa488fd11bb83bfb1eeda843e498cf6972ca4fd7febb386ebf"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.5419385, "relation_name": "`xapi`.`int_problem_hints`", "raw_code": "with hints as (\n select\n emission_time,\n org,\n course_key,\n {{ get_problem_id('object_id') }} as problem_id,\n actor_id,\n case\n when object_id like '%/hint%' then 'hint'\n when object_id like '%/answer%' then 'answer'\n else 'N/A'\n end as help_type\n from\n {{ ref('problem_events') }}\n where\n verb_id = 'http://adlnet.gov/expapi/verbs/asked'\n)\n\nselect\n hints.emission_time as emission_time,\n hints.org as org,\n hints.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n hints.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n hints.actor_id as actor_id,\n hints.help_type as help_type\nfrom\n hints\n join {{ ref('dim_course_blocks')}} blocks\n on (hints.course_key = blocks.course_key\n and hints.problem_id = blocks.block_id)", "language": "sql", "refs": [{"name": "problem_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_problem_id"], "nodes": ["model.aspects.problem_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/problems/int_problem_hints.sql", "compiled": true, "compiled_code": "with hints as (\n select\n emission_time,\n org,\n course_key,\n \n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n as problem_id,\n actor_id,\n case\n when object_id like '%/hint%' then 'hint'\n when object_id like '%/answer%' then 'answer'\n else 'N/A'\n end as help_type\n from\n `xapi`.`problem_events`\n where\n verb_id = 'http://adlnet.gov/expapi/verbs/asked'\n)\n\nselect\n hints.emission_time as emission_time,\n hints.org as org,\n hints.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n hints.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n hints.actor_id as actor_id,\n hints.help_type as help_type\nfrom\n hints\n join `xapi`.`dim_course_blocks` blocks\n on (hints.course_key = blocks.course_key\n and hints.problem_id = blocks.block_id)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.int_problem_results": {"database": "", "schema": "xapi", "name": "int_problem_results", "resource_type": "model", "package_name": "aspects", "path": "problems/int_problem_results.sql", "original_file_path": "models/problems/int_problem_results.sql", "unique_id": "model.aspects.int_problem_results", "fqn": ["aspects", "problems", "int_problem_results"], "alias": "int_problem_results", "checksum": {"name": "sha256", "checksum": "a0f3b295ad345aae0555b804478a62cef3cb2854cb5c9b6066e18df64fdecf84"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.5482466, "relation_name": "`xapi`.`int_problem_results`", "raw_code": "-- select one record per (learner, problem, course, org) tuple\n-- contains either the first successful attempt\n-- or the most recent unsuccessful attempt\n\n\n-- find the timestamp of the earliest successful response\n-- this will be used to pick the xAPI event corresponding to that submission\nwith successful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n min(emission_time) as first_success_at\n from\n {{ ref('fact_problem_responses') }}\n where\n -- clickhouse throws an error when shortening this to `where success`\n success = true\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- for all learners who did not submit a successful response,\n-- find the timestamp of the most recent unsuccessful response\nunsuccessful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n max(emission_time) as last_response_at\n from\n {{ ref('fact_problem_responses') }}\n where\n actor_id not in (select distinct actor_id from successful_responses)\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- combine result sets for successful and unsuccessful problem submissions\nresponses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n first_success_at as emission_time\n from\n successful_responses\n union all\n select\n org,\n course_key,\n problem_id,\n actor_id,\n last_response_at as emission_time\n from\n unsuccessful_responses\n)\n\nselect\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts\nfrom\n {{ ref('fact_problem_responses') }} problem_responses\n join responses\n using (org, course_key, problem_id, actor_id, emission_time)", "language": "sql", "refs": [{"name": "fact_problem_responses", "package": null, "version": null}, {"name": "fact_problem_responses", "package": null, "version": null}, {"name": "fact_problem_responses", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.fact_problem_responses"]}, "compiled_path": "target/compiled/aspects/models/problems/int_problem_results.sql", "compiled": true, "compiled_code": "-- select one record per (learner, problem, course, org) tuple\n-- contains either the first successful attempt\n-- or the most recent unsuccessful attempt\n\n\n-- find the timestamp of the earliest successful response\n-- this will be used to pick the xAPI event corresponding to that submission\nwith successful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n min(emission_time) as first_success_at\n from\n `xapi`.`fact_problem_responses`\n where\n -- clickhouse throws an error when shortening this to `where success`\n success = true\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- for all learners who did not submit a successful response,\n-- find the timestamp of the most recent unsuccessful response\nunsuccessful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n max(emission_time) as last_response_at\n from\n `xapi`.`fact_problem_responses`\n where\n actor_id not in (select distinct actor_id from successful_responses)\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- combine result sets for successful and unsuccessful problem submissions\nresponses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n first_success_at as emission_time\n from\n successful_responses\n union all\n select\n org,\n course_key,\n problem_id,\n actor_id,\n last_response_at as emission_time\n from\n unsuccessful_responses\n)\n\nselect\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts\nfrom\n `xapi`.`fact_problem_responses` problem_responses\n join responses\n using (org, course_key, problem_id, actor_id, emission_time)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_learner_problem_summary": {"database": "", "schema": "xapi", "name": "fact_learner_problem_summary", "resource_type": "model", "package_name": "aspects", "path": "problems/fact_learner_problem_summary.sql", "original_file_path": "models/problems/fact_learner_problem_summary.sql", "unique_id": "model.aspects.fact_learner_problem_summary", "fqn": ["aspects", "problems", "fact_learner_problem_summary"], "alias": "fact_learner_problem_summary", "checksum": {"name": "sha256", "checksum": "fd0a2f24f39497aee19b9f6de759ee4a53b2312b1ef8fe24f94c44dd3dc9bfc7"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record per learner per problem in a course", "columns": {"org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_id": {"name": "problem_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_name": {"name": "problem_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_name_with_location": {"name": "problem_name_with_location", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "success": {"name": "success", "description": "The result of the last submission", "meta": {}, "data_type": "Bool", "constraints": [], "quote": null, "tags": []}, "attempts": {"name": "attempts", "description": "The number of attempts made", "meta": {}, "data_type": "Int16", "constraints": [], "quote": null, "tags": []}, "num_hints_displayed": {"name": "num_hints_displayed", "description": "The number of times a learner asked for a hint", "meta": {}, "data_type": "UInt64", "constraints": [], "quote": null, "tags": []}, "num_answers_displayed": {"name": "num_answers_displayed", "description": "The number of times a learner requested the answers for the problem", "meta": {}, "data_type": "UInt64", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/problems/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9485216, "relation_name": "`xapi`.`fact_learner_problem_summary`", "raw_code": "-- summary table for a learner's performance on and interactions with a\n-- particular problem\nwith results_with_hints as (\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n success,\n attempts,\n 0 as num_hints_displayed,\n 0 as num_answers_displayed\n from {{ ref('int_problem_results') }}\n union all\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n null as success,\n null as attempts,\n case help_type\n when 'hint' then 1\n else 0\n end as num_hints_displayed,\n case help_type\n when 'answer' then 1\n else 0\n end as num_answers_displayed\n from {{ ref('int_problem_hints') }}\n)\n\n-- n.b.: there should only be one row per org, course, problem, and actor\n-- in problem_results, so any(success) and any(attempts) should return the\n-- values from that part of the union and not the null values used as\n-- placeholders in the problem_hints part of the union\nselect\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n coalesce(any(success), false) as success,\n coalesce(any(attempts), 0) as attempts,\n sum(num_hints_displayed) as num_hints_displayed,\n sum(num_answers_displayed) as num_answers_displayed\nfrom\n results_with_hints\ngroup by\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id", "language": "sql", "refs": [{"name": "int_problem_results", "package": null, "version": null}, {"name": "int_problem_hints", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.int_problem_results", "model.aspects.int_problem_hints"]}, "compiled_path": "target/compiled/aspects/models/problems/fact_learner_problem_summary.sql", "compiled": true, "compiled_code": "-- summary table for a learner's performance on and interactions with a\n-- particular problem\nwith results_with_hints as (\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n success,\n attempts,\n 0 as num_hints_displayed,\n 0 as num_answers_displayed\n from `xapi`.`int_problem_results`\n union all\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n null as success,\n null as attempts,\n case help_type\n when 'hint' then 1\n else 0\n end as num_hints_displayed,\n case help_type\n when 'answer' then 1\n else 0\n end as num_answers_displayed\n from `xapi`.`int_problem_hints`\n)\n\n-- n.b.: there should only be one row per org, course, problem, and actor\n-- in problem_results, so any(success) and any(attempts) should return the\n-- values from that part of the union and not the null values used as\n-- placeholders in the problem_hints part of the union\nselect\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n coalesce(any(success), false) as success,\n coalesce(any(attempts), 0) as attempts,\n sum(num_hints_displayed) as num_hints_displayed,\n sum(num_answers_displayed) as num_answers_displayed\nfrom\n results_with_hints\ngroup by\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_problem_responses": {"database": "", "schema": "xapi", "name": "fact_problem_responses", "resource_type": "model", "package_name": "aspects", "path": "problems/fact_problem_responses.sql", "original_file_path": "models/problems/fact_problem_responses.sql", "unique_id": "model.aspects.fact_problem_responses", "fqn": ["aspects", "problems", "fact_problem_responses"], "alias": "fact_problem_responses", "checksum": {"name": "sha256", "checksum": "9327b7aecfc7487b29850a582a053dff923d287d8db0b76b17b7835d71bcecbd"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record for each submitted response to a problem", "columns": {"emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": "DateTime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_id": {"name": "problem_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_name": {"name": "problem_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "problem_name_with_location": {"name": "problem_name_with_location", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "responses": {"name": "responses", "description": "The responses for this submission. If a problem has multiple parts, values for all parts will be in this field", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "success": {"name": "success", "description": "Boolean indicating whether the responses were correct", "meta": {}, "data_type": "Bool", "constraints": [], "quote": null, "tags": []}, "attempts": {"name": "attempts", "description": "Number indicating which attempt this was", "meta": {}, "data_type": "Int16", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/problems/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9499915, "relation_name": "`xapi`.`fact_problem_responses`", "raw_code": "with responses as (\n select\n emission_time,\n org,\n course_key,\n {{ get_problem_id('object_id') }} as problem_id,\n actor_id,\n responses,\n success,\n attempts\n from\n {{ ref('problem_events') }}\n where\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated'\n)\n\nselect\n responses.emission_time as emission_time,\n responses.org as org,\n responses.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n responses.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n responses.actor_id as actor_id,\n responses.responses as responses,\n responses.success as success,\n responses.attempts as attempts\nfrom\n responses\n join {{ ref('dim_course_blocks')}} blocks\n on (responses.course_key = blocks.course_key\n and responses.problem_id = blocks.block_id)\ngroup by\n -- multi-part questions include an extra record for the response to the first\n -- part of the question. this group by clause eliminates the duplicate record\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts", "language": "sql", "refs": [{"name": "problem_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_problem_id"], "nodes": ["model.aspects.problem_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/problems/fact_problem_responses.sql", "compiled": true, "compiled_code": "with responses as (\n select\n emission_time,\n org,\n course_key,\n \n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n as problem_id,\n actor_id,\n responses,\n success,\n attempts\n from\n `xapi`.`problem_events`\n where\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated'\n)\n\nselect\n responses.emission_time as emission_time,\n responses.org as org,\n responses.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n responses.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n responses.actor_id as actor_id,\n responses.responses as responses,\n responses.success as success,\n responses.attempts as attempts\nfrom\n responses\n join `xapi`.`dim_course_blocks` blocks\n on (responses.course_key = blocks.course_key\n and responses.problem_id = blocks.block_id)\ngroup by\n -- multi-part questions include an extra record for the response to the first\n -- part of the question. this group by clause eliminates the duplicate record\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.problem_events": {"database": "", "schema": "xapi", "name": "problem_events", "resource_type": "model", "package_name": "aspects", "path": "problems/problem_events.sql", "original_file_path": "models/problems/problem_events.sql", "unique_id": "model.aspects.problem_events", "fqn": ["aspects", "problems", "problem_events"], "alias": "problem_events", "checksum": {"name": "sha256", "checksum": "963cec9a8f32aacb20b22f5f2ae2e47593797326ac4a4e321ac67122c462231e"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, responses, success, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, object_id, responses, success, event_id)"}, "created_at": 1706549584.5594792, "relation_name": "`xapi`.`problem_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, object_id, responses, success, event_id)'\n ) }}\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.result.response') as responses,\n JSON_VALUE(event, '$.result.score.scaled') as scaled_score,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event, '$.result.success') as Bool),\n false\n ) as success,\n JSON_VALUE(event, '$.object.definition.interactionType') as interaction_type,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event, '$.object.definition.extensions.\"http://id.tincanapi.com/extension/attempt-id\"') as Int16),\n 0\n ) as attempts\nFROM\n {{ ref('xapi_events_all_parsed') }}\nWHERE\n verb_id in (\n 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n 'http://adlnet.gov/expapi/verbs/passed',\n 'http://adlnet.gov/expapi/verbs/asked'\n )", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/problems/problem_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.result.response') as responses,\n JSON_VALUE(event, '$.result.score.scaled') as scaled_score,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event, '$.result.success') as Bool),\n false\n ) as success,\n JSON_VALUE(event, '$.object.definition.interactionType') as interaction_type,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event, '$.object.definition.extensions.\"http://id.tincanapi.com/extension/attempt-id\"') as Int16),\n 0\n ) as attempts\nFROM\n `xapi`.`xapi_events_all_parsed`\nWHERE\n verb_id in (\n 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n 'http://adlnet.gov/expapi/verbs/passed',\n 'http://adlnet.gov/expapi/verbs/asked'\n )", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_video_plays": {"database": "", "schema": "xapi", "name": "fact_video_plays", "resource_type": "model", "package_name": "aspects", "path": "video/fact_video_plays.sql", "original_file_path": "models/video/fact_video_plays.sql", "unique_id": "model.aspects.fact_video_plays", "fqn": ["aspects", "video", "fact_video_plays"], "alias": "fact_video_plays", "checksum": {"name": "sha256", "checksum": "85ab8faefe964ecf36254cab661f50df9eb0fc59bfd6f9b10af0a00779956fc2"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record for each time a learner played a video", "columns": {"emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": "DateTime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_id": {"name": "video_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_name": {"name": "video_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_name_with_location": {"name": "video_name_with_location", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/video/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9559827, "relation_name": "`xapi`.`fact_video_plays`", "raw_code": "-- model to support number of watches per video\n-- ref: https://edx.readthedocs.io/projects/edx-insights/en/latest/Reference.html#engagement-computations\nwith plays as (\n select\n emission_time,\n org,\n course_key,\n splitByString('/xblock/', object_id)[-1] as video_id,\n actor_id\n from\n {{ ref('video_playback_events') }}\n where\n verb_id = 'https://w3id.org/xapi/video/verbs/played'\n)\n\nselect\n plays.emission_time as emission_time,\n plays.org as org,\n plays.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n plays.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n plays.actor_id as actor_id\nfrom\n plays\n join {{ ref('dim_course_blocks')}} blocks\n on (plays.course_key = blocks.course_key\n and plays.video_id = blocks.block_id)", "language": "sql", "refs": [{"name": "video_playback_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.video_playback_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/video/fact_video_plays.sql", "compiled": true, "compiled_code": "-- model to support number of watches per video\n-- ref: https://edx.readthedocs.io/projects/edx-insights/en/latest/Reference.html#engagement-computations\nwith plays as (\n select\n emission_time,\n org,\n course_key,\n splitByString('/xblock/', object_id)[-1] as video_id,\n actor_id\n from\n `xapi`.`video_playback_events`\n where\n verb_id = 'https://w3id.org/xapi/video/verbs/played'\n)\n\nselect\n plays.emission_time as emission_time,\n plays.org as org,\n plays.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n plays.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n plays.actor_id as actor_id\nfrom\n plays\n join `xapi`.`dim_course_blocks` blocks\n on (plays.course_key = blocks.course_key\n and plays.video_id = blocks.block_id)", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.video_playback_events": {"database": "", "schema": "xapi", "name": "video_playback_events", "resource_type": "model", "package_name": "aspects", "path": "video/video_playback_events.sql", "original_file_path": "models/video/video_playback_events.sql", "unique_id": "model.aspects.video_playback_events", "fqn": ["aspects", "video", "video_playback_events"], "alias": "video_playback_events", "checksum": {"name": "sha256", "checksum": "1f102b930d640f92efd401dacda34be4aeb23ba5de0422e43eb545b9d6d69afe"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, verb_id, emission_time, actor_id, video_position, event_id)", "primary_key": "(org, course_key, verb_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, verb_id)", "order_by": "(org, course_key, verb_id, emission_time, actor_id, video_position, event_id)"}, "created_at": 1706549584.5685084, "relation_name": "`xapi`.`video_playback_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, verb_id)',\n order_by='(org, course_key, verb_id, emission_time, actor_id, video_position, event_id)'\n ) }}\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n ceil(CAST(coalesce(nullIf(JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time\"'), ''), nullIf(JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time-from\"'), ''), '0.0'), 'Decimal32(2)')) AS video_position\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE (verb_id IN ('http://adlnet.gov/expapi/verbs/completed', 'http://adlnet.gov/expapi/verbs/initialized', 'http://adlnet.gov/expapi/verbs/terminated', 'https://w3id.org/xapi/video/verbs/paused', 'https://w3id.org/xapi/video/verbs/played', 'https://w3id.org/xapi/video/verbs/seeked')) AND (object_id LIKE '%video+block%')", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/video/video_playback_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n ceil(CAST(coalesce(nullIf(JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time\"'), ''), nullIf(JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time-from\"'), ''), '0.0'), 'Decimal32(2)')) AS video_position\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE (verb_id IN ('http://adlnet.gov/expapi/verbs/completed', 'http://adlnet.gov/expapi/verbs/initialized', 'http://adlnet.gov/expapi/verbs/terminated', 'https://w3id.org/xapi/video/verbs/paused', 'https://w3id.org/xapi/video/verbs/played', 'https://w3id.org/xapi/video/verbs/seeked')) AND (object_id LIKE '%video+block%')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.fact_transcript_usage": {"database": "", "schema": "xapi", "name": "fact_transcript_usage", "resource_type": "model", "package_name": "aspects", "path": "video/fact_transcript_usage.sql", "original_file_path": "models/video/fact_transcript_usage.sql", "unique_id": "model.aspects.fact_transcript_usage", "fqn": ["aspects", "video", "fact_transcript_usage"], "alias": "fact_transcript_usage", "checksum": {"name": "sha256", "checksum": "6ebe9cc34ac188422c1d512034164d4666a2fcfc30cde343707b141b7343b051"}, "config": {"enabled": true, "alias": null, "schema": null, "database": null, "tags": [], "meta": {}, "group": null, "materialized": "view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected"}, "tags": [], "description": "One record for each time a transcript or closed caption was enabled", "columns": {"emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": "DateTime", "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_id": {"name": "video_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_name": {"name": "video_name", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "video_name_with_location": {"name": "video_name_with_location", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}, "actor_id": {"name": "actor_id", "description": "", "meta": {}, "data_type": "String", "constraints": [], "quote": null, "tags": []}}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": "aspects://models/video/schema.yml", "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9571497, "relation_name": "`xapi`.`fact_transcript_usage`", "raw_code": "select\n transcripts.emission_time as emission_time,\n transcripts.org as org,\n transcripts.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n transcripts.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n transcripts.actor_id as actor_id\nfrom\n {{ ref('video_transcript_events') }} transcripts\n join {{ ref('dim_course_blocks')}} blocks\n on (transcripts.course_key = blocks.course_key\n and transcripts.video_id = blocks.block_id)\nwhere\n transcripts.cc_enabled", "language": "sql", "refs": [{"name": "video_transcript_events", "package": null, "version": null}, {"name": "dim_course_blocks", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.video_transcript_events", "model.aspects.dim_course_blocks"]}, "compiled_path": "target/compiled/aspects/models/video/fact_transcript_usage.sql", "compiled": true, "compiled_code": "select\n transcripts.emission_time as emission_time,\n transcripts.org as org,\n transcripts.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n transcripts.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n transcripts.actor_id as actor_id\nfrom\n `xapi`.`video_transcript_events` transcripts\n join `xapi`.`dim_course_blocks` blocks\n on (transcripts.course_key = blocks.course_key\n and transcripts.video_id = blocks.block_id)\nwhere\n transcripts.cc_enabled", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "model.aspects.video_transcript_events": {"database": "", "schema": "xapi", "name": "video_transcript_events", "resource_type": "model", "package_name": "aspects", "path": "video/video_transcript_events.sql", "original_file_path": "models/video/video_transcript_events.sql", "unique_id": "model.aspects.video_transcript_events", "fqn": ["aspects", "video", "video_transcript_events"], "alias": "video_transcript_events", "checksum": {"name": "sha256", "checksum": "d51d73cf4f6c4f20698f5e23e6faf91013fc466a24cee2db250f6bf2cddbd8d0"}, "config": {"enabled": true, "alias": null, "schema": "xapi", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "materialized_view", "incremental_strategy": null, "persist_docs": {}, "post-hook": [], "pre-hook": [], "quoting": {}, "column_types": {}, "full_refresh": null, "unique_key": null, "on_schema_change": "ignore", "on_configuration_change": "apply", "grants": {}, "packages": [], "docs": {"show": true, "node_color": null}, "contract": {"enforced": false, "alias_types": true}, "access": "protected", "engine": "\n ReplacingMergeTree()", "order_by": "(org, course_key, video_id, emission_time, actor_id, cc_enabled, event_id)", "primary_key": "(org, course_key, video_id)"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"materialized": "materialized_view", "schema": "xapi", "engine": "\n ReplacingMergeTree()", "primary_key": "(org, course_key, video_id)", "order_by": "(org, course_key, video_id, emission_time, actor_id, cc_enabled, event_id)"}, "created_at": 1706549584.577598, "relation_name": "`xapi`.`video_transcript_events`", "raw_code": "{{ config(\n materialized='materialized_view',\n schema=env_var('ASPECTS_XAPI_DATABASE', 'xapi'),\n engine=get_engine('ReplacingMergeTree()'),\n primary_key='(org, course_key, video_id)',\n order_by='(org, course_key, video_id, emission_time, actor_id, cc_enabled, event_id)'\n ) }}\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n splitByString('/xblock/', object_id)[2] as video_id,\n actor_id,\n JSONExtractBool(event, 'result','extensions','https://w3id.org/xapi/video/extensions/cc-enabled') as cc_enabled\nFROM {{ ref('xapi_events_all_parsed') }}\nWHERE\n verb_id IN ('http://adlnet.gov/expapi/verbs/interacted')\n AND JSONHas(event, 'result', 'extensions', 'https://w3id.org/xapi/video/extensions/cc-enabled')", "language": "sql", "refs": [{"name": "xapi_events_all_parsed", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.aspects.get_engine"], "nodes": ["model.aspects.xapi_events_all_parsed"]}, "compiled_path": "target/compiled/aspects/models/video/video_transcript_events.sql", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n splitByString('/xblock/', object_id)[2] as video_id,\n actor_id,\n JSONExtractBool(event, 'result','extensions','https://w3id.org/xapi/video/extensions/cc-enabled') as cc_enabled\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE\n verb_id IN ('http://adlnet.gov/expapi/verbs/interacted')\n AND JSONHas(event, 'result', 'extensions', 'https://w3id.org/xapi/video/extensions/cc-enabled')", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "access": "protected", "constraints": [], "version": null, "latest_version": null, "deprecation_date": null}, "test.aspects.problem_results_uniqueness": {"database": "", "schema": "xapi", "name": "problem_results_uniqueness", "resource_type": "test", "package_name": "aspects", "path": "problem_results_uniqueness.sql", "original_file_path": "tests/problem_results_uniqueness.sql", "unique_id": "test.aspects.problem_results_uniqueness", "fqn": ["aspects", "problem_results_uniqueness"], "alias": "problem_results_uniqueness", "checksum": {"name": "sha256", "checksum": "d21bd7a3a03835f0d1c3ba9edb31a94067fffa2450bb56ceed607997f41524b7"}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.6698143, "relation_name": null, "raw_code": "-- problem_results should only have one record for the following\n-- combination of values:\n-- actor_id, problem_id, course_id, org\n\nselect\n org,\n course_key,\n problem_id,\n actor_id,\n responses,\n count(*) as num_rows\nfrom\n {{ ref('int_problem_results') }}\ngroup by\n org,\n course_key,\n problem_id,\n actor_id,\n responses\nhaving num_rows > 1", "language": "sql", "refs": [{"name": "int_problem_results", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.int_problem_results"]}, "compiled_path": "target/compiled/aspects/tests/problem_results_uniqueness.sql", "compiled": true, "compiled_code": "-- problem_results should only have one record for the following\n-- combination of values:\n-- actor_id, problem_id, course_id, org\n\nselect\n org,\n course_key,\n problem_id,\n actor_id,\n responses,\n count(*) as num_rows\nfrom\n `xapi`.`int_problem_results`\ngroup by\n org,\n course_key,\n problem_id,\n actor_id,\n responses\nhaving num_rows > 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}}, "test.aspects.learner_problem_summary_uniqueness": {"database": "", "schema": "xapi", "name": "learner_problem_summary_uniqueness", "resource_type": "test", "package_name": "aspects", "path": "learner_problem_summary_uniqueness.sql", "original_file_path": "tests/learner_problem_summary_uniqueness.sql", "unique_id": "test.aspects.learner_problem_summary_uniqueness", "fqn": ["aspects", "learner_problem_summary_uniqueness"], "alias": "learner_problem_summary_uniqueness", "checksum": {"name": "sha256", "checksum": "9cb84d9dc15e82589de6c3cbb6b1c97e7cde37513a6399754e490a4453802244"}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.6746817, "relation_name": null, "raw_code": "select\n org,\n course_key,\n problem_id,\n actor_id,\n count(*) as num_rows\nfrom\n {{ ref('fact_learner_problem_summary') }}\ngroup by\n org,\n course_key,\n problem_id,\n actor_id\nhaving num_rows > 1", "language": "sql", "refs": [{"name": "fact_learner_problem_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": [], "nodes": ["model.aspects.fact_learner_problem_summary"]}, "compiled_path": "target/compiled/aspects/tests/learner_problem_summary_uniqueness.sql", "compiled": true, "compiled_code": "select\n org,\n course_key,\n problem_id,\n actor_id,\n count(*) as num_rows\nfrom\n `xapi`.`fact_learner_problem_summary`\ngroup by\n org,\n course_key,\n problem_id,\n actor_id\nhaving num_rows > 1", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}}, "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4": {"test_metadata": {"name": "accepted_values", "kwargs": {"values": ["registered", "unregistered"], "column_name": "enrollment_status", "model": "{{ get_where_subquery(ref('fact_enrollments')) }}"}, "namespace": null}, "database": "", "schema": "xapi", "name": "accepted_values_fact_enrollments_enrollment_status__registered__unregistered", "resource_type": "test", "package_name": "aspects", "path": "accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9.sql", "original_file_path": "models/enrollment/schema.yml", "unique_id": "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4", "fqn": ["aspects", "enrollment", "accepted_values_fact_enrollments_enrollment_status__registered__unregistered"], "alias": "accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"alias": "accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9"}, "created_at": 1706549584.836003, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9\") }}", "language": "sql", "refs": [{"name": "fact_enrollments", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.aspects.fact_enrollments"]}, "compiled_path": "target/compiled/aspects/models/enrollment/schema.yml/accepted_values_fact_enrollmen_1086f4b5aaa1831a14dfbb256e3845c9.sql", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n enrollment_status as value_field,\n count(*) as n_records\n\n from `xapi`.`fact_enrollments`\n group by enrollment_status\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'registered','unregistered'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "enrollment_status", "file_key_name": "models.fact_enrollments", "attached_node": "model.aspects.fact_enrollments"}, "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f": {"test_metadata": {"name": "accepted_values", "kwargs": {"values": ["course", "subsection", "problem"], "column_name": "grade_type", "model": "{{ get_where_subquery(ref('fact_grades')) }}"}, "namespace": null}, "database": "", "schema": "xapi", "name": "accepted_values_fact_grades_grade_type__course__subsection__problem", "resource_type": "test", "package_name": "aspects", "path": "accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87.sql", "original_file_path": "models/grading/schema.yml", "unique_id": "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f", "fqn": ["aspects", "grading", "accepted_values_fact_grades_grade_type__course__subsection__problem"], "alias": "accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": "accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87", "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {"alias": "accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87"}, "created_at": 1706549584.9393554, "relation_name": null, "raw_code": "{{ test_accepted_values(**_dbt_generic_test_kwargs) }}{{ config(alias=\"accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87\") }}", "language": "sql", "refs": [{"name": "fact_grades", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_accepted_values", "macro.dbt.get_where_subquery"], "nodes": ["model.aspects.fact_grades"]}, "compiled_path": "target/compiled/aspects/models/grading/schema.yml/accepted_values_fact_grades_de7a17ef32c1f12fb10640d566a35d87.sql", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n grade_type as value_field,\n count(*) as n_records\n\n from `xapi`.`fact_grades`\n group by grade_type\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'course','subsection','problem'\n)\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "grade_type", "file_key_name": "models.fact_grades", "attached_node": "model.aspects.fact_grades"}, "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da": {"test_metadata": {"name": "not_null", "kwargs": {"column_name": "success", "model": "{{ get_where_subquery(ref('fact_learner_problem_summary')) }}"}, "namespace": null}, "database": "", "schema": "xapi", "name": "not_null_fact_learner_problem_summary_success", "resource_type": "test", "package_name": "aspects", "path": "not_null_fact_learner_problem_summary_success.sql", "original_file_path": "models/problems/schema.yml", "unique_id": "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da", "fqn": ["aspects", "problems", "not_null_fact_learner_problem_summary_success"], "alias": "not_null_fact_learner_problem_summary_success", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9510157, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "fact_learner_problem_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.aspects.fact_learner_problem_summary"]}, "compiled_path": "target/compiled/aspects/models/problems/schema.yml/not_null_fact_learner_problem_summary_success.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect success\nfrom `xapi`.`fact_learner_problem_summary`\nwhere success is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "success", "file_key_name": "models.fact_learner_problem_summary", "attached_node": "model.aspects.fact_learner_problem_summary"}, "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b": {"test_metadata": {"name": "not_null", "kwargs": {"column_name": "attempts", "model": "{{ get_where_subquery(ref('fact_learner_problem_summary')) }}"}, "namespace": null}, "database": "", "schema": "xapi", "name": "not_null_fact_learner_problem_summary_attempts", "resource_type": "test", "package_name": "aspects", "path": "not_null_fact_learner_problem_summary_attempts.sql", "original_file_path": "models/problems/schema.yml", "unique_id": "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b", "fqn": ["aspects", "problems", "not_null_fact_learner_problem_summary_attempts"], "alias": "not_null_fact_learner_problem_summary_attempts", "checksum": {"name": "none", "checksum": ""}, "config": {"enabled": true, "alias": null, "schema": "dbt_test__audit", "database": null, "tags": [], "meta": {}, "group": null, "materialized": "test", "severity": "ERROR", "store_failures": null, "store_failures_as": null, "where": null, "limit": null, "fail_calc": "count(*)", "warn_if": "!= 0", "error_if": "!= 0"}, "tags": [], "description": "", "columns": {}, "meta": {}, "group": null, "docs": {"show": true, "node_color": null}, "patch_path": null, "build_path": null, "deferred": false, "unrendered_config": {}, "created_at": 1706549584.9529855, "relation_name": null, "raw_code": "{{ test_not_null(**_dbt_generic_test_kwargs) }}", "language": "sql", "refs": [{"name": "fact_learner_problem_summary", "package": null, "version": null}], "sources": [], "metrics": [], "depends_on": {"macros": ["macro.dbt.test_not_null", "macro.dbt.get_where_subquery"], "nodes": ["model.aspects.fact_learner_problem_summary"]}, "compiled_path": "target/compiled/aspects/models/problems/schema.yml/not_null_fact_learner_problem_summary_attempts.sql", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect attempts\nfrom `xapi`.`fact_learner_problem_summary`\nwhere attempts is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "contract": {"enforced": false, "alias_types": true, "checksum": null}, "column_name": "attempts", "file_key_name": "models.fact_learner_problem_summary", "attached_node": "model.aspects.fact_learner_problem_summary"}}, "sources": {"source.aspects.xapi.xapi_events_all": {"database": "xapi", "schema": "xapi", "name": "xapi_events_all", "resource_type": "source", "package_name": "aspects", "path": "models/base/sources.yml", "original_file_path": "models/base/sources.yml", "unique_id": "source.aspects.xapi.xapi_events_all", "fqn": ["aspects", "base", "xapi", "xapi_events_all"], "source_name": "xapi", "source_description": "the xapi database in clickhouse", "loader": "", "identifier": "xapi_events_all", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": null, "freshness": {"warn_after": {"count": null, "period": null}, "error_after": {"count": null, "period": null}, "filter": null}, "external": null, "description": "Base table for raw xAPI events", "columns": {"event_id": {"name": "event_id", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "emission_time": {"name": "emission_time", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "event": {"name": "event", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "`xapi`.`xapi_events_all`", "created_at": 1706549584.9588652}, "source.aspects.event_sink.course_block_names": {"database": "event_sink", "schema": "event_sink", "name": "course_block_names", "resource_type": "source", "package_name": "aspects", "path": "models/base/sources.yml", "original_file_path": "models/base/sources.yml", "unique_id": "source.aspects.event_sink.course_block_names", "fqn": ["aspects", "base", "event_sink", "course_block_names"], "source_name": "event_sink", "source_description": "", "loader": "", "identifier": "course_block_names", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": null, "freshness": {"warn_after": {"count": null, "period": null}, "error_after": {"count": null, "period": null}, "filter": null}, "external": null, "description": "", "columns": {"location": {"name": "location", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "block_name": {"name": "block_name", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "graded": {"name": "graded", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "display_name_with_location": {"name": "display_name_with_location", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "`event_sink`.`course_block_names`", "created_at": 1706549584.9591022}, "source.aspects.event_sink.course_names": {"database": "event_sink", "schema": "event_sink", "name": "course_names", "resource_type": "source", "package_name": "aspects", "path": "models/base/sources.yml", "original_file_path": "models/base/sources.yml", "unique_id": "source.aspects.event_sink.course_names", "fqn": ["aspects", "base", "event_sink", "course_names"], "source_name": "event_sink", "source_description": "", "loader": "", "identifier": "course_names", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": null, "freshness": {"warn_after": {"count": null, "period": null}, "error_after": {"count": null, "period": null}, "filter": null}, "external": null, "description": "", "columns": {"course_key": {"name": "course_key", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "course_name": {"name": "course_name", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "course_run": {"name": "course_run", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}, "org": {"name": "org", "description": "", "meta": {}, "data_type": null, "constraints": [], "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "`event_sink`.`course_names`", "created_at": 1706549584.959297}}, "macros": {"macro.aspects.get_problem_id": {"name": "get_problem_id", "resource_type": "macro", "package_name": "aspects", "path": "macros/get_problem_id.sql", "original_file_path": "macros/get_problem_id.sql", "unique_id": "macro.aspects.get_problem_id", "macro_sql": "{% macro get_problem_id(object_id) %}\n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0322676, "supported_languages": null}, "macro.aspects.on_cluster": {"name": "on_cluster", "resource_type": "macro", "package_name": "aspects", "path": "macros/cluster_macros.sql", "original_file_path": "macros/cluster_macros.sql", "unique_id": "macro.aspects.on_cluster", "macro_sql": "{% macro on_cluster() -%}\n {%- if env_var(\"CLICKHOUSE_CLUSTER_NAME\", \"\") != \"\" -%}\n ON CLUSTER {{ env_var(\"CLICKHOUSE_CLUSTER_NAME\") }}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.033161, "supported_languages": null}, "macro.aspects.get_engine": {"name": "get_engine", "resource_type": "macro", "package_name": "aspects", "path": "macros/cluster_macros.sql", "original_file_path": "macros/cluster_macros.sql", "unique_id": "macro.aspects.get_engine", "macro_sql": "{% macro get_engine(engine) -%}\n {%- if env_var(\"CLICKHOUSE_CLUSTER_NAME\", \"\") != \"\" -%}\n {{ \"Replicated\" + engine }}\n {% else %}\n {{ engine }}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0337105, "supported_languages": null}, "macro.aspects.generate_schema_name": {"name": "generate_schema_name", "resource_type": "macro", "package_name": "aspects", "path": "macros/get_custom_schema.sql", "original_file_path": "macros/get_custom_schema.sql", "unique_id": "macro.aspects.generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name, node) -%}\n {{ generate_schema_name_for_env(custom_schema_name, node) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.generate_schema_name_for_env"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.034094, "supported_languages": null}, "macro.dbt_clickhouse.one_alter_relation": {"name": "one_alter_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.one_alter_relation", "macro_sql": "{% macro one_alter_relation(relation, alter_comments) %}\n alter table {{ relation }} {{ on_cluster_clause(relation) }} {{ alter_comments }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0361354, "supported_languages": null}, "macro.dbt_clickhouse.one_alter_column_comment": {"name": "one_alter_column_comment", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.one_alter_column_comment", "macro_sql": "{% macro one_alter_column_comment(relation, column_name, comment) %}\n alter table {{ relation }} {{ on_cluster_clause(relation) }} comment column {{ column_name }} '{{ comment }}'\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0365775, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__alter_relation_comment": {"name": "clickhouse__alter_relation_comment", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__alter_relation_comment", "macro_sql": "{% macro clickhouse__alter_relation_comment(relation, comment) %}\n alter table {{ relation }} {{ on_cluster_clause(relation) }} modify comment '{{ comment }}'\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0371468, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__persist_docs": {"name": "clickhouse__persist_docs", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__persist_docs", "macro_sql": "{% macro clickhouse__persist_docs(relation, model, for_relation, for_columns) %}\n {%- set alter_comments = [] %}\n\n {%- if for_relation and config.persist_relation_docs() and model.description -%}\n {% set escaped_comment = clickhouse_escape_comment(model.description) %}\n {% do alter_comments.append(\"modify comment {comment}\".format(comment=escaped_comment)) %}\n {%- endif -%}\n\n {%- if for_columns and config.persist_column_docs() and model.columns -%}\n {% set existing_columns = adapter.get_columns_in_relation(relation) | map(attribute=\"name\") | list %}\n {% for column_name in model.columns if (column_name in existing_columns) %}\n {%- set comment = model.columns[column_name]['description'] -%}\n {%- if comment %}\n {% set escaped_comment = clickhouse_escape_comment(comment) %}\n {% do alter_comments.append(\"comment column {column_name} {comment}\".format(column_name=column_name, comment=escaped_comment)) %}\n {%- endif %}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if alter_comments | length > 0 -%}\n {% do run_query(one_alter_relation(relation, alter_comments|join(', '))) %}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse_escape_comment", "macro.dbt.run_query", "macro.dbt_clickhouse.one_alter_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.039751, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse_escape_comment": {"name": "clickhouse_escape_comment", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/persist_docs.sql", "original_file_path": "macros/persist_docs.sql", "unique_id": "macro.dbt_clickhouse.clickhouse_escape_comment", "macro_sql": "{% macro clickhouse_escape_comment(comment) -%}\n {% if adapter.is_before_version('21.9.2.17') %}\n {% do exceptions.raise_compiler_error('Unsupported ClickHouse version for using heredoc syntax') %}\n {% endif %}\n {% if comment is not string %}\n {% do exceptions.raise_compiler_error('cannot escape a non-string: ' ~ comment) %}\n {% endif %}\n {%- set magic = '$dbt_comment_literal_block$' -%}\n {%- if magic in comment -%}\n {%- do exceptions.raise_compiler_error('The string ' ~ magic ~ ' is not allowed in comments.') -%}\n {%- endif -%}\n {{ magic }}{{ comment }}{{ magic }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.041084, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__list_schemas": {"name": "clickhouse__list_schemas", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__list_schemas", "macro_sql": "{% macro clickhouse__list_schemas(database) %}\n {% call statement('list_schemas', fetch_result=True, auto_begin=False) %}\n select name from system.databases\n {% endcall %}\n {{ return(load_result('list_schemas').table) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0458026, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__create_schema": {"name": "clickhouse__create_schema", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_schema", "macro_sql": "{% macro clickhouse__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create database if not exists {{ relation.without_identifier().include(database=False) }}\n {{ on_cluster_clause(relation)}}\n {{ adapter.clickhouse_db_engine_clause() }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.046453, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__drop_schema": {"name": "clickhouse__drop_schema", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__drop_schema", "macro_sql": "{% macro clickhouse__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop database if exists {{ relation.without_identifier().include(database=False) }} {{ on_cluster_clause(relation)}}\n {%- endcall -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0470028, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__list_relations_without_caching": {"name": "clickhouse__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__list_relations_without_caching", "macro_sql": "{% macro clickhouse__list_relations_without_caching(schema_relation) %}\n {% call statement('list_relations_without_caching', fetch_result=True) -%}\n select\n t.name as name,\n t.database as schema,\n if(engine not in ('MaterializedView', 'View'), 'table', 'view') as type,\n db.engine as db_engine,\n {%- if adapter.get_clickhouse_cluster_name() -%}\n count(distinct _shard_num) > 1 as is_on_cluster\n from clusterAllReplicas({{ adapter.get_clickhouse_cluster_name() }}, system.tables) as t\n join system.databases as db on t.database = db.name\n where schema = '{{ schema_relation.schema }}'\n group by name, schema, type, db_engine\n {%- else -%}\n 0 as is_on_cluster\n from system.tables as t join system.databases as db on t.database = db.name\n where schema = '{{ schema_relation.schema }}'\n {% endif %}\n\n {% endcall %}\n {{ return(load_result('list_relations_without_caching').table) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0479727, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_columns_in_relation": {"name": "clickhouse__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_columns_in_relation", "macro_sql": "{% macro clickhouse__get_columns_in_relation(relation) -%}\n {% call statement('get_columns', fetch_result=True) %}\n select name, type from system.columns where table = '{{ relation.identifier }}'\n {% if relation.schema %}\n and database = '{{ relation.schema }}'\n {% endif %}\n order by position\n {% endcall %}\n {{ return(sql_convert_columns_in_relation(load_result('get_columns').table)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.sql_convert_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0487711, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__drop_relation": {"name": "clickhouse__drop_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__drop_relation", "macro_sql": "{% macro clickhouse__drop_relation(relation, obj_type='table') -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n {# drop relation on cluster by default if cluster is set #}\n drop {{ obj_type }} if exists {{ relation }} {{ on_cluster_clause(relation.without_identifier(), True)}}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0494583, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__rename_relation": {"name": "clickhouse__rename_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__rename_relation", "macro_sql": "{% macro clickhouse__rename_relation(from_relation, to_relation, obj_type='table') -%}\n {% call statement('drop_relation') %}\n drop {{ obj_type }} if exists {{ to_relation }} {{ on_cluster_clause(to_relation.without_identifier())}}\n {% endcall %}\n {% call statement('rename_relation') %}\n rename {{ obj_type }} {{ from_relation }} to {{ to_relation }} {{ on_cluster_clause(from_relation)}}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0504005, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__truncate_relation": {"name": "clickhouse__truncate_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__truncate_relation", "macro_sql": "{% macro clickhouse__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }} {{ on_cluster_clause(relation)}}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0508413, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__make_temp_relation": {"name": "clickhouse__make_temp_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__make_temp_relation", "macro_sql": "{% macro clickhouse__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={\"identifier\": tmp_identifier, \"schema\": None}) -%}\n {% do return(tmp_relation) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.051556, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__generate_database_name": {"name": "clickhouse__generate_database_name", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__generate_database_name", "macro_sql": "{% macro clickhouse__generate_database_name(custom_database_name=none, node=none) -%}\n {% do return('') %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0518897, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_columns_in_query": {"name": "clickhouse__get_columns_in_query", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_columns_in_query", "macro_sql": "{% macro clickhouse__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n limit 0\n {% endcall %}\n\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0526, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__alter_column_type": {"name": "clickhouse__alter_column_type", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__alter_column_type", "macro_sql": "{% macro clickhouse__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} {{ on_cluster_clause(relation)}} modify column {{ adapter.quote(column_name) }} {{ new_column_type }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0532482, "supported_languages": null}, "macro.dbt_clickhouse.exchange_tables_atomic": {"name": "exchange_tables_atomic", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "unique_id": "macro.dbt_clickhouse.exchange_tables_atomic", "macro_sql": "{% macro exchange_tables_atomic(old_relation, target_relation, obj_types='TABLES') %}\n\n {%- if adapter.get_clickhouse_cluster_name() is not none and obj_types == 'TABLES' and 'Replicated' in engine_clause() %}\n {%- call statement('exchange_table_sync_replica') -%}\n SYSTEM SYNC REPLICA {{ on_cluster_clause(target_relation) }} {{ target_relation.schema }}.{{ target_relation.identifier }}\n {% endcall %}\n {%- endif %}\n {%- call statement('exchange_tables_atomic') -%}\n EXCHANGE {{ obj_types }} {{ old_relation }} AND {{ target_relation }} {{ on_cluster_clause(target_relation)}}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.engine_clause", "macro.dbt.statement", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0545568, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_assert_columns_equivalent": {"name": "clickhouse__get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/column_spec_ddl.sql", "original_file_path": "macros/column_spec_ddl.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_assert_columns_equivalent", "macro_sql": "{% macro clickhouse__get_assert_columns_equivalent(sql) -%}\n {%- set user_defined_columns = model['columns'] -%}\n\n {%- if not user_defined_columns -%}\n {{ exceptions.raise_contract_error([], []) }}\n {%- endif -%}\n\n {%- set yaml_columns = user_defined_columns.values() -%}\n\n {%- set sql_file_provided_columns = adapter.get_column_schema_from_query(sql) -%}\n {%- set sql_columns = adapter.format_columns(sql_file_provided_columns) -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- for sql_col in sql_columns -%}\n {%- set yaml_col = [] -%}\n {%- for this_col in yaml_columns -%}\n {%- if this_col['name'] == sql_col['name'] -%}\n {%- do yaml_col.append(this_col) -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if not yaml_col -%}\n {#-- Column with name not found in yaml #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- if sql_col['data_type'] != yaml_col[0]['data_type'] -%}\n {#-- Column data types don't match #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- endfor -%}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0580688, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_catalog": {"name": "clickhouse__get_catalog", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_catalog", "macro_sql": "{% macro clickhouse__get_catalog(information_schema, schemas) -%}\n {%- call statement('catalog', fetch_result=True) -%}\n select\n '' as table_database,\n columns.database as table_schema,\n columns.table as table_name,\n if(tables.engine not in ('MaterializedView', 'View'), 'table', 'view') as table_type,\n nullIf(tables.comment, '') as table_comment,\n columns.name as column_name,\n columns.position as column_index,\n columns.type as column_type,\n nullIf(columns.comment, '') as column_comment,\n null as table_owner\n from system.columns as columns\n join system.tables as tables on tables.database = columns.database and tables.name = columns.table\n where database != 'system' and\n (\n {%- for schema in schemas -%}\n columns.database = '{{ schema }}'\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n order by columns.database, columns.table, columns.position\n {%- endcall -%}\n {{ return(load_result('catalog').table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0592418, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__test_relationships": {"name": "clickhouse__test_relationships", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/schema_tests/relationships.sql", "original_file_path": "macros/schema_tests/relationships.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__test_relationships", "macro_sql": "{% macro clickhouse__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\nsettings join_use_nulls = 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0599189, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse_s3source": {"name": "clickhouse_s3source", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/s3.sql", "original_file_path": "macros/materializations/s3.sql", "unique_id": "macro.dbt_clickhouse.clickhouse_s3source", "macro_sql": "{% macro clickhouse_s3source(config_name='', bucket='', path='', fmt='', structure='',\n aws_access_key_id='', aws_secret_access_key='', compression='') %}\n {% if config_name and not config_name.lower().endswith('s3') %}\n {{ exceptions.raise_compiler_error(\"S3 configuration should end with 's3'\") }}\n {% endif %}\n {% set s3config = config.get(config_name, {}) %}\n {{ adapter.s3source_clause(\n config_name=config_name,\n s3_model_config=s3config,\n bucket=bucket,\n path=path,\n fmt=fmt,\n structure=structure,\n aws_access_key_id=aws_access_key_id,\n aws_secret_access_key=aws_secret_access_key,\n compression=compression) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.061673, "supported_languages": null}, "macro.dbt_clickhouse.materialization_distributed_table_clickhouse": {"name": "materialization_distributed_table_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/distributed_table.sql", "original_file_path": "macros/materializations/distributed_table.sql", "unique_id": "macro.dbt_clickhouse.materialization_distributed_table_clickhouse", "macro_sql": "{% materialization distributed_table, adapter='clickhouse' %}\n {% set insert_distributed_sync = run_query(\"SELECT value FROM system.settings WHERE name = 'insert_distributed_sync'\")[0][0] %}\n {% if insert_distributed_sync != '1' %}\n {% do exceptions.raise_compiler_error('To use distributed materialization setting insert_distributed_sync should be set to 1') %}\n {% endif %}\n\n {%- set local_suffix = adapter.get_clickhouse_local_suffix() -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n\n {% set on_cluster = on_cluster_clause(target_relation) %}\n {% if on_cluster.strip() == '' %}\n {% do exceptions.raise_compiler_error('To use distributed materialization cluster setting in dbt profile must be set') %}\n {% endif %}\n\n {% set existing_relation_local = existing_relation.incorporate(path={\"identifier\": this.identifier + local_suffix}) if existing_relation is not none else none %}\n {% set target_relation_local = target_relation.incorporate(path={\"identifier\": this.identifier + local_suffix}) if target_relation is not none else none %}\n\n {%- set backup_relation = none -%}\n {%- set preexisting_backup_relation = none -%}\n {%- set preexisting_intermediate_relation = none -%}\n\n {% if existing_relation_local is not none %}\n {%- set backup_relation_type = existing_relation_local.type -%}\n {%- set backup_relation = make_backup_relation(target_relation_local, backup_relation_type) -%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {% if not existing_relation.can_exchange %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation_local) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n {% endif %}\n {% endif %}\n {% set view_relation = default__make_temp_relation(target_relation, '__dbt_tmp') %}\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(view_relation) }}\n\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {% call statement('main') %}\n {{ create_view_as(view_relation, sql) }}\n {% endcall %}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if backup_relation is none %}\n {{ create_distributed_local_table(target_relation, target_relation_local, view_relation) }}\n {% elif existing_relation.can_exchange %}\n -- We can do an atomic exchange, so no need for an intermediate\n {% call statement('main') -%}\n {{ create_empty_table_from_relation(backup_relation, view_relation) }}\n {%- endcall %}\n {% do exchange_tables_atomic(backup_relation, existing_relation_local) %}\n {% else %}\n {% do run_query(create_empty_table_from_relation(intermediate_relation, view_relation)) or '' %}\n {{ adapter.rename_relation(existing_relation_local, backup_relation) }}\n {{ adapter.rename_relation(intermediate_relation, target_relation_local) }}\n {{ create_distributed_table(target_relation, target_relation_local) }}\n {% endif %}\n {% do run_query(clickhouse__insert_into(target_relation, sql)) or '' %}\n {{ drop_relation_if_exists(view_relation) }}\n -- cleanup\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation_local, grant_config, should_revoke=should_revoke) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n {{ adapter.commit() }}\n {{ drop_relation_if_exists(backup_relation) }}\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.load_cached_relation", "macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.make_backup_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.default__make_temp_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_view_as", "macro.dbt_clickhouse.create_distributed_local_table", "macro.dbt_clickhouse.create_empty_table_from_relation", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt_clickhouse.create_distributed_table", "macro.dbt_clickhouse.clickhouse__insert_into", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0771382, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.create_distributed_table": {"name": "create_distributed_table", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/distributed_table.sql", "original_file_path": "macros/materializations/distributed_table.sql", "unique_id": "macro.dbt_clickhouse.create_distributed_table", "macro_sql": "{% macro create_distributed_table(relation, local_relation) %}\n {%- set cluster = adapter.get_clickhouse_cluster_name() -%}\n {% if cluster is none %}\n {% do exceptions.raise_compiler_error('Cluster name should be defined for using distributed materializations, current is None') %}\n {% endif %}\n\n {%- set cluster = cluster[1:-1] -%}\n {%- set sharding = config.get('sharding_key') -%}\n\n create table {{ relation }} {{ on_cluster_clause(relation) }} as {{ local_relation }}\n ENGINE = Distributed('{{ cluster}}', '{{ relation.schema }}', '{{ local_relation.name }}'\n {%- if sharding is not none and sharding.strip() != '' -%}\n , {{ sharding }}\n {%- else %}\n , rand()\n {% endif -%}\n )\n {% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0787156, "supported_languages": null}, "macro.dbt_clickhouse.create_empty_table_from_relation": {"name": "create_empty_table_from_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/distributed_table.sql", "original_file_path": "macros/materializations/distributed_table.sql", "unique_id": "macro.dbt_clickhouse.create_empty_table_from_relation", "macro_sql": "{% macro create_empty_table_from_relation(relation, source_relation) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n {%- set columns = adapter.get_columns_in_relation(source_relation) | list -%}\n\n {%- set col_list = [] -%}\n {% for col in columns %}\n {{col_list.append(col.name + ' ' + col.data_type) or '' }}\n {% endfor %}\n {{ sql_header if sql_header is not none }}\n\n create table {{ relation.include(database=False) }}\n {{ on_cluster_clause(relation) }} (\n {{col_list | join(', ')}}\n )\n\n {{ engine_clause() }}\n {{ order_cols(label=\"order by\") }}\n {{ primary_key_clause(label=\"primary key\") }}\n {{ partition_cols(label=\"partition by\") }}\n {{ adapter.get_model_settings(model) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt_clickhouse.engine_clause", "macro.dbt_clickhouse.order_cols", "macro.dbt_clickhouse.primary_key_clause", "macro.dbt_clickhouse.partition_cols"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0805264, "supported_languages": null}, "macro.dbt_clickhouse.create_distributed_local_table": {"name": "create_distributed_local_table", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/distributed_table.sql", "original_file_path": "macros/materializations/distributed_table.sql", "unique_id": "macro.dbt_clickhouse.create_distributed_local_table", "macro_sql": "{% macro create_distributed_local_table(distributed_relation, shard_relation, structure_relation, sql_query=none) -%}\n {{ drop_relation_if_exists(shard_relation) }}\n {{ drop_relation_if_exists(distributed_relation) }}\n {% do run_query(create_empty_table_from_relation(shard_relation, structure_relation)) or '' %}\n {% do run_query(create_distributed_table(distributed_relation, shard_relation)) or '' %}\n {% if sql_query is not none %}\n {% do run_query(clickhouse__insert_into(distributed_relation, sql_query)) or '' %}\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt.run_query", "macro.dbt_clickhouse.create_empty_table_from_relation", "macro.dbt_clickhouse.create_distributed_table", "macro.dbt_clickhouse.clickhouse__insert_into"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.081699, "supported_languages": null}, "macro.dbt_clickhouse.materialization_view_clickhouse": {"name": "materialization_view_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "unique_id": "macro.dbt_clickhouse.materialization_view_clickhouse", "macro_sql": "{%- materialization view, adapter='clickhouse' -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set backup_relation = none -%}\n {%- set preexisting_backup_relation = none -%}\n {%- set preexisting_intermediate_relation = none -%}\n\n {% if existing_relation is not none %}\n {%- set backup_relation_type = existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {% if not existing_relation.can_exchange %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n {% endif %}\n {% endif %}\n\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if backup_relation is none %}\n {{ log('Creating new relation ' + target_relation.name )}}\n -- There is not existing relation, so we can just create\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n {% elif existing_relation.can_exchange %}\n -- We can do an atomic exchange, so no need for an intermediate\n {% call statement('main') -%}\n {{ get_create_view_as_sql(backup_relation, sql) }}\n {%- endcall %}\n {% do exchange_tables_atomic(backup_relation, existing_relation) %}\n {% else %}\n -- We have to use an intermediate and rename accordingly\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n {% endif %}\n\n -- cleanup\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_backup_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0893276, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.clickhouse__create_view_as": {"name": "clickhouse__create_view_as", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_view_as", "macro_sql": "{% macro clickhouse__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n {{ sql_header if sql_header is not none }}\n\n create view {{ relation.include(database=False) }} {{ on_cluster_clause(relation)}}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced %}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n as (\n {{ sql }}\n )\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.090413, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__load_csv_rows": {"name": "clickhouse__load_csv_rows", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__load_csv_rows", "macro_sql": "{% macro clickhouse__load_csv_rows(model, agate_table) %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set data_sql = adapter.get_csv_data(agate_table) %}\n\n {% set sql -%}\n insert into {{ this.render() }} ({{ cols_sql }})\n {{ adapter.get_model_query_settings(model) }}\n format CSV\n {{ data_sql }}\n {%- endset %}\n\n {% do adapter.add_query(sql, bindings=agate_table, abridge_sql_log=True) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_seed_column_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0925858, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__create_csv_table": {"name": "clickhouse__create_csv_table", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/seed.sql", "original_file_path": "macros/materializations/seed.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_csv_table", "macro_sql": "{% macro clickhouse__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} {{ on_cluster_clause(this) }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {{ engine_clause() }}\n {{ order_cols(label='order by') }}\n {{ partition_cols(label='partition by') }}\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt_clickhouse.engine_clause", "macro.dbt_clickhouse.order_cols", "macro.dbt_clickhouse.partition_cols", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.0948215, "supported_languages": null}, "macro.dbt_clickhouse.materialization_table_clickhouse": {"name": "materialization_table_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.materialization_table_clickhouse", "macro_sql": "{% materialization table, adapter='clickhouse' %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set backup_relation = none -%}\n {%- set preexisting_backup_relation = none -%}\n {%- set preexisting_intermediate_relation = none -%}\n\n {% if existing_relation is not none %}\n {%- set backup_relation_type = existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {% if not existing_relation.can_exchange %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n {% endif %}\n {% endif %}\n\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if backup_relation is none %}\n {{ log('Creating new relation ' + target_relation.name )}}\n -- There is not existing relation, so we can just create\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, target_relation, sql) }}\n {%- endcall %}\n {% elif existing_relation.can_exchange %}\n -- We can do an atomic exchange, so no need for an intermediate\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, backup_relation, sql) }}\n {%- endcall %}\n {% do exchange_tables_atomic(backup_relation, existing_relation) %}\n {% else %}\n -- We have to use an intermediate and rename accordingly\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n {% endif %}\n\n -- cleanup\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_backup_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1082826, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.engine_clause": {"name": "engine_clause", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.engine_clause", "macro_sql": "{% macro engine_clause() %}\n engine = {{ config.get('engine', default='MergeTree()') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1086466, "supported_languages": null}, "macro.dbt_clickhouse.partition_cols": {"name": "partition_cols", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.partition_cols", "macro_sql": "{% macro partition_cols(label) %}\n {%- set cols = config.get('partition_by', validator=validation.any[list, basestring]) -%}\n {%- if cols is not none %}\n {%- if cols is string -%}\n {%- set cols = [cols] -%}\n {%- endif -%}\n {{ label }} (\n {%- for item in cols -%}\n {{ item }}\n {%- if not loop.last -%},{%- endif -%}\n {%- endfor -%}\n )\n {%- endif %}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1097531, "supported_languages": null}, "macro.dbt_clickhouse.primary_key_clause": {"name": "primary_key_clause", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.primary_key_clause", "macro_sql": "{% macro primary_key_clause(label) %}\n {%- set primary_key = config.get('primary_key', validator=validation.any[basestring]) -%}\n\n {%- if primary_key is not none %}\n {{ label }} {{ primary_key }}\n {%- endif %}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1103714, "supported_languages": null}, "macro.dbt_clickhouse.order_cols": {"name": "order_cols", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.order_cols", "macro_sql": "{% macro order_cols(label) %}\n {%- set cols = config.get('order_by', validator=validation.any[list, basestring]) -%}\n {%- set engine = config.get('engine', default='MergeTree()') -%}\n {%- set supported = [\n 'HDFS',\n 'MaterializedPostgreSQL',\n 'S3',\n 'EmbeddedRocksDB',\n 'Hive'\n ] -%}\n\n {%- if 'MergeTree' in engine or engine in supported %}\n {%- if cols is not none %}\n {%- if cols is string -%}\n {%- set cols = [cols] -%}\n {%- endif -%}\n {{ label }} (\n {%- for item in cols -%}\n {{ item }}\n {%- if not loop.last -%},{%- endif -%}\n {%- endfor -%}\n )\n {%- else %}\n {{ label }} (tuple())\n {%- endif %}\n {%- endif %}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1120872, "supported_languages": null}, "macro.dbt_clickhouse.on_cluster_clause": {"name": "on_cluster_clause", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.on_cluster_clause", "macro_sql": "{% macro on_cluster_clause(relation, force_sync) %}\n {% set active_cluster = adapter.get_clickhouse_cluster_name() %}\n {%- if active_cluster is not none and relation.should_on_cluster %}\n {# Add trailing whitespace to avoid problems when this clause is not last #}\n ON CLUSTER {{ active_cluster + ' ' }}\n {%- if force_sync %}\n SYNC\n {%- endif %}\n {%- endif %}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1127677, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__create_table_as": {"name": "clickhouse__create_table_as", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_table_as", "macro_sql": "{% macro clickhouse__create_table_as(temporary, relation, sql) -%}\n {% set has_contract = config.get('contract').enforced %}\n {% set create_table = create_table_or_empty(temporary, relation, sql, has_contract) %}\n {% if adapter.is_before_version('22.7.1.2484') -%}\n {{ create_table }}\n {%- else %}\n {% call statement('create_table_empty') %}\n {{ create_table }}\n {% endcall %}\n {{ clickhouse__insert_into(relation, sql, has_contract) }}\n {%- endif %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.create_table_or_empty", "macro.dbt.statement", "macro.dbt_clickhouse.clickhouse__insert_into"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1138914, "supported_languages": null}, "macro.dbt_clickhouse.create_table_or_empty": {"name": "create_table_or_empty", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.create_table_or_empty", "macro_sql": "{% macro create_table_or_empty(temporary, relation, sql, has_contract) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n {% if temporary -%}\n create temporary table {{ relation }}\n engine Memory\n {{ order_cols(label=\"order by\") }}\n {{ partition_cols(label=\"partition by\") }}\n {{ adapter.get_model_settings(model) }}\n as (\n {{ sql }}\n )\n {%- else %}\n create table {{ relation }}\n {{ on_cluster_clause(relation)}}\n {%- if has_contract%}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {%- endif %}\n {{ engine_clause() }}\n {{ order_cols(label=\"order by\") }}\n {{ primary_key_clause(label=\"primary key\") }}\n {{ partition_cols(label=\"partition by\") }}\n {{ adapter.get_model_settings(model) }}\n\n {%- if not has_contract %}\n {%- if not adapter.is_before_version('22.7.1.2484') %}\n empty\n {%- endif %}\n as (\n {{ sql }}\n )\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.order_cols", "macro.dbt_clickhouse.partition_cols", "macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt_clickhouse.engine_clause", "macro.dbt_clickhouse.primary_key_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1160083, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__insert_into": {"name": "clickhouse__insert_into", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__insert_into", "macro_sql": "{% macro clickhouse__insert_into(target_relation, sql, has_contract) %}\n {%- set dest_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') -%}\n\n insert into {{ target_relation }}\n ({{ dest_cols_csv }})\n {%- if has_contract -%}\n -- Use a subquery to get columns in the right order\n SELECT {{ dest_cols_csv }} FROM ( {{ sql }} )\n {%- else -%}\n {{ sql }}\n {{ adapter.get_model_query_settings(model) }}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1171095, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__snapshot_hash_arguments": {"name": "clickhouse__snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__snapshot_hash_arguments", "macro_sql": "{% macro clickhouse__snapshot_hash_arguments(args) -%}\n halfMD5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1214464, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__post_snapshot": {"name": "clickhouse__post_snapshot", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__post_snapshot", "macro_sql": "{% macro clickhouse__post_snapshot(staging_relation) %}\n {{ drop_relation_if_exists(staging_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1217244, "supported_languages": null}, "macro.dbt_clickhouse.build_snapshot_staging_table": {"name": "build_snapshot_staging_table", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_clickhouse.build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(False, tmp_relation, select) }}\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1226513, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__snapshot_merge_sql": {"name": "clickhouse__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/snapshot.sql", "original_file_path": "macros/materializations/snapshot.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__snapshot_merge_sql", "macro_sql": "{% macro clickhouse__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n {%- set valid_to_col = adapter.quote('dbt_valid_to') -%}\n\n {%- set upsert = target.derivative('__snapshot_upsert') -%}\n {% call statement('create_upsert_relation') %}\n create table if not exists {{ upsert }} as {{ target }}\n {% endcall %}\n\n {% call statement('insert_unchanged_data') %}\n insert into {{ upsert }} ({{ insert_cols_csv }})\n select {% for column in insert_cols -%}\n {{ column }} {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n from {{ target }}\n where dbt_scd_id not in (\n select {{ source }}.dbt_scd_id from {{ source }} \n )\n {% endcall %}\n\n {% call statement('insert_updated_and_deleted') %}\n insert into {{ upsert }} ({{ insert_cols_csv }})\n with updates_and_deletes as (\n select\n dbt_scd_id,\n dbt_valid_to\n from {{ source }}\n where dbt_change_type IN ('update', 'delete')\n )\n select {% for column in insert_cols %}\n {%- if column == valid_to_col -%}\n updates_and_deletes.dbt_valid_to as dbt_valid_to\n {%- else -%}\n target.{{ column }} as {{ column }}\n {%- endif %} {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n from {{ target }} target\n join updates_and_deletes on target.dbt_scd_id = updates_and_deletes.dbt_scd_id;\n {% endcall %}\n\n {% call statement('insert_new') %}\n insert into {{ upsert }} ({{ insert_cols_csv }})\n select {% for column in insert_cols -%}\n {{ column }} {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n from {{ source }}\n where {{ source }}.dbt_change_type IN ('insert');\n {% endcall %}\n\n {% if target.can_exchange %}\n {% do exchange_tables_atomic(upsert, target) %}\n {% call statement('drop_exchanged_relation') %}\n drop table if exists {{ upsert }};\n {% endcall %}\n {% else %}\n {% call statement('drop_target_relation') %}\n drop table if exists {{ target }};\n {% endcall %}\n {% call statement('rename_upsert_relation') %}\n rename table {{ upsert }} to {{ target }};\n {% endcall %}\n {% endif %}\n\n {% do return ('select 1') %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_clickhouse.exchange_tables_atomic"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1264524, "supported_languages": null}, "macro.dbt_clickhouse.materialization_materialized_view_clickhouse": {"name": "materialization_materialized_view_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/materialized_view.sql", "original_file_path": "macros/materializations/materialized_view.sql", "unique_id": "macro.dbt_clickhouse.materialization_materialized_view_clickhouse", "macro_sql": "\n{%- materialization materialized_view, adapter='clickhouse' -%}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set mv_relation = target_relation.derivative('_mv', 'MaterializedView') -%}\n {%- set cluster_clause = on_cluster_clause(target_relation) -%}\n\n {# look for an existing relation for the target table and create backup relations if necessary #}\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set backup_relation = none -%}\n {%- set preexisting_backup_relation = none -%}\n {%- set preexisting_intermediate_relation = none -%}\n {% if existing_relation is not none %}\n {%- set backup_relation_type = existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {% if not existing_relation.can_exchange %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n {% endif %}\n {% endif %}\n\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if backup_relation is none %}\n {{ log('Creating new materialized view ' + target_relation.name )}}\n {% call statement('main') -%}\n {{ clickhouse__get_create_materialized_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n {% elif existing_relation.can_exchange %}\n {{ log('Replacing existing materialized view' + target_relation.name) }}\n {% call statement('drop existing materialized view') %}\n drop view if exists {{ mv_relation }} {{ cluster_clause }}\n {% endcall %}\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, backup_relation, sql) }}\n {%- endcall %}\n {% do exchange_tables_atomic(backup_relation, existing_relation) %}\n {% call statement('create new materialized view') %}\n {{ clickhouse__create_mv_sql(mv_relation, existing_relation.name, cluster_clause, sql) }}\n {% endcall %}\n {% else %}\n {{ log('Replacing existing materialized view' + target_relation.name) }}\n {{ clickhouse__replace_mv(target_relation, existing_relation, intermediate_relation, backup_relation, sql) }}\n {% endif %}\n\n -- cleanup\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation, mv_relation]}) }}\n\n{%- endmaterialization -%}\n\n\n", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.load_cached_relation", "macro.dbt.make_backup_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt_clickhouse.clickhouse__get_create_materialized_view_as_sql", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt_clickhouse.clickhouse__create_mv_sql", "macro.dbt_clickhouse.clickhouse__replace_mv", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1350126, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.clickhouse__get_create_materialized_view_as_sql": {"name": "clickhouse__get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/materialized_view.sql", "original_file_path": "macros/materializations/materialized_view.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_create_materialized_view_as_sql", "macro_sql": "{% macro clickhouse__get_create_materialized_view_as_sql(relation, sql) -%}\n {% call statement('create_target_table') %}\n {{ get_create_table_as_sql(False, relation, sql) }}\n {% endcall %}\n {%- set cluster_clause = on_cluster_clause(relation) -%}\n {%- set mv_relation = relation.derivative('_mv', 'MaterializedView') -%}\n {{ clickhouse__create_mv_sql(mv_relation, relation, cluster_clause, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.on_cluster_clause", "macro.dbt_clickhouse.clickhouse__create_mv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1360657, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__create_mv_sql": {"name": "clickhouse__create_mv_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/materialized_view.sql", "original_file_path": "macros/materializations/materialized_view.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__create_mv_sql", "macro_sql": "{% macro clickhouse__create_mv_sql(mv_relation, target_table, cluster_clause, sql) -%}\n create materialized view if not exists {{ mv_relation }} {{ cluster_clause }}\n to {{ target_table }}\n as {{ sql }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1364806, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__replace_mv": {"name": "clickhouse__replace_mv", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/materialized_view.sql", "original_file_path": "macros/materializations/materialized_view.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__replace_mv", "macro_sql": "{% macro clickhouse__replace_mv(target_relation, existing_relation, intermediate_relation, backup_relation, sql) %}\n {# drop existing materialized view while we recreate the target table #}\n {%- set cluster_clause = on_cluster_clause(target_relation) -%}\n {%- set mv_relation = target_relation.derivative('_mv', 'MaterializedView') -%}\n {% call statement('drop existing mv') -%}\n drop view if exists {{ mv_relation }} {{ cluster_clause }}\n {%- endcall %}\n\n {# recreate the target table #}\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {# now that the target table is recreated, we can finally create our new view #}\n {{ clickhouse__create_mv_sql(mv_relation, target_relation, cluster_clause, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.clickhouse__create_mv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.138001, "supported_languages": null}, "macro.dbt_clickhouse.materialization_distributed_incremental_clickhouse": {"name": "materialization_distributed_incremental_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/distributed_incremental.sql", "original_file_path": "macros/materializations/incremental/distributed_incremental.sql", "unique_id": "macro.dbt_clickhouse.materialization_distributed_incremental_clickhouse", "macro_sql": "{% materialization distributed_incremental, adapter='clickhouse' %}\n {% set insert_distributed_sync = run_query(\"SELECT value FROM system.settings WHERE name = 'insert_distributed_sync'\")[0][0] %}\n {% if insert_distributed_sync != '1' %}\n {% do exceptions.raise_compiler_error('To use distributed materialization setting insert_distributed_sync should be set to 1') %}\n {% endif %}\n\n {%- set local_suffix = adapter.get_clickhouse_local_suffix() -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n\n {% set on_cluster = on_cluster_clause(target_relation) %}\n {% if on_cluster.strip() == '' %}\n {% do exceptions.raise_compiler_error('To use distributed materializations cluster setting in dbt profile must be set') %}\n {% endif %}\n\n {% set existing_relation_local = existing_relation.incorporate(path={\"identifier\": this.identifier + local_suffix}) if existing_relation is not none else none %}\n {% set target_relation_local = target_relation.incorporate(path={\"identifier\": this.identifier + local_suffix}) if target_relation is not none else none %}\n\n {%- set unique_key = config.get('unique_key') -%}\n {% if unique_key is not none and unique_key|length == 0 %}\n {% set unique_key = none %}\n {% endif %}\n {% if unique_key is iterable and (unique_key is not string and unique_key is not mapping) %}\n {% set unique_key = unique_key|join(', ') %}\n {% endif %}\n {%- set inserts_only = config.get('inserts_only') -%}\n {%- set grant_config = config.get('grants') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n {%- set intermediate_relation = make_intermediate_relation(target_relation_local)-%}\n {%- set distributed_intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation_local, backup_relation_type) -%}\n {%- set distributed_backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n {%- set view_relation = default__make_temp_relation(target_relation, '__dbt_view_tmp') -%}\n\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(view_relation) }}\n {{ drop_relation_if_exists(distributed_intermediate_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n {% set to_drop = [] %}\n {% set schema_changes = none %}\n\n {% call statement('main') %}\n {{ create_view_as(view_relation, sql) }}\n {% endcall %}\n\n {% if existing_relation is none %}\n -- No existing table, simply create a new one\n {{ create_distributed_local_table(target_relation, target_relation_local, view_relation, sql) }}\n\n {% elif full_refresh_mode %}\n -- Completely replacing the old table, so create a temporary table and then swap it\n {{ create_distributed_local_table(distributed_intermediate_relation, intermediate_relation, view_relation, sql) }}\n {% do adapter.drop_relation(distributed_intermediate_relation) or '' %}\n {% set need_swap = true %}\n\n {% elif inserts_only or unique_key is none -%}\n -- There are no updates/deletes or duplicate keys are allowed. Simply add all of the new rows to the existing\n -- table. It is the user's responsibility to avoid duplicates. Note that \"inserts_only\" is a ClickHouse adapter\n -- specific configurable that is used to avoid creating an expensive intermediate table.\n {% call statement('main') %}\n {{ clickhouse__insert_into(target_relation, sql) }}\n {% endcall %}\n\n {% else %}\n {% set incremental_strategy = adapter.calculate_incremental_strategy(config.get('incremental_strategy')) %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% if on_schema_change != 'ignore' %}\n {%- set schema_changes = check_for_schema_changes(existing_relation, target_relation) -%}\n {% if schema_changes['schema_changed'] and incremental_strategy in ('append', 'delete_insert') %}\n {% set incremental_strategy = 'legacy' %}\n {% do log('Schema changes detected, switching to legacy incremental strategy') %}\n {% endif %}\n {% endif %}\n {% if incremental_strategy != 'delete_insert' and incremental_predicates %}\n {% do exceptions.raise_compiler_error('Cannot apply incremental predicates with ' + incremental_strategy + ' strategy.') %}\n {% endif %}\n {% if incremental_strategy == 'legacy' %}\n {% do clickhouse__incremental_legacy(existing_relation, intermediate_relation, schema_changes, unique_key, True) %}\n {% set need_swap = true %}\n {% elif incremental_strategy == 'delete_insert' %}\n {% do clickhouse__incremental_delete_insert(existing_relation, unique_key, incremental_predicates, True) %}\n {% elif incremental_strategy == 'append' %}\n {% call statement('main') %}\n {{ clickhouse__insert_into(target_relation, sql) }}\n {% endcall %}\n {% endif %}\n {% endif %}\n\n {% if need_swap %}\n {% if False %}\n {% do adapter.rename_relation(intermediate_relation, backup_relation) %}\n {% do exchange_tables_atomic(backup_relation, target_relation_local) %}\n {% else %}\n {% do adapter.rename_relation(target_relation_local, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation_local) %}\n {% endif %}\n\n -- Structure could have changed, need to update distributed table from replaced local table\n {% set target_relation_new = target_relation.incorporate(path={\"identifier\": target_relation.identifier + '_temp'}) %}\n {{ drop_relation_if_exists(target_relation_new) }}\n {% do run_query(create_distributed_table(target_relation_new, target_relation_local)) %}\n\n {% if False %}\n {% do adapter.rename_relation(target_relation_new, distributed_backup_relation) %}\n {% do exchange_tables_atomic(distributed_backup_relation, target_relation) %}\n {% else %}\n {% do adapter.rename_relation(target_relation, distributed_backup_relation) %}\n {% do adapter.rename_relation(target_relation_new, target_relation) %}\n {% endif %}\n\n {% do to_drop.append(backup_relation) %}\n {% do to_drop.append(distributed_backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n {% do apply_grants(target_relation_local, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.load_cached_relation", "macro.dbt_clickhouse.on_cluster_clause", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.default__make_temp_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.create_view_as", "macro.dbt_clickhouse.create_distributed_local_table", "macro.dbt_clickhouse.clickhouse__insert_into", "macro.dbt.check_for_schema_changes", "macro.dbt_clickhouse.clickhouse__incremental_legacy", "macro.dbt_clickhouse.clickhouse__incremental_delete_insert", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt_clickhouse.create_distributed_table", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1640723, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.is_incremental": {"name": "is_incremental", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/is_incremental.sql", "original_file_path": "macros/materializations/incremental/is_incremental.sql", "unique_id": "macro.dbt_clickhouse.is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and (model.config.materialized == 'incremental' or model.config.materialized == 'distributed_incremental' )\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.1655862, "supported_languages": null}, "macro.dbt_clickhouse.materialization_incremental_clickhouse": {"name": "materialization_incremental_clickhouse", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/incremental.sql", "original_file_path": "macros/materializations/incremental/incremental.sql", "unique_id": "macro.dbt_clickhouse.materialization_incremental_clickhouse", "macro_sql": "{% materialization incremental, adapter='clickhouse' %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n\n {%- set unique_key = config.get('unique_key') -%}\n {% if unique_key is not none and unique_key|length == 0 %}\n {% set unique_key = none %}\n {% endif %}\n {% if unique_key is iterable and (unique_key is not string and unique_key is not mapping) %}\n {% set unique_key = unique_key|join(', ') %}\n {% endif %}\n {%- set inserts_only = config.get('inserts_only') -%}\n {%- set grant_config = config.get('grants') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n -- No existing table, simply create a new one\n {% call statement('main') %}\n {{ get_create_table_as_sql(False, target_relation, sql) }}\n {% endcall %}\n\n {% elif full_refresh_mode %}\n -- Completely replacing the old table, so create a temporary table and then swap it\n {% call statement('main') %}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {% endcall %}\n {% set need_swap = true %}\n\n {% elif inserts_only or unique_key is none -%}\n -- There are no updates/deletes or duplicate keys are allowed. Simply add all of the new rows to the existing\n -- table. It is the user's responsibility to avoid duplicates. Note that \"inserts_only\" is a ClickHouse adapter\n -- specific configurable that is used to avoid creating an expensive intermediate table.\n {% call statement('main') %}\n {{ clickhouse__insert_into(target_relation, sql) }}\n {% endcall %}\n\n {% else %}\n {% set column_changes = none %}\n {% set incremental_strategy = adapter.calculate_incremental_strategy(config.get('incremental_strategy')) %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {%- if on_schema_change != 'ignore' %}\n {%- set column_changes = adapter.check_incremental_schema_changes(on_schema_change, existing_relation, sql) -%}\n {%- if column_changes %}\n {%- if incremental_strategy in ('append', 'delete_insert') %}\n {% set incremental_strategy = 'legacy' %}\n {{ log('Schema changes detected, switching to legacy incremental strategy') }}\n {%- endif %}\n {% endif %}\n {% endif %}\n {% if incremental_strategy != 'delete_insert' and incremental_predicates %}\n {% do exceptions.raise_compiler_error('Cannot apply incremental predicates with ' + incremental_strategy + ' strategy.') %}\n {% endif %}\n {% if incremental_strategy == 'legacy' %}\n {% do clickhouse__incremental_legacy(existing_relation, intermediate_relation, column_changes, unique_key) %}\n {% set need_swap = true %}\n {% elif incremental_strategy == 'delete_insert' %}\n {% do clickhouse__incremental_delete_insert(existing_relation, unique_key, incremental_predicates) %}\n {% elif incremental_strategy == 'append' %}\n {% call statement('main') %}\n {{ clickhouse__insert_into(target_relation, sql) }}\n {% endcall %}\n {% endif %}\n {% endif %}\n\n {% if need_swap %}\n {% if existing_relation.can_exchange %}\n {% do adapter.rename_relation(intermediate_relation, backup_relation) %}\n {% do exchange_tables_atomic(backup_relation, target_relation) %}\n {% else %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% endif %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.clickhouse__insert_into", "macro.dbt_clickhouse.clickhouse__incremental_legacy", "macro.dbt_clickhouse.clickhouse__incremental_delete_insert", "macro.dbt_clickhouse.exchange_tables_atomic", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2134905, "supported_languages": ["sql"]}, "macro.dbt_clickhouse.clickhouse__incremental_legacy": {"name": "clickhouse__incremental_legacy", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/incremental.sql", "original_file_path": "macros/materializations/incremental/incremental.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__incremental_legacy", "macro_sql": "{% macro clickhouse__incremental_legacy(existing_relation, intermediate_relation, column_changes, unique_key, is_distributed=False) %}\n {% set new_data_relation = existing_relation.incorporate(path={\"identifier\": existing_relation.identifier + '__dbt_new_data'}) %}\n {{ drop_relation_if_exists(new_data_relation) }}\n\n {%- set inserted_relation = intermediate_relation -%}\n {%- set inserting_relation = new_data_relation -%}\n\n -- First create a temporary table for all of the new data\n {% if is_distributed %}\n {% if column_changes %}\n {% do exceptions.raise_compiler_error('Schema changes not supported with Distributed tables ') %}\n {% endif %}\n -- Need to use distributed table to have data on all shards\n {%- set distributed_new_data_relation = existing_relation.incorporate(path={\"identifier\": existing_relation.identifier + '__dbt_distributed_new_data'}) -%}\n {%- set inserting_relation = distributed_new_data_relation -%}\n {{ create_distributed_local_table(distributed_new_data_relation, new_data_relation, existing_relation, sql) }}\n {% elif column_changes %}\n {% call statement('create_new_data_temp') %}\n {{ get_create_table_as_sql(False, new_data_relation, sql) }}\n {% endcall %}\n {% else %}\n {% call statement('create_new_data_temp') %}\n {{ get_create_table_as_sql(False, new_data_relation, sql) }}\n {% endcall %}\n {% endif %}\n\n -- Next create another temporary table that will eventually be used to replace the existing table. We can't\n -- use the table just created in the previous step because we don't want to override any updated rows with\n -- old rows when we insert the old data\n {% if is_distributed %}\n {%- set distributed_intermediate_relation = make_intermediate_relation(existing_relation) -%}\n {%- set inserted_relation = distributed_intermediate_relation -%}\n {{ create_distributed_local_table(distributed_intermediate_relation, intermediate_relation, existing_relation) }}\n {% else %}\n {% call statement('main') %}\n create table {{ intermediate_relation }} {{ on_cluster_clause(existing_relation) }} as {{ new_data_relation }}\n {% endcall %}\n {% endif %}\n\n -- Insert all the existing rows into the new temporary table, ignoring any rows that have keys in the \"new data\"\n -- table.\n {%- set source_columns = adapter.get_columns_in_relation(existing_relation) -%}\n {%- set source_columns_csv = source_columns | map(attribute='quoted') | join(', ') -%}\n {% call statement('insert_existing_data') %}\n insert into {{ inserted_relation }} ({{ source_columns_csv }})\n select {{ source_columns_csv }}\n from {{ existing_relation }}\n where ({{ unique_key }}) not in (\n select {{ unique_key }}\n from {{ inserting_relation }}\n )\n {{ adapter.get_model_query_settings(model) }}\n {% endcall %}\n\n -- Insert all of the new data into the temporary table\n {% if column_changes %}\n {%- set dest_columns = adapter.get_columns_in_relation(new_data_relation) -%}\n {%- set dest_columns_csv = dest_columns | map(attribute='quoted') | join(', ') -%}\n {% else %}\n {%- set dest_columns_csv = source_columns_csv %}\n {% endif %}\n {% call statement('insert_new_data') %}\n insert into {{ inserted_relation }} ({{ dest_columns_csv }})\n select {{ dest_columns_csv }}\n from {{ inserting_relation }}\n {{ adapter.get_model_query_settings(model) }}\n {% endcall %}\n\n {% do adapter.drop_relation(new_data_relation) %}\n {% if is_distributed %}\n {{ drop_relation_if_exists(distributed_new_data_relation) }}\n {{ drop_relation_if_exists(distributed_intermediate_relation) }}\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt_clickhouse.create_distributed_local_table", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.make_intermediate_relation", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2188785, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__incremental_delete_insert": {"name": "clickhouse__incremental_delete_insert", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/materializations/incremental/incremental.sql", "original_file_path": "macros/materializations/incremental/incremental.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__incremental_delete_insert", "macro_sql": "{% macro clickhouse__incremental_delete_insert(existing_relation, unique_key, incremental_predicates, is_distributed=False) %}\n {% set new_data_relation = existing_relation.incorporate(path={\"identifier\": existing_relation.identifier\n + '__dbt_new_data_' + invocation_id.replace('-', '_')}) %}\n {{ drop_relation_if_exists(new_data_relation) }}\n {%- set distributed_new_data_relation = existing_relation.incorporate(path={\"identifier\": existing_relation.identifier + '__dbt_distributed_new_data'}) -%}\n\n {%- set inserting_relation = new_data_relation -%}\n\n {% if is_distributed %}\n -- Need to use distributed table to have data on all shards\n {%- set inserting_relation = distributed_new_data_relation -%}\n {{ create_distributed_local_table(distributed_new_data_relation, new_data_relation, existing_relation, sql) }}\n {% else %}\n {% call statement('main') %}\n {{ get_create_table_as_sql(False, new_data_relation, sql) }}\n {% endcall %}\n {% endif %}\n\n {% call statement('delete_existing_data') %}\n {% if is_distributed %}\n {%- set existing_local = existing_relation.derivative(adapter.get_clickhouse_local_suffix()) %}\n delete from {{ existing_local }} {{ on_cluster_clause(existing_relation) }} where ({{ unique_key }}) in (select {{ unique_key }}\n from {{ inserting_relation }})\n {% else %}\n delete from {{ existing_relation }} where ({{ unique_key }}) in (select {{ unique_key }}\n from {{ inserting_relation }})\n {% endif %}\n {%- if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {%- endif -%}\n {{ adapter.get_model_query_settings(model) }}\n {% endcall %}\n\n {%- set dest_columns = adapter.get_columns_in_relation(existing_relation) -%}\n {%- set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') -%}\n {% call statement('insert_new_data') %}\n insert into {{ existing_relation }} {{ adapter.get_model_query_settings(model) }} select {{ dest_cols_csv }} from {{ inserting_relation }}\n {% endcall %}\n {% do adapter.drop_relation(new_data_relation) %}\n {{ drop_relation_if_exists(distributed_new_data_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.drop_relation_if_exists", "macro.dbt_clickhouse.create_distributed_local_table", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2227907, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__current_timestamp": {"name": "clickhouse__current_timestamp", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__current_timestamp", "macro_sql": "{% macro clickhouse__current_timestamp() -%}\n now()\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2231379, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__snapshot_string_as_time": {"name": "clickhouse__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/timestamps.sql", "original_file_path": "macros/utils/timestamps.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__snapshot_string_as_time", "macro_sql": "{% macro clickhouse__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"toDateTime('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2235274, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__any_value": {"name": "clickhouse__any_value", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__any_value", "macro_sql": "{% macro clickhouse__any_value(expression) -%}\n any({{ expression }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2251747, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__bool_or": {"name": "clickhouse__bool_or", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__bool_or", "macro_sql": "{% macro clickhouse__bool_or(expression) -%}\n any({{ expression }}) > 0\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2254102, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__cast_bool_to_text": {"name": "clickhouse__cast_bool_to_text", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__cast_bool_to_text", "macro_sql": "{% macro clickhouse__cast_bool_to_text(field) %}\n multiIf({{ field }} > 0, 'true', {{ field }} = 0, 'false', NULL)\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2256773, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__hash": {"name": "clickhouse__hash", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__hash", "macro_sql": "{% macro clickhouse__hash(field) -%}\n lower(hex(MD5(toString({{ field }} ))))\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2259018, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__last_day": {"name": "clickhouse__last_day", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__last_day", "macro_sql": "\n\n\n{%- macro clickhouse__last_day(date, datepart) -%}\n {{ dbt.dateadd('day', '-1', dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date)))}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2264328, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__split_part": {"name": "clickhouse__split_part", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__split_part", "macro_sql": "{% macro clickhouse__split_part(string_text, delimiter_text, part_number) %}\n splitByChar('{{delimiter_text}}', {{ string_text }})[{{ part_number }}]\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2267778, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__replace": {"name": "clickhouse__replace", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__replace", "macro_sql": "{% macro clickhouse__replace(field, old_chars, new_chars) %}\n replaceAll({{ field }},'{{ old_chars }}','{{ new_chars }}')\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2271242, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__listagg": {"name": "clickhouse__listagg", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__listagg", "macro_sql": "{% macro clickhouse__listagg(measure, delimiter_text, order_by_clause, limit_num) %}\n {{ exceptions.raise_compiler_error(\n 'ClickHouse does not support the listagg function. See the groupArray function instead')\n }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2275953, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__array_construct": {"name": "clickhouse__array_construct", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__array_construct", "macro_sql": "{% macro clickhouse__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n [ {{ inputs|join(' , ') }} ]\n {% else %}\n emptyArray{{data_type}}()\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.228472, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__array_append": {"name": "clickhouse__array_append", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__array_append", "macro_sql": "{% macro clickhouse__array_append(array, new_element) -%}\n arrayPushBack({{ array }}, {{ new_element }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.228998, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__array_concat": {"name": "clickhouse__array_concat", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/utils/utils.sql", "original_file_path": "macros/utils/utils.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__array_concat", "macro_sql": "{% macro clickhouse__array_concat(array_1, array_2) -%}\n arrayConcat({{ array_1 }}, {{ array_2 }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2295034, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_or_create_relation": {"name": "clickhouse__get_or_create_relation", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_or_create_relation", "macro_sql": "{% macro clickhouse__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set can_exchange = adapter.can_exchange(schema, type) %}\n {%- set should_on_cluster = adapter.should_on_cluster(config.get('materialized'), engine_clause()) %}\n {%- set new_relation = api.Relation.create(\n database=None,\n schema=schema,\n identifier=identifier,\n type=type,\n can_exchange=can_exchange,\n can_on_cluster=should_on_cluster\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.engine_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2329538, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_database": {"name": "clickhouse__get_database", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_database", "macro_sql": "{% macro clickhouse__get_database(database) %}\n {% call statement('get_database', fetch_result=True) %}\n select name, engine, comment\n from system.databases\n where name = '{{ database }}'\n {% endcall %}\n {% do return(load_result('get_database').table) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.233895, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_show_grant_sql": {"name": "clickhouse__get_show_grant_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_show_grant_sql", "macro_sql": "{% macro clickhouse__get_show_grant_sql(relation) %}\n SELECT access_type as privilege_type, COALESCE(user_name, role_name) as grantee from system.grants where table = '{{ relation.name }}'\n AND database = '{{ relation.schema }}'\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2352479, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__call_dcl_statements": {"name": "clickhouse__call_dcl_statements", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__call_dcl_statements", "macro_sql": "{% macro clickhouse__call_dcl_statements(dcl_statement_list) %}\n {% for dcl_statement in dcl_statement_list %}\n {% call statement('dcl') %}\n {{ dcl_statement }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2360463, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_grant_sql": {"name": "clickhouse__get_grant_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_grant_sql", "macro_sql": "\n\n\n{%- macro clickhouse__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ on_cluster_clause(relation)}} {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.236823, "supported_languages": null}, "macro.dbt_clickhouse.clickhouse__get_revoke_sql": {"name": "clickhouse__get_revoke_sql", "resource_type": "macro", "package_name": "dbt_clickhouse", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt_clickhouse.clickhouse__get_revoke_sql", "macro_sql": "{%- macro clickhouse__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ on_cluster_clause(relation)}} {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt_clickhouse.on_cluster_clause"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2376251, "supported_languages": null}, "macro.dbt.generate_schema_name": {"name": "generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name=none, node=none) -%}\n {{ return(adapter.dispatch('generate_schema_name', 'dbt')(custom_schema_name, node)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2391863, "supported_languages": null}, "macro.dbt.default__generate_schema_name": {"name": "default__generate_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.default__generate_schema_name", "macro_sql": "{% macro default__generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2400503, "supported_languages": null}, "macro.dbt.generate_schema_name_for_env": {"name": "generate_schema_name_for_env", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_schema.sql", "original_file_path": "macros/get_custom_name/get_custom_schema.sql", "unique_id": "macro.dbt.generate_schema_name_for_env", "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2406726, "supported_languages": null}, "macro.dbt.generate_database_name": {"name": "generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "unique_id": "macro.dbt.generate_database_name", "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name', 'dbt')(custom_database_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__generate_database_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.241458, "supported_languages": null}, "macro.dbt.default__generate_database_name": {"name": "default__generate_database_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_database.sql", "original_file_path": "macros/get_custom_name/get_custom_database.sql", "unique_id": "macro.dbt.default__generate_database_name", "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2419999, "supported_languages": null}, "macro.dbt.generate_alias_name": {"name": "generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "unique_id": "macro.dbt.generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_alias_name', 'dbt')(custom_alias_name, node)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_alias_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2427638, "supported_languages": null}, "macro.dbt.default__generate_alias_name": {"name": "default__generate_alias_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/get_custom_name/get_custom_alias.sql", "original_file_path": "macros/get_custom_name/get_custom_alias.sql", "unique_id": "macro.dbt.default__generate_alias_name", "macro_sql": "{% macro default__generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name -%}\n\n {{ custom_alias_name | trim }}\n\n {%- elif node.version -%}\n\n {{ return(node.name ~ \"_v\" ~ (node.version | replace(\".\", \"_\"))) }}\n\n {%- else -%}\n\n {{ node.name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2435513, "supported_languages": null}, "macro.dbt.convert_datetime": {"name": "convert_datetime", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.convert_datetime", "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.246479, "supported_languages": null}, "macro.dbt.dates_in_range": {"name": "dates_in_range", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.dates_in_range", "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partition start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.convert_datetime"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2489653, "supported_languages": null}, "macro.dbt.partition_range": {"name": "partition_range", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.partition_range", "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dates_in_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2505739, "supported_languages": null}, "macro.dbt.py_current_timestring": {"name": "py_current_timestring", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "unique_id": "macro.dbt.py_current_timestring", "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2510765, "supported_languages": null}, "macro.dbt.statement": {"name": "statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.statement", "macro_sql": "\n{%- macro statement(name=None, fetch_result=False, auto_begin=True, language='sql') -%}\n {%- if execute: -%}\n {%- set compiled_code = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime {} for node \"{}\"'.format(language, model['unique_id'])) }}\n {{ write(compiled_code) }}\n {%- endif -%}\n {%- if language == 'sql'-%}\n {%- set res, table = adapter.execute(compiled_code, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- elif language == 'python' -%}\n {%- set res = submit_python_job(model, compiled_code) -%}\n {#-- TODO: What should table be for python models? --#}\n {%- set table = None -%}\n {%- else -%}\n {% do exceptions.raise_compiler_error(\"statement macro didn't get supported language\") %}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2540853, "supported_languages": null}, "macro.dbt.noop_statement": {"name": "noop_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.noop_statement", "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2552853, "supported_languages": null}, "macro.dbt.run_query": {"name": "run_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/etc/statement.sql", "original_file_path": "macros/etc/statement.sql", "unique_id": "macro.dbt.run_query", "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2559, "supported_languages": null}, "macro.dbt.resolve_model_name": {"name": "resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.resolve_model_name", "macro_sql": "{% macro resolve_model_name(input_model_name) %}\n {{ return(adapter.dispatch('resolve_model_name', 'dbt')(input_model_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.258496, "supported_languages": null}, "macro.dbt.default__resolve_model_name": {"name": "default__resolve_model_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.default__resolve_model_name", "macro_sql": "\n\n{%- macro default__resolve_model_name(input_model_name) -%}\n {{ input_model_name | string | replace('\"', '\\\"') }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.258838, "supported_languages": null}, "macro.dbt.build_ref_function": {"name": "build_ref_function", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_ref_function", "macro_sql": "{% macro build_ref_function(model) %}\n\n {%- set ref_dict = {} -%}\n {%- for _ref in model.refs -%}\n {% set _ref_args = [_ref.get('package'), _ref['name']] if _ref.get('package') else [_ref['name'],] %}\n {%- set resolved = ref(*_ref_args, v=_ref.get('version')) -%}\n {%- if _ref.get('version') -%}\n {% do _ref_args.extend([\"v\" ~ _ref['version']]) %}\n {%- endif -%}\n {%- do ref_dict.update({_ref_args | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef ref(*args, **kwargs):\n refs = {{ ref_dict | tojson }}\n key = '.'.join(args)\n version = kwargs.get(\"v\") or kwargs.get(\"version\")\n if version:\n key += f\".v{version}\"\n dbt_load_df_function = kwargs.get(\"dbt_load_df_function\")\n return dbt_load_df_function(refs[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2605445, "supported_languages": null}, "macro.dbt.build_source_function": {"name": "build_source_function", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_source_function", "macro_sql": "{% macro build_source_function(model) %}\n\n {%- set source_dict = {} -%}\n {%- for _source in model.sources -%}\n {%- set resolved = source(*_source) -%}\n {%- do source_dict.update({_source | join('.'): resolve_model_name(resolved)}) -%}\n {%- endfor -%}\n\ndef source(*args, dbt_load_df_function):\n sources = {{ source_dict | tojson }}\n key = '.'.join(args)\n return dbt_load_df_function(sources[key])\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.resolve_model_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2614427, "supported_languages": null}, "macro.dbt.build_config_dict": {"name": "build_config_dict", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.build_config_dict", "macro_sql": "{% macro build_config_dict(model) %}\n {%- set config_dict = {} -%}\n {% set config_dbt_used = zip(model.config.config_keys_used, model.config.config_keys_defaults) | list %}\n {%- for key, default in config_dbt_used -%}\n {# weird type testing with enum, would be much easier to write this logic in Python! #}\n {%- if key == \"language\" -%}\n {%- set value = \"python\" -%}\n {%- endif -%}\n {%- set value = model.config.get(key, default) -%}\n {%- do config_dict.update({key: value}) -%}\n {%- endfor -%}\nconfig_dict = {{ config_dict }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2626498, "supported_languages": null}, "macro.dbt.py_script_postfix": {"name": "py_script_postfix", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.py_script_postfix", "macro_sql": "{% macro py_script_postfix(model) %}\n# This part is user provided model code\n# you will need to copy the next section to run the code\n# COMMAND ----------\n# this part is dbt logic for get ref work, do not modify\n\n{{ build_ref_function(model ) }}\n{{ build_source_function(model ) }}\n{{ build_config_dict(model) }}\n\nclass config:\n def __init__(self, *args, **kwargs):\n pass\n\n @staticmethod\n def get(key, default=None):\n return config_dict.get(key, default)\n\nclass this:\n \"\"\"dbt.this() or dbt.this.identifier\"\"\"\n database = \"{{ this.database }}\"\n schema = \"{{ this.schema }}\"\n identifier = \"{{ this.identifier }}\"\n {% set this_relation_name = resolve_model_name(this) %}\n def __repr__(self):\n return '{{ this_relation_name }}'\n\n\nclass dbtObj:\n def __init__(self, load_df_function) -> None:\n self.source = lambda *args: source(*args, dbt_load_df_function=load_df_function)\n self.ref = lambda *args, **kwargs: ref(*args, **kwargs, dbt_load_df_function=load_df_function)\n self.config = config\n self.this = this()\n self.is_incremental = {{ is_incremental() }}\n\n# COMMAND ----------\n{{py_script_comment()}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.build_ref_function", "macro.dbt.build_source_function", "macro.dbt.build_config_dict", "macro.dbt.resolve_model_name", "macro.dbt.is_incremental", "macro.dbt.py_script_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2637427, "supported_languages": null}, "macro.dbt.py_script_comment": {"name": "py_script_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/python_model/python.sql", "original_file_path": "macros/python_model/python.sql", "unique_id": "macro.dbt.py_script_comment", "macro_sql": "{%macro py_script_comment()%}\n{%endmacro%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2639215, "supported_languages": null}, "macro.dbt.set_sql_header": {"name": "set_sql_header", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.set_sql_header", "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2646434, "supported_languages": null}, "macro.dbt.should_full_refresh": {"name": "should_full_refresh", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.should_full_refresh", "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2653496, "supported_languages": null}, "macro.dbt.should_store_failures": {"name": "should_store_failures", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/configs.sql", "original_file_path": "macros/materializations/configs.sql", "unique_id": "macro.dbt.should_store_failures", "macro_sql": "{% macro should_store_failures() %}\n {% set config_store_failures = config.get('store_failures') %}\n {% if config_store_failures is none %}\n {% set config_store_failures = flags.STORE_FAILURES %}\n {% endif %}\n {% do return(config_store_failures) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2661924, "supported_languages": null}, "macro.dbt.run_hooks": {"name": "run_hooks", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.run_hooks", "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2682827, "supported_languages": null}, "macro.dbt.make_hook_config": {"name": "make_hook_config", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.make_hook_config", "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2686954, "supported_languages": null}, "macro.dbt.before_begin": {"name": "before_begin", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.before_begin", "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2690272, "supported_languages": null}, "macro.dbt.in_transaction": {"name": "in_transaction", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.in_transaction", "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2693686, "supported_languages": null}, "macro.dbt.after_commit": {"name": "after_commit", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/hooks.sql", "original_file_path": "macros/materializations/hooks.sql", "unique_id": "macro.dbt.after_commit", "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_hook_config"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2696974, "supported_languages": null}, "macro.dbt.snapshot_merge_sql": {"name": "snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "unique_id": "macro.dbt.snapshot_merge_sql", "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql', 'dbt')(target, source, insert_cols) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__snapshot_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.270509, "supported_languages": null}, "macro.dbt.default__snapshot_merge_sql": {"name": "default__snapshot_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshots/snapshot_merge.sql", "unique_id": "macro.dbt.default__snapshot_merge_sql", "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2711267, "supported_languages": null}, "macro.dbt.create_columns": {"name": "create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.create_columns", "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns', 'dbt')(relation, columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.276622, "supported_languages": null}, "macro.dbt.default__create_columns": {"name": "default__create_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__create_columns", "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2774436, "supported_languages": null}, "macro.dbt.post_snapshot": {"name": "post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.post_snapshot", "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot', 'dbt')(staging_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.277877, "supported_languages": null}, "macro.dbt.default__post_snapshot": {"name": "default__post_snapshot", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__post_snapshot", "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.278088, "supported_languages": null}, "macro.dbt.get_true_sql": {"name": "get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.get_true_sql", "macro_sql": "{% macro get_true_sql() %}\n {{ adapter.dispatch('get_true_sql', 'dbt')() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_true_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2784166, "supported_languages": null}, "macro.dbt.default__get_true_sql": {"name": "default__get_true_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__get_true_sql", "macro_sql": "{% macro default__get_true_sql() %}\n {{ return('TRUE') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.278672, "supported_languages": null}, "macro.dbt.snapshot_staging_table": {"name": "snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.snapshot_staging_table", "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n {{ adapter.dispatch('snapshot_staging_table', 'dbt')(strategy, source_sql, target_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__snapshot_staging_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2791023, "supported_languages": null}, "macro.dbt.default__snapshot_staging_table": {"name": "default__snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__snapshot_staging_table", "macro_sql": "{% macro default__snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n\n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n\n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.280923, "supported_languages": null}, "macro.dbt.build_snapshot_table": {"name": "build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.build_snapshot_table", "macro_sql": "{% macro build_snapshot_table(strategy, sql) -%}\n {{ adapter.dispatch('build_snapshot_table', 'dbt')(strategy, sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__build_snapshot_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2813714, "supported_languages": null}, "macro.dbt.default__build_snapshot_table": {"name": "default__build_snapshot_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.default__build_snapshot_table", "macro_sql": "{% macro default__build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2819293, "supported_languages": null}, "macro.dbt.build_snapshot_staging_table": {"name": "build_snapshot_staging_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/helpers.sql", "original_file_path": "macros/materializations/snapshots/helpers.sql", "unique_id": "macro.dbt.build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set temp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, temp_relation, select) }}\n {% endcall %}\n\n {% do return(temp_relation) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.make_temp_relation", "macro.dbt.snapshot_staging_table", "macro.dbt.statement", "macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.282838, "supported_languages": null}, "macro.dbt.materialization_snapshot_default": {"name": "materialization_snapshot_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/snapshot.sql", "original_file_path": "macros/materializations/snapshots/snapshot.sql", "unique_id": "macro.dbt.materialization_snapshot_default", "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n -- grab current tables grants config for comparision later on\n {%- set grant_config = config.get('grants') -%}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_code']) %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if not target_relation_exists %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.get_or_create_relation", "macro.dbt.run_hooks", "macro.dbt.strategy_dispatch", "macro.dbt.build_snapshot_table", "macro.dbt.create_table_as", "macro.dbt.build_snapshot_staging_table", "macro.dbt.create_columns", "macro.dbt.snapshot_merge_sql", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes", "macro.dbt.post_snapshot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.293598, "supported_languages": ["sql"]}, "macro.dbt.strategy_dispatch": {"name": "strategy_dispatch", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.strategy_dispatch", "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2992523, "supported_languages": null}, "macro.dbt.snapshot_hash_arguments": {"name": "snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_hash_arguments", "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments', 'dbt')(args) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.2996132, "supported_languages": null}, "macro.dbt.default__snapshot_hash_arguments": {"name": "default__snapshot_hash_arguments", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.default__snapshot_hash_arguments", "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3000987, "supported_languages": null}, "macro.dbt.snapshot_timestamp_strategy": {"name": "snapshot_timestamp_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_timestamp_strategy", "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/dbt-labs/dbt-core/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3016682, "supported_languages": null}, "macro.dbt.snapshot_string_as_time": {"name": "snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_string_as_time", "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time', 'dbt')(timestamp) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__snapshot_string_as_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3020349, "supported_languages": null}, "macro.dbt.default__snapshot_string_as_time": {"name": "default__snapshot_string_as_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.default__snapshot_string_as_time", "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3024077, "supported_languages": null}, "macro.dbt.snapshot_check_all_get_existing_columns": {"name": "snapshot_check_all_get_existing_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) -%}\n {%- if not target_exists -%}\n {#-- no table yet -> return whatever the query does --#}\n {{ return((false, query_columns)) }}\n {%- endif -%}\n\n {#-- handle any schema changes --#}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=node.alias) -%}\n\n {% if check_cols_config == 'all' %}\n {%- set query_columns = get_columns_in_query(node['compiled_code']) -%}\n\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {#-- query for proper casing/quoting, to support comparison below --#}\n {%- set select_check_cols_from_target -%}\n {#-- N.B. The whitespace below is necessary to avoid edge case issue with comments --#}\n {#-- See: https://github.com/dbt-labs/dbt-core/issues/6781 --#}\n select {{ check_cols_config | join(', ') }} from (\n {{ node['compiled_code'] }}\n ) subq\n {%- endset -%}\n {% set query_columns = get_columns_in_query(select_check_cols_from_target) %}\n\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set existing_cols = adapter.get_columns_in_relation(target_relation) | map(attribute = 'name') | list -%}\n {%- set ns = namespace() -%} {#-- handle for-loop scoping with a namespace --#}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(adapter.quote(col)) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return((ns.column_added, intersection)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3053625, "supported_languages": null}, "macro.dbt.snapshot_check_strategy": {"name": "snapshot_check_strategy", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/snapshots/strategies.sql", "original_file_path": "macros/materializations/snapshots/strategies.sql", "unique_id": "macro.dbt.snapshot_check_strategy", "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n {% set updated_at = config.get('updated_at', snapshot_get_time()) %}\n\n {% set column_added = false %}\n\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists, check_cols_config) %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n {{ get_true_sql() }}\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.snapshot_get_time", "macro.dbt.snapshot_check_all_get_existing_columns", "macro.dbt.get_true_sql", "macro.dbt.snapshot_hash_arguments"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3081865, "supported_languages": null}, "macro.dbt.materialization_view_default": {"name": "materialization_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/view.sql", "original_file_path": "macros/materializations/models/view.sql", "unique_id": "macro.dbt.materialization_view_default", "macro_sql": "{%- materialization view, default -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='view') -%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"existing_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the existing_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the existing_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.run_hooks", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.313603, "supported_languages": ["sql"]}, "macro.dbt.materialization_table_default": {"name": "materialization_table_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/table.sql", "original_file_path": "macros/materializations/models/table.sql", "unique_id": "macro.dbt.materialization_table_default", "macro_sql": "{% materialization table, default %}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') %}\n {%- set intermediate_relation = make_intermediate_relation(target_relation) -%}\n -- the intermediate_relation should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) -%}\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n -- as above, the backup_relation should not already exist\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_table_as_sql(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if existing_relation is not none %}\n /* Do the equivalent of rename_if_exists. 'existing_relation' could have been dropped\n since the variable was first set. */\n {% set existing_relation = load_cached_relation(existing_relation) %}\n {% if existing_relation is not none %}\n {{ adapter.rename_relation(existing_relation, backup_relation) }}\n {% endif %}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do create_indexes(target_relation) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.get_create_table_as_sql", "macro.dbt.create_indexes", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3188539, "supported_languages": ["sql"]}, "macro.dbt.materialization_materialized_view_default": {"name": "materialization_materialized_view_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialization_materialized_view_default", "macro_sql": "{% materialization materialized_view, default %}\n {% set existing_relation = load_cached_relation(this) %}\n {% set target_relation = this.incorporate(type=this.MaterializedView) %}\n {% set intermediate_relation = make_intermediate_relation(target_relation) %}\n {% set backup_relation_type = target_relation.MaterializedView if existing_relation is none else existing_relation.type %}\n {% set backup_relation = make_backup_relation(target_relation, backup_relation_type) %}\n\n {{ materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) }}\n\n {% set build_sql = materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% if build_sql == '' %}\n {{ materialized_view_execute_no_op(target_relation) }}\n {% else %}\n {{ materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) }}\n {% endif %}\n\n {{ materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.materialized_view_setup", "macro.dbt.materialized_view_get_build_sql", "macro.dbt.materialized_view_execute_no_op", "macro.dbt.materialized_view_execute_build_sql", "macro.dbt.materialized_view_teardown"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3260963, "supported_languages": ["sql"]}, "macro.dbt.materialized_view_setup": {"name": "materialized_view_setup", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_setup", "macro_sql": "{% macro materialized_view_setup(backup_relation, intermediate_relation, pre_hooks) %}\n\n -- backup_relation and intermediate_relation should not already exist in the database\n -- it's possible these exist because of a previous run that exited unexpectedly\n {% set preexisting_backup_relation = load_cached_relation(backup_relation) %}\n {% set preexisting_intermediate_relation = load_cached_relation(intermediate_relation) %}\n\n -- drop the temp relations if they exist already in the database\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.326911, "supported_languages": null}, "macro.dbt.materialized_view_teardown": {"name": "materialized_view_teardown", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_teardown", "macro_sql": "{% macro materialized_view_teardown(backup_relation, intermediate_relation, post_hooks) %}\n\n -- drop the temp relations if they exist to leave the database clean for the next run\n {{ drop_relation_if_exists(backup_relation) }}\n {{ drop_relation_if_exists(intermediate_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3274453, "supported_languages": null}, "macro.dbt.materialized_view_get_build_sql": {"name": "materialized_view_get_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_get_build_sql", "macro_sql": "{% macro materialized_view_get_build_sql(existing_relation, target_relation, backup_relation, intermediate_relation) %}\n\n {% set full_refresh_mode = should_full_refresh() %}\n\n -- determine the scenario we're in: create, full_refresh, alter, refresh data\n {% if existing_relation is none %}\n {% set build_sql = get_create_materialized_view_as_sql(target_relation, sql) %}\n {% elif full_refresh_mode or not existing_relation.is_materialized_view %}\n {% set build_sql = get_replace_sql(existing_relation, target_relation, sql) %}\n {% else %}\n\n -- get config options\n {% set on_configuration_change = config.get('on_configuration_change') %}\n {% set configuration_changes = get_materialized_view_configuration_changes(existing_relation, config) %}\n\n {% if configuration_changes is none %}\n {% set build_sql = refresh_materialized_view(target_relation) %}\n\n {% elif on_configuration_change == 'apply' %}\n {% set build_sql = get_alter_materialized_view_as_sql(target_relation, configuration_changes, sql, existing_relation, backup_relation, intermediate_relation) %}\n {% elif on_configuration_change == 'continue' %}\n {% set build_sql = '' %}\n {{ exceptions.warn(\"Configuration changes were identified and `on_configuration_change` was set to `continue` for `\" ~ target_relation ~ \"`\") }}\n {% elif on_configuration_change == 'fail' %}\n {{ exceptions.raise_fail_fast_error(\"Configuration changes were identified and `on_configuration_change` was set to `fail` for `\" ~ target_relation ~ \"`\") }}\n\n {% else %}\n -- this only happens if the user provides a value other than `apply`, 'skip', 'fail'\n {{ exceptions.raise_compiler_error(\"Unexpected configuration scenario\") }}\n\n {% endif %}\n\n {% endif %}\n\n {% do return(build_sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.get_create_materialized_view_as_sql", "macro.dbt.get_replace_sql", "macro.dbt.get_materialized_view_configuration_changes", "macro.dbt.refresh_materialized_view", "macro.dbt.get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.330197, "supported_languages": null}, "macro.dbt.materialized_view_execute_no_op": {"name": "materialized_view_execute_no_op", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_no_op", "macro_sql": "{% macro materialized_view_execute_no_op(target_relation) %}\n {% do store_raw_result(\n name=\"main\",\n message=\"skip \" ~ target_relation,\n code=\"skip\",\n rows_affected=\"-1\"\n ) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.330685, "supported_languages": null}, "macro.dbt.materialized_view_execute_build_sql": {"name": "materialized_view_execute_build_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/materialized_view.sql", "original_file_path": "macros/materializations/models/materialized_view.sql", "unique_id": "macro.dbt.materialized_view_execute_build_sql", "macro_sql": "{% macro materialized_view_execute_build_sql(build_sql, existing_relation, target_relation, post_hooks) %}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set grant_config = config.get('grants') %}\n\n {% call statement(name=\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3321054, "supported_languages": null}, "macro.dbt.get_merge_sql": {"name": "get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_merge_sql", "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n -- back compat for old kwarg name\n {% set incremental_predicates = kwargs.get('predicates', incremental_predicates) %}\n {{ adapter.dispatch('get_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3407986, "supported_languages": null}, "macro.dbt.default__get_merge_sql": {"name": "default__get_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_merge_sql", "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, incremental_predicates=none) -%}\n {%- set predicates = [] if incremental_predicates is none else [] + incremental_predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set merge_update_columns = config.get('merge_update_columns') -%}\n {%- set merge_exclude_columns = config.get('merge_exclude_columns') -%}\n {%- set update_columns = get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}\n {% for key in unique_key %}\n {% set this_key_match %}\n DBT_INTERNAL_SOURCE.{{ key }} = DBT_INTERNAL_DEST.{{ key }}\n {% endset %}\n {% do predicates.append(this_key_match) %}\n {% endfor %}\n {% else %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% endif %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{\"(\" ~ predicates | join(\") and (\") ~ \")\"}}\n\n {% if unique_key %}\n when matched then update set\n {% for column_name in update_columns -%}\n {{ column_name }} = DBT_INTERNAL_SOURCE.{{ column_name }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv", "macro.dbt.get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3443108, "supported_languages": null}, "macro.dbt.get_delete_insert_merge_sql": {"name": "get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_delete_insert_merge_sql", "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql', 'dbt')(target, source, unique_key, dest_columns, incremental_predicates) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3448663, "supported_languages": null}, "macro.dbt.default__get_delete_insert_merge_sql": {"name": "default__get_delete_insert_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_delete_insert_merge_sql", "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns, incremental_predicates) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key %}\n {% if unique_key is sequence and unique_key is not string %}\n delete from {{target }}\n using {{ source }}\n where (\n {% for key in unique_key %}\n {{ source }}.{{ key }} = {{ target }}.{{ key }}\n {{ \"and \" if not loop.last}}\n {% endfor %}\n {% if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {% endif %}\n );\n {% else %}\n delete from {{ target }}\n where (\n {{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n )\n {%- if incremental_predicates %}\n {% for predicate in incremental_predicates %}\n and {{ predicate }}\n {% endfor %}\n {%- endif -%};\n\n {% endif %}\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.347056, "supported_languages": null}, "macro.dbt.get_insert_overwrite_merge_sql": {"name": "get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.get_insert_overwrite_merge_sql", "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql', 'dbt')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3476112, "supported_languages": null}, "macro.dbt.default__get_insert_overwrite_merge_sql": {"name": "default__get_insert_overwrite_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/merge.sql", "original_file_path": "macros/materializations/models/incremental/merge.sql", "unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {#-- The only time include_sql_header is True: --#}\n {#-- BigQuery + insert_overwrite strategy + \"static\" partitions config --#}\n {#-- We should consider including the sql header at the materialization level instead --#}\n\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3489625, "supported_languages": null}, "macro.dbt.get_quoted_csv": {"name": "get_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.get_quoted_csv", "macro_sql": "{% macro get_quoted_csv(column_names) %}\n\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3515925, "supported_languages": null}, "macro.dbt.diff_columns": {"name": "diff_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.diff_columns", "macro_sql": "{% macro diff_columns(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% set source_names = source_columns | map(attribute = 'column') | list %}\n {% set target_names = target_columns | map(attribute = 'column') | list %}\n\n {# --check whether the name attribute exists in the target - this does not perform a data type check #}\n {% for sc in source_columns %}\n {% if sc.name not in target_names %}\n {{ result.append(sc) }}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3527708, "supported_languages": null}, "macro.dbt.diff_column_data_types": {"name": "diff_column_data_types", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.diff_column_data_types", "macro_sql": "{% macro diff_column_data_types(source_columns, target_columns) %}\n\n {% set result = [] %}\n {% for sc in source_columns %}\n {% set tc = target_columns | selectattr(\"name\", \"equalto\", sc.name) | list | first %}\n {% if tc %}\n {% if sc.data_type != tc.data_type and not sc.can_expand_to(other_column=tc) %}\n {{ result.append( { 'column_name': tc.name, 'new_type': sc.data_type } ) }}\n {% endif %}\n {% endif %}\n {% endfor %}\n\n {{ return(result) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3541975, "supported_languages": null}, "macro.dbt.get_merge_update_columns": {"name": "get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.get_merge_update_columns", "macro_sql": "{% macro get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {{ return(adapter.dispatch('get_merge_update_columns', 'dbt')(merge_update_columns, merge_exclude_columns, dest_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_merge_update_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.354704, "supported_languages": null}, "macro.dbt.default__get_merge_update_columns": {"name": "default__get_merge_update_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/column_helpers.sql", "original_file_path": "macros/materializations/models/incremental/column_helpers.sql", "unique_id": "macro.dbt.default__get_merge_update_columns", "macro_sql": "{% macro default__get_merge_update_columns(merge_update_columns, merge_exclude_columns, dest_columns) %}\n {%- set default_cols = dest_columns | map(attribute=\"quoted\") | list -%}\n\n {%- if merge_update_columns and merge_exclude_columns -%}\n {{ exceptions.raise_compiler_error(\n 'Model cannot specify merge_update_columns and merge_exclude_columns. Please update model to use only one config'\n )}}\n {%- elif merge_update_columns -%}\n {%- set update_columns = merge_update_columns -%}\n {%- elif merge_exclude_columns -%}\n {%- set update_columns = [] -%}\n {%- for column in dest_columns -%}\n {% if column.column | lower not in merge_exclude_columns | map(\"lower\") | list %}\n {%- do update_columns.append(column.quoted) -%}\n {% endif %}\n {%- endfor -%}\n {%- else -%}\n {%- set update_columns = default_cols -%}\n {%- endif -%}\n\n {{ return(update_columns) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.356216, "supported_languages": null}, "macro.dbt.incremental_validate_on_schema_change": {"name": "incremental_validate_on_schema_change", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.incremental_validate_on_schema_change", "macro_sql": "{% macro incremental_validate_on_schema_change(on_schema_change, default='ignore') %}\n\n {% if on_schema_change not in ['sync_all_columns', 'append_new_columns', 'fail', 'ignore'] %}\n\n {% set log_message = 'Invalid value for on_schema_change (%s) specified. Setting default value of %s.' % (on_schema_change, default) %}\n {% do log(log_message) %}\n\n {{ return(default) }}\n\n {% else %}\n\n {{ return(on_schema_change) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3640592, "supported_languages": null}, "macro.dbt.check_for_schema_changes": {"name": "check_for_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.check_for_schema_changes", "macro_sql": "{% macro check_for_schema_changes(source_relation, target_relation) %}\n\n {% set schema_changed = False %}\n\n {%- set source_columns = adapter.get_columns_in_relation(source_relation) -%}\n {%- set target_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set source_not_in_target = diff_columns(source_columns, target_columns) -%}\n {%- set target_not_in_source = diff_columns(target_columns, source_columns) -%}\n\n {% set new_target_types = diff_column_data_types(source_columns, target_columns) %}\n\n {% if source_not_in_target != [] %}\n {% set schema_changed = True %}\n {% elif target_not_in_source != [] or new_target_types != [] %}\n {% set schema_changed = True %}\n {% elif new_target_types != [] %}\n {% set schema_changed = True %}\n {% endif %}\n\n {% set changes_dict = {\n 'schema_changed': schema_changed,\n 'source_not_in_target': source_not_in_target,\n 'target_not_in_source': target_not_in_source,\n 'source_columns': source_columns,\n 'target_columns': target_columns,\n 'new_target_types': new_target_types\n } %}\n\n {% set msg %}\n In {{ target_relation }}:\n Schema changed: {{ schema_changed }}\n Source columns not in target: {{ source_not_in_target }}\n Target columns not in source: {{ target_not_in_source }}\n New column types: {{ new_target_types }}\n {% endset %}\n\n {% do log(msg) %}\n\n {{ return(changes_dict) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.diff_columns", "macro.dbt.diff_column_data_types"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.366624, "supported_languages": null}, "macro.dbt.sync_column_schemas": {"name": "sync_column_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.sync_column_schemas", "macro_sql": "{% macro sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {%- set add_to_target_arr = schema_changes_dict['source_not_in_target'] -%}\n\n {%- if on_schema_change == 'append_new_columns'-%}\n {%- if add_to_target_arr | length > 0 -%}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, none) -%}\n {%- endif -%}\n\n {% elif on_schema_change == 'sync_all_columns' %}\n {%- set remove_from_target_arr = schema_changes_dict['target_not_in_source'] -%}\n {%- set new_target_types = schema_changes_dict['new_target_types'] -%}\n\n {% if add_to_target_arr | length > 0 or remove_from_target_arr | length > 0 %}\n {%- do alter_relation_add_remove_columns(target_relation, add_to_target_arr, remove_from_target_arr) -%}\n {% endif %}\n\n {% if new_target_types != [] %}\n {% for ntt in new_target_types %}\n {% set column_name = ntt['column_name'] %}\n {% set new_type = ntt['new_type'] %}\n {% do alter_column_type(target_relation, column_name, new_type) %}\n {% endfor %}\n {% endif %}\n\n {% endif %}\n\n {% set schema_change_message %}\n In {{ target_relation }}:\n Schema change approach: {{ on_schema_change }}\n Columns added: {{ add_to_target_arr }}\n Columns removed: {{ remove_from_target_arr }}\n Data types changed: {{ new_target_types }}\n {% endset %}\n\n {% do log(schema_change_message) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.alter_relation_add_remove_columns", "macro.dbt.alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3692784, "supported_languages": null}, "macro.dbt.process_schema_changes": {"name": "process_schema_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/on_schema_change.sql", "original_file_path": "macros/materializations/models/incremental/on_schema_change.sql", "unique_id": "macro.dbt.process_schema_changes", "macro_sql": "{% macro process_schema_changes(on_schema_change, source_relation, target_relation) %}\n\n {% if on_schema_change == 'ignore' %}\n\n {{ return({}) }}\n\n {% else %}\n\n {% set schema_changes_dict = check_for_schema_changes(source_relation, target_relation) %}\n\n {% if schema_changes_dict['schema_changed'] %}\n\n {% if on_schema_change == 'fail' %}\n\n {% set fail_msg %}\n The source and target schemas on this incremental model are out of sync!\n They can be reconciled in several ways:\n - set the `on_schema_change` config to either append_new_columns or sync_all_columns, depending on your situation.\n - Re-run the incremental model with `full_refresh: True` to update the target schema.\n - update the schema manually and re-run the process.\n\n Additional troubleshooting context:\n Source columns not in target: {{ schema_changes_dict['source_not_in_target'] }}\n Target columns not in source: {{ schema_changes_dict['target_not_in_source'] }}\n New column types: {{ schema_changes_dict['new_target_types'] }}\n {% endset %}\n\n {% do exceptions.raise_compiler_error(fail_msg) %}\n\n {# -- unless we ignore, run the sync operation per the config #}\n {% else %}\n\n {% do sync_column_schemas(on_schema_change, target_relation, schema_changes_dict) %}\n\n {% endif %}\n\n {% endif %}\n\n {{ return(schema_changes_dict['source_columns']) }}\n\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.check_for_schema_changes", "macro.dbt.sync_column_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3711069, "supported_languages": null}, "macro.dbt.is_incremental": {"name": "is_incremental", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/is_incremental.sql", "original_file_path": "macros/materializations/models/incremental/is_incremental.sql", "unique_id": "macro.dbt.is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3723667, "supported_languages": null}, "macro.dbt.materialization_incremental_default": {"name": "materialization_incremental_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/incremental.sql", "original_file_path": "macros/materializations/models/incremental/incremental.sql", "unique_id": "macro.dbt.materialization_incremental_default", "macro_sql": "{% materialization incremental, default -%}\n\n -- relations\n {%- set existing_relation = load_cached_relation(this) -%}\n {%- set target_relation = this.incorporate(type='table') -%}\n {%- set temp_relation = make_temp_relation(target_relation)-%}\n {%- set intermediate_relation = make_intermediate_relation(target_relation)-%}\n {%- set backup_relation_type = 'table' if existing_relation is none else existing_relation.type -%}\n {%- set backup_relation = make_backup_relation(target_relation, backup_relation_type) -%}\n\n -- configs\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh() or existing_relation.is_view) -%}\n {%- set on_schema_change = incremental_validate_on_schema_change(config.get('on_schema_change'), default='ignore') -%}\n\n -- the temp_ and backup_ relations should not already exist in the database; get_relation\n -- will return None in that case. Otherwise, we get a relation that we can drop\n -- later, before we try to use this name for the current operation. This has to happen before\n -- BEGIN, in a separate transaction\n {%- set preexisting_intermediate_relation = load_cached_relation(intermediate_relation)-%}\n {%- set preexisting_backup_relation = load_cached_relation(backup_relation) -%}\n -- grab current tables grants config for comparision later on\n {% set grant_config = config.get('grants') %}\n {{ drop_relation_if_exists(preexisting_intermediate_relation) }}\n {{ drop_relation_if_exists(preexisting_backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n\n {% if existing_relation is none %}\n {% set build_sql = get_create_table_as_sql(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = get_create_table_as_sql(False, intermediate_relation, sql) %}\n {% set need_swap = true %}\n {% else %}\n {% do run_query(get_create_table_as_sql(True, temp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=temp_relation,\n to_relation=target_relation) %}\n {#-- Process schema changes. Returns dict of changes if successful. Use source columns for upserting/merging --#}\n {% set dest_columns = process_schema_changes(on_schema_change, temp_relation, existing_relation) %}\n {% if not dest_columns %}\n {% set dest_columns = adapter.get_columns_in_relation(existing_relation) %}\n {% endif %}\n\n {#-- Get the incremental_strategy, the macro to use for the strategy, and build the sql --#}\n {% set incremental_strategy = config.get('incremental_strategy') or 'default' %}\n {% set incremental_predicates = config.get('predicates', none) or config.get('incremental_predicates', none) %}\n {% set strategy_sql_macro_func = adapter.get_incremental_strategy_macro(context, incremental_strategy) %}\n {% set strategy_arg_dict = ({'target_relation': target_relation, 'temp_relation': temp_relation, 'unique_key': unique_key, 'dest_columns': dest_columns, 'incremental_predicates': incremental_predicates }) %}\n {% set build_sql = strategy_sql_macro_func(strategy_arg_dict) %}\n\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% if need_swap %}\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% do adapter.rename_relation(intermediate_relation, target_relation) %}\n {% do to_drop.append(backup_relation) %}\n {% endif %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if existing_relation is none or existing_relation.is_view or should_full_refresh() %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.make_temp_relation", "macro.dbt.make_intermediate_relation", "macro.dbt.make_backup_relation", "macro.dbt.should_full_refresh", "macro.dbt.incremental_validate_on_schema_change", "macro.dbt.drop_relation_if_exists", "macro.dbt.run_hooks", "macro.dbt.get_create_table_as_sql", "macro.dbt.run_query", "macro.dbt.process_schema_changes", "macro.dbt.statement", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3818703, "supported_languages": ["sql"]}, "macro.dbt.get_incremental_append_sql": {"name": "get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_append_sql", "macro_sql": "{% macro get_incremental_append_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_append_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3833618, "supported_languages": null}, "macro.dbt.default__get_incremental_append_sql": {"name": "default__get_incremental_append_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_append_sql", "macro_sql": "{% macro default__get_incremental_append_sql(arg_dict) %}\n\n {% do return(get_insert_into_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_into_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.383858, "supported_languages": null}, "macro.dbt.get_incremental_delete_insert_sql": {"name": "get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_delete_insert_sql", "macro_sql": "{% macro get_incremental_delete_insert_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_delete_insert_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_delete_insert_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3842552, "supported_languages": null}, "macro.dbt.default__get_incremental_delete_insert_sql": {"name": "default__get_incremental_delete_insert_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_delete_insert_sql", "macro_sql": "{% macro default__get_incremental_delete_insert_sql(arg_dict) %}\n\n {% do return(get_delete_insert_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_delete_insert_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3848586, "supported_languages": null}, "macro.dbt.get_incremental_merge_sql": {"name": "get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_merge_sql", "macro_sql": "{% macro get_incremental_merge_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3852885, "supported_languages": null}, "macro.dbt.default__get_incremental_merge_sql": {"name": "default__get_incremental_merge_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_merge_sql", "macro_sql": "{% macro default__get_incremental_merge_sql(arg_dict) %}\n\n {% do return(get_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"unique_key\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3859158, "supported_languages": null}, "macro.dbt.get_incremental_insert_overwrite_sql": {"name": "get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_insert_overwrite_sql", "macro_sql": "{% macro get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_insert_overwrite_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_insert_overwrite_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3863132, "supported_languages": null}, "macro.dbt.default__get_incremental_insert_overwrite_sql": {"name": "default__get_incremental_insert_overwrite_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_insert_overwrite_sql", "macro_sql": "{% macro default__get_incremental_insert_overwrite_sql(arg_dict) %}\n\n {% do return(get_insert_overwrite_merge_sql(arg_dict[\"target_relation\"], arg_dict[\"temp_relation\"], arg_dict[\"dest_columns\"], arg_dict[\"incremental_predicates\"])) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_insert_overwrite_merge_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3868513, "supported_languages": null}, "macro.dbt.get_incremental_default_sql": {"name": "get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_incremental_default_sql", "macro_sql": "{% macro get_incremental_default_sql(arg_dict) %}\n\n {{ return(adapter.dispatch('get_incremental_default_sql', 'dbt')(arg_dict)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_incremental_default_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3872366, "supported_languages": null}, "macro.dbt.default__get_incremental_default_sql": {"name": "default__get_incremental_default_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.default__get_incremental_default_sql", "macro_sql": "{% macro default__get_incremental_default_sql(arg_dict) %}\n\n {% do return(get_incremental_append_sql(arg_dict)) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_incremental_append_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3875718, "supported_languages": null}, "macro.dbt.get_insert_into_sql": {"name": "get_insert_into_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/incremental/strategies.sql", "original_file_path": "macros/materializations/models/incremental/strategies.sql", "unique_id": "macro.dbt.get_insert_into_sql", "macro_sql": "{% macro get_insert_into_sql(target_relation, temp_relation, dest_columns) %}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ temp_relation }}\n )\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_quoted_csv"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3881514, "supported_languages": null}, "macro.dbt.create_or_replace_clone": {"name": "create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/create_or_replace_clone.sql", "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", "unique_id": "macro.dbt.create_or_replace_clone", "macro_sql": "{% macro create_or_replace_clone(this_relation, defer_relation) %}\n {{ return(adapter.dispatch('create_or_replace_clone', 'dbt')(this_relation, defer_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_or_replace_clone"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3887293, "supported_languages": null}, "macro.dbt.default__create_or_replace_clone": {"name": "default__create_or_replace_clone", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/create_or_replace_clone.sql", "original_file_path": "macros/materializations/models/clone/create_or_replace_clone.sql", "unique_id": "macro.dbt.default__create_or_replace_clone", "macro_sql": "{% macro default__create_or_replace_clone(this_relation, defer_relation) %}\n create or replace table {{ this_relation }} clone {{ defer_relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3890452, "supported_languages": null}, "macro.dbt.materialization_clone_default": {"name": "materialization_clone_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/clone.sql", "original_file_path": "macros/materializations/models/clone/clone.sql", "unique_id": "macro.dbt.materialization_clone_default", "macro_sql": "{%- materialization clone, default -%}\n\n {%- set relations = {'relations': []} -%}\n\n {%- if not defer_relation -%}\n -- nothing to do\n {{ log(\"No relation found in state manifest for \" ~ model.unique_id, info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set existing_relation = load_cached_relation(this) -%}\n\n {%- if existing_relation and not flags.FULL_REFRESH -%}\n -- noop!\n {{ log(\"Relation \" ~ existing_relation ~ \" already exists\", info=True) }}\n {{ return(relations) }}\n {%- endif -%}\n\n {%- set other_existing_relation = load_cached_relation(defer_relation) -%}\n\n -- If this is a database that can do zero-copy cloning of tables, and the other relation is a table, then this will be a table\n -- Otherwise, this will be a view\n\n {% set can_clone_table = can_clone_table() %}\n\n {%- if other_existing_relation and other_existing_relation.type == 'table' and can_clone_table -%}\n\n {%- set target_relation = this.incorporate(type='table') -%}\n {% if existing_relation is not none and not existing_relation.is_table %}\n {{ log(\"Dropping relation \" ~ existing_relation ~ \" because it is of type \" ~ existing_relation.type) }}\n {{ drop_relation_if_exists(existing_relation) }}\n {% endif %}\n\n -- as a general rule, data platforms that can clone tables can also do atomic 'create or replace'\n {% call statement('main') %}\n {% if target_relation and defer_relation and target_relation == defer_relation %}\n {{ log(\"Target relation and defer relation are the same, skipping clone for relation: \" ~ target_relation) }}\n {% else %}\n {{ create_or_replace_clone(target_relation, defer_relation) }}\n {% endif %}\n\n {% endcall %}\n\n {% set should_revoke = should_revoke(existing_relation, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n {% do persist_docs(target_relation, model) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n {%- else -%}\n\n {%- set target_relation = this.incorporate(type='view') -%}\n\n -- reuse the view materialization\n -- TODO: support actual dispatch for materialization macros\n -- Tracking ticket: https://github.com/dbt-labs/dbt-core/issues/7799\n {% set search_name = \"materialization_view_\" ~ adapter.type() %}\n {% if not search_name in context %}\n {% set search_name = \"materialization_view_default\" %}\n {% endif %}\n {% set materialization_macro = context[search_name] %}\n {% set relations = materialization_macro() %}\n {{ return(relations) }}\n\n {%- endif -%}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.load_cached_relation", "macro.dbt.can_clone_table", "macro.dbt.drop_relation_if_exists", "macro.dbt.statement", "macro.dbt.create_or_replace_clone", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3954248, "supported_languages": ["sql"]}, "macro.dbt.can_clone_table": {"name": "can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/can_clone_table.sql", "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", "unique_id": "macro.dbt.can_clone_table", "macro_sql": "{% macro can_clone_table() %}\n {{ return(adapter.dispatch('can_clone_table', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__can_clone_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3959317, "supported_languages": null}, "macro.dbt.default__can_clone_table": {"name": "default__can_clone_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/models/clone/can_clone_table.sql", "original_file_path": "macros/materializations/models/clone/can_clone_table.sql", "unique_id": "macro.dbt.default__can_clone_table", "macro_sql": "{% macro default__can_clone_table() %}\n {{ return(False) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3961852, "supported_languages": null}, "macro.dbt.get_where_subquery": {"name": "get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "unique_id": "macro.dbt.get_where_subquery", "macro_sql": "{% macro get_where_subquery(relation) -%}\n {% do return(adapter.dispatch('get_where_subquery', 'dbt')(relation)) %}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_where_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.396872, "supported_languages": null}, "macro.dbt.default__get_where_subquery": {"name": "default__get_where_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/where_subquery.sql", "original_file_path": "macros/materializations/tests/where_subquery.sql", "unique_id": "macro.dbt.default__get_where_subquery", "macro_sql": "{% macro default__get_where_subquery(relation) -%}\n {% set where = config.get('where', '') %}\n {% if where %}\n {%- set filtered -%}\n (select * from {{ relation }} where {{ where }}) dbt_subquery\n {%- endset -%}\n {% do return(filtered) %}\n {%- else -%}\n {% do return(relation) %}\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.3977358, "supported_languages": null}, "macro.dbt.materialization_test_default": {"name": "materialization_test_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/test.sql", "original_file_path": "macros/materializations/tests/test.sql", "unique_id": "macro.dbt.materialization_test_default", "macro_sql": "{%- materialization test, default -%}\n\n {% set relations = [] %}\n\n {% if should_store_failures() %}\n\n {% set identifier = model['alias'] %}\n {% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% set store_failures_as = config.get('store_failures_as') %}\n -- if `--store-failures` is invoked via command line and `store_failures_as` is not set,\n -- config.get('store_failures_as', 'table') returns None, not 'table'\n {% if store_failures_as == none %}{% set store_failures_as = 'table' %}{% endif %}\n {% if store_failures_as not in ['table', 'view'] %}\n {{ exceptions.raise_compiler_error(\n \"'\" ~ store_failures_as ~ \"' is not a valid value for `store_failures_as`. \"\n \"Accepted values are: ['ephemeral', 'table', 'view']\"\n ) }}\n {% endif %}\n\n {% set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database, type=store_failures_as) -%} %}\n\n {% if old_relation %}\n {% do adapter.drop_relation(old_relation) %}\n {% endif %}\n\n {% call statement(auto_begin=True) %}\n {{ get_create_sql(target_relation, sql) }}\n {% endcall %}\n\n {% do relations.append(target_relation) %}\n\n {% set main_sql %}\n select *\n from {{ target_relation }}\n {% endset %}\n\n {{ adapter.commit() }}\n\n {% else %}\n\n {% set main_sql = sql %}\n\n {% endif %}\n\n {% set limit = config.get('limit') %}\n {% set fail_calc = config.get('fail_calc') %}\n {% set warn_if = config.get('warn_if') %}\n {% set error_if = config.get('error_if') %}\n\n {% call statement('main', fetch_result=True) -%}\n\n {{ get_test_sql(main_sql, fail_calc, warn_if, error_if, limit)}}\n\n {%- endcall %}\n\n {{ return({'relations': relations}) }}\n\n{%- endmaterialization -%}", "depends_on": {"macros": ["macro.dbt.should_store_failures", "macro.dbt.statement", "macro.dbt.get_create_sql", "macro.dbt.get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4029033, "supported_languages": ["sql"]}, "macro.dbt.get_test_sql": {"name": "get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.get_test_sql", "macro_sql": "{% macro get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n {{ adapter.dispatch('get_test_sql', 'dbt')(main_sql, fail_calc, warn_if, error_if, limit) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_test_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4037428, "supported_languages": null}, "macro.dbt.default__get_test_sql": {"name": "default__get_test_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/tests/helpers.sql", "original_file_path": "macros/materializations/tests/helpers.sql", "unique_id": "macro.dbt.default__get_test_sql", "macro_sql": "{% macro default__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}\n select\n {{ fail_calc }} as failures,\n {{ fail_calc }} {{ warn_if }} as should_warn,\n {{ fail_calc }} {{ error_if }} as should_error\n from (\n {{ main_sql }}\n {{ \"limit \" ~ limit if limit != none }}\n ) dbt_internal_test\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.404407, "supported_languages": null}, "macro.dbt.materialization_seed_default": {"name": "materialization_seed_default", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/seed.sql", "original_file_path": "macros/materializations/seeds/seed.sql", "unique_id": "macro.dbt.materialization_seed_default", "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set grant_config = config.get('grants') -%}\n {%- set agate_table = load_agate_table() -%}\n -- grab current tables grants config for comparison later on\n\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation)) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ get_csv_sql(create_table_sql, sql) }};\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n\n {% set should_revoke = should_revoke(old_relation, full_refresh_mode) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {% do persist_docs(target_relation, model) %}\n\n {% if full_refresh_mode or not exists_as_table %}\n {% do create_indexes(target_relation) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "depends_on": {"macros": ["macro.dbt.should_full_refresh", "macro.dbt.run_hooks", "macro.dbt.reset_csv_table", "macro.dbt.create_csv_table", "macro.dbt.load_csv_rows", "macro.dbt.noop_statement", "macro.dbt.get_csv_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants", "macro.dbt.persist_docs", "macro.dbt.create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4107792, "supported_languages": ["sql"]}, "macro.dbt.create_csv_table": {"name": "create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.create_csv_table", "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4178457, "supported_languages": null}, "macro.dbt.default__create_csv_table": {"name": "default__create_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__create_csv_table", "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4197457, "supported_languages": null}, "macro.dbt.reset_csv_table": {"name": "reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.reset_csv_table", "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table', 'dbt')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__reset_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4202416, "supported_languages": null}, "macro.dbt.default__reset_csv_table": {"name": "default__reset_csv_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__reset_csv_table", "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_csv_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4213388, "supported_languages": null}, "macro.dbt.get_csv_sql": {"name": "get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_csv_sql", "macro_sql": "{% macro get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ adapter.dispatch('get_csv_sql', 'dbt')(create_or_truncate_sql, insert_sql) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_csv_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4217637, "supported_languages": null}, "macro.dbt.default__get_csv_sql": {"name": "default__get_csv_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_csv_sql", "macro_sql": "{% macro default__get_csv_sql(create_or_truncate_sql, insert_sql) %}\n {{ create_or_truncate_sql }};\n -- dbt seed --\n {{ insert_sql }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4220598, "supported_languages": null}, "macro.dbt.get_binding_char": {"name": "get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_binding_char", "macro_sql": "{% macro get_binding_char() -%}\n {{ adapter.dispatch('get_binding_char', 'dbt')() }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4223628, "supported_languages": null}, "macro.dbt.default__get_binding_char": {"name": "default__get_binding_char", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_binding_char", "macro_sql": "{% macro default__get_binding_char() %}\n {{ return('%s') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4226196, "supported_languages": null}, "macro.dbt.get_batch_size": {"name": "get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_batch_size", "macro_sql": "{% macro get_batch_size() -%}\n {{ return(adapter.dispatch('get_batch_size', 'dbt')()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_batch_size"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4229662, "supported_languages": null}, "macro.dbt.default__get_batch_size": {"name": "default__get_batch_size", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__get_batch_size", "macro_sql": "{% macro default__get_batch_size() %}\n {{ return(10000) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4232259, "supported_languages": null}, "macro.dbt.get_seed_column_quoted_csv": {"name": "get_seed_column_quoted_csv", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.get_seed_column_quoted_csv", "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.424256, "supported_languages": null}, "macro.dbt.load_csv_rows": {"name": "load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.load_csv_rows", "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows', 'dbt')(model, agate_table) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__load_csv_rows"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4246578, "supported_languages": null}, "macro.dbt.default__load_csv_rows": {"name": "default__load_csv_rows", "resource_type": "macro", "package_name": "dbt", "path": "macros/materializations/seeds/helpers.sql", "original_file_path": "macros/materializations/seeds/helpers.sql", "unique_id": "macro.dbt.default__load_csv_rows", "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n\n {% set batch_size = get_batch_size() %}\n\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n {{ get_binding_char() }}\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_batch_size", "macro.dbt.get_seed_column_quoted_csv", "macro.dbt.get_binding_char"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4273484, "supported_languages": null}, "macro.dbt.default__test_unique": {"name": "default__test_unique", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/unique.sql", "original_file_path": "macros/generic_test_sql/unique.sql", "unique_id": "macro.dbt.default__test_unique", "macro_sql": "{% macro default__test_unique(model, column_name) %}\n\nselect\n {{ column_name }} as unique_field,\n count(*) as n_records\n\nfrom {{ model }}\nwhere {{ column_name }} is not null\ngroup by {{ column_name }}\nhaving count(*) > 1\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4278698, "supported_languages": null}, "macro.dbt.default__test_relationships": {"name": "default__test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/relationships.sql", "original_file_path": "macros/generic_test_sql/relationships.sql", "unique_id": "macro.dbt.default__test_relationships", "macro_sql": "{% macro default__test_relationships(model, column_name, to, field) %}\n\nwith child as (\n select {{ column_name }} as from_field\n from {{ model }}\n where {{ column_name }} is not null\n),\n\nparent as (\n select {{ field }} as to_field\n from {{ to }}\n)\n\nselect\n from_field\n\nfrom child\nleft join parent\n on child.from_field = parent.to_field\n\nwhere parent.to_field is null\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4285202, "supported_languages": null}, "macro.dbt.default__test_not_null": {"name": "default__test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/not_null.sql", "original_file_path": "macros/generic_test_sql/not_null.sql", "unique_id": "macro.dbt.default__test_not_null", "macro_sql": "{% macro default__test_not_null(model, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else column_name %}\n\nselect {{ column_list }}\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4291873, "supported_languages": null}, "macro.dbt.default__test_accepted_values": {"name": "default__test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "macros/generic_test_sql/accepted_values.sql", "original_file_path": "macros/generic_test_sql/accepted_values.sql", "unique_id": "macro.dbt.default__test_accepted_values", "macro_sql": "{% macro default__test_accepted_values(model, column_name, values, quote=True) %}\n\nwith all_values as (\n\n select\n {{ column_name }} as value_field,\n count(*) as n_records\n\n from {{ model }}\n group by {{ column_name }}\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n)\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4303296, "supported_languages": null}, "macro.dbt.length": {"name": "length", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "unique_id": "macro.dbt.length", "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__length"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4308598, "supported_languages": null}, "macro.dbt.default__length": {"name": "default__length", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/length.sql", "original_file_path": "macros/utils/length.sql", "unique_id": "macro.dbt.default__length", "macro_sql": "{% macro default__length(expression) %}\n\n length(\n {{ expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4310954, "supported_languages": null}, "macro.dbt.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4324613, "supported_languages": null}, "macro.dbt.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4334035, "supported_languages": null}, "macro.dbt.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4338143, "supported_languages": null}, "macro.dbt.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/generate_series.sql", "original_file_path": "macros/utils/generate_series.sql", "unique_id": "macro.dbt.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4349215, "supported_languages": null}, "macro.dbt.datediff": {"name": "datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "unique_id": "macro.dbt.datediff", "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', 'dbt')(first_date, second_date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4355795, "supported_languages": null}, "macro.dbt.default__datediff": {"name": "default__datediff", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/datediff.sql", "original_file_path": "macros/utils/datediff.sql", "unique_id": "macro.dbt.default__datediff", "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) -%}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.435952, "supported_languages": null}, "macro.dbt.split_part": {"name": "split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt.split_part", "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', 'dbt') (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.436862, "supported_languages": null}, "macro.dbt.default__split_part": {"name": "default__split_part", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt.default__split_part", "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4372685, "supported_languages": null}, "macro.dbt._split_part_negative": {"name": "_split_part_negative", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/split_part.sql", "original_file_path": "macros/utils/split_part.sql", "unique_id": "macro.dbt._split_part_negative", "macro_sql": "{% macro _split_part_negative(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n length({{ string_text }})\n - length(\n replace({{ string_text }}, {{ delimiter_text }}, '')\n ) + 2 + {{ part_number }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4377615, "supported_languages": null}, "macro.dbt.bool_or": {"name": "bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt.bool_or", "macro_sql": "{% macro bool_or(expression) -%}\n {{ return(adapter.dispatch('bool_or', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__bool_or"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4382734, "supported_languages": null}, "macro.dbt.default__bool_or": {"name": "default__bool_or", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/bool_or.sql", "original_file_path": "macros/utils/bool_or.sql", "unique_id": "macro.dbt.default__bool_or", "macro_sql": "{% macro default__bool_or(expression) -%}\n\n bool_or({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4385102, "supported_languages": null}, "macro.dbt.array_append": {"name": "array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "unique_id": "macro.dbt.array_append", "macro_sql": "{% macro array_append(array, new_element) -%}\n {{ return(adapter.dispatch('array_append', 'dbt')(array, new_element)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__array_append"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4390707, "supported_languages": null}, "macro.dbt.default__array_append": {"name": "default__array_append", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_append.sql", "original_file_path": "macros/utils/array_append.sql", "unique_id": "macro.dbt.default__array_append", "macro_sql": "{% macro default__array_append(array, new_element) -%}\n array_append({{ array }}, {{ new_element }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4393656, "supported_languages": null}, "macro.dbt.cast_bool_to_text": {"name": "cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "unique_id": "macro.dbt.cast_bool_to_text", "macro_sql": "{% macro cast_bool_to_text(field) %}\n {{ adapter.dispatch('cast_bool_to_text', 'dbt') (field) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4398746, "supported_languages": null}, "macro.dbt.default__cast_bool_to_text": {"name": "default__cast_bool_to_text", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/cast_bool_to_text.sql", "original_file_path": "macros/utils/cast_bool_to_text.sql", "unique_id": "macro.dbt.default__cast_bool_to_text", "macro_sql": "{% macro default__cast_bool_to_text(field) %}\n cast({{ field }} as {{ api.Column.translate_type('string') }})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4405224, "supported_languages": null}, "macro.dbt.type_string": {"name": "type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_string", "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4421473, "supported_languages": null}, "macro.dbt.default__type_string": {"name": "default__type_string", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_string", "macro_sql": "{% macro default__type_string() %}\n {{ return(api.Column.translate_type(\"string\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.442485, "supported_languages": null}, "macro.dbt.type_timestamp": {"name": "type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_timestamp", "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4428267, "supported_languages": null}, "macro.dbt.default__type_timestamp": {"name": "default__type_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() %}\n {{ return(api.Column.translate_type(\"timestamp\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4431553, "supported_languages": null}, "macro.dbt.type_float": {"name": "type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_float", "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_float"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4434965, "supported_languages": null}, "macro.dbt.default__type_float": {"name": "default__type_float", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_float", "macro_sql": "{% macro default__type_float() %}\n {{ return(api.Column.translate_type(\"float\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4438205, "supported_languages": null}, "macro.dbt.type_numeric": {"name": "type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_numeric", "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4441726, "supported_languages": null}, "macro.dbt.default__type_numeric": {"name": "default__type_numeric", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_numeric", "macro_sql": "{% macro default__type_numeric() %}\n {{ return(api.Column.numeric_type(\"numeric\", 28, 6)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4445536, "supported_languages": null}, "macro.dbt.type_bigint": {"name": "type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_bigint", "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_bigint"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.44491, "supported_languages": null}, "macro.dbt.default__type_bigint": {"name": "default__type_bigint", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_bigint", "macro_sql": "{% macro default__type_bigint() %}\n {{ return(api.Column.translate_type(\"bigint\")) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.445326, "supported_languages": null}, "macro.dbt.type_int": {"name": "type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_int", "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_int"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4456906, "supported_languages": null}, "macro.dbt.default__type_int": {"name": "default__type_int", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_int", "macro_sql": "{%- macro default__type_int() -%}\n {{ return(api.Column.translate_type(\"integer\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.446015, "supported_languages": null}, "macro.dbt.type_boolean": {"name": "type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.type_boolean", "macro_sql": "\n\n{%- macro type_boolean() -%}\n {{ return(adapter.dispatch('type_boolean', 'dbt')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__type_boolean"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4463716, "supported_languages": null}, "macro.dbt.default__type_boolean": {"name": "default__type_boolean", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/data_types.sql", "original_file_path": "macros/utils/data_types.sql", "unique_id": "macro.dbt.default__type_boolean", "macro_sql": "{%- macro default__type_boolean() -%}\n {{ return(api.Column.translate_type(\"boolean\")) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4466825, "supported_languages": null}, "macro.dbt.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4479194, "supported_languages": null}, "macro.dbt.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4491975, "supported_languages": null}, "macro.dbt.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4497938, "supported_languages": null}, "macro.dbt.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_spine.sql", "original_file_path": "macros/utils/date_spine.sql", "unique_id": "macro.dbt.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n {# call as follows:\n\n date_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n ) #}\n\n\n with rawdata as (\n\n {{dbt.generate_series(\n dbt.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n ),\n\n all_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n ),\n\n filtered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n )\n\n select * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.generate_series", "macro.dbt.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.450685, "supported_languages": null}, "macro.dbt.any_value": {"name": "any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "unique_id": "macro.dbt.any_value", "macro_sql": "{% macro any_value(expression) -%}\n {{ return(adapter.dispatch('any_value', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__any_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.451204, "supported_languages": null}, "macro.dbt.default__any_value": {"name": "default__any_value", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/any_value.sql", "original_file_path": "macros/utils/any_value.sql", "unique_id": "macro.dbt.default__any_value", "macro_sql": "{% macro default__any_value(expression) -%}\n\n any_value({{ expression }})\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.451433, "supported_languages": null}, "macro.dbt.safe_cast": {"name": "safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt.safe_cast", "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', 'dbt') (field, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__safe_cast"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4520192, "supported_languages": null}, "macro.dbt.default__safe_cast": {"name": "default__safe_cast", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/safe_cast.sql", "original_file_path": "macros/utils/safe_cast.sql", "unique_id": "macro.dbt.default__safe_cast", "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.452433, "supported_languages": null}, "macro.dbt.date_trunc": {"name": "date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "unique_id": "macro.dbt.date_trunc", "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', 'dbt') (datepart, date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4531443, "supported_languages": null}, "macro.dbt.default__date_trunc": {"name": "default__date_trunc", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/date_trunc.sql", "original_file_path": "macros/utils/date_trunc.sql", "unique_id": "macro.dbt.default__date_trunc", "macro_sql": "{% macro default__date_trunc(datepart, date) -%}\n date_trunc('{{datepart}}', {{date}})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4534423, "supported_languages": null}, "macro.dbt.string_literal": {"name": "string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "unique_id": "macro.dbt.string_literal", "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', 'dbt') (value)) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__string_literal"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4539373, "supported_languages": null}, "macro.dbt.default__string_literal": {"name": "default__string_literal", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/literal.sql", "original_file_path": "macros/utils/literal.sql", "unique_id": "macro.dbt.default__string_literal", "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4541607, "supported_languages": null}, "macro.dbt.listagg": {"name": "listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "unique_id": "macro.dbt.listagg", "macro_sql": "{% macro listagg(measure, delimiter_text=\"','\", order_by_clause=none, limit_num=none) -%}\n {{ return(adapter.dispatch('listagg', 'dbt') (measure, delimiter_text, order_by_clause, limit_num)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__listagg"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4552767, "supported_languages": null}, "macro.dbt.default__listagg": {"name": "default__listagg", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/listagg.sql", "original_file_path": "macros/utils/listagg.sql", "unique_id": "macro.dbt.default__listagg", "macro_sql": "{% macro default__listagg(measure, delimiter_text, order_by_clause, limit_num) -%}\n\n {% if limit_num -%}\n array_to_string(\n array_slice(\n array_agg(\n {{ measure }}\n ){% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n ,0\n ,{{ limit_num }}\n ),\n {{ delimiter_text }}\n )\n {%- else %}\n listagg(\n {{ measure }},\n {{ delimiter_text }}\n )\n {% if order_by_clause -%}\n within group ({{ order_by_clause }})\n {%- endif %}\n {%- endif %}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4562368, "supported_languages": null}, "macro.dbt.dateadd": {"name": "dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "unique_id": "macro.dbt.dateadd", "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', 'dbt')(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.45727, "supported_languages": null}, "macro.dbt.default__dateadd": {"name": "default__dateadd", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/dateadd.sql", "original_file_path": "macros/utils/dateadd.sql", "unique_id": "macro.dbt.default__dateadd", "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4577134, "supported_languages": null}, "macro.dbt.replace": {"name": "replace", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "unique_id": "macro.dbt.replace", "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', 'dbt') (field, old_chars, new_chars)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__replace"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.458887, "supported_languages": null}, "macro.dbt.default__replace": {"name": "default__replace", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/replace.sql", "original_file_path": "macros/utils/replace.sql", "unique_id": "macro.dbt.default__replace", "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4595602, "supported_languages": null}, "macro.dbt.last_day": {"name": "last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.last_day", "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', 'dbt') (date, datepart)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4607894, "supported_languages": null}, "macro.dbt.default_last_day": {"name": "default_last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.default_last_day", "macro_sql": "\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt.dateadd('day', '-1',\n dbt.dateadd(datepart, '1', dbt.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.date_trunc"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4618204, "supported_languages": null}, "macro.dbt.default__last_day": {"name": "default__last_day", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/last_day.sql", "original_file_path": "macros/utils/last_day.sql", "unique_id": "macro.dbt.default__last_day", "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt.default_last_day(date, datepart)}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default_last_day"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4624066, "supported_languages": null}, "macro.dbt.right": {"name": "right", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt.right", "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', 'dbt') (string_text, length_expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__right"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4634938, "supported_languages": null}, "macro.dbt.default__right": {"name": "default__right", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/right.sql", "original_file_path": "macros/utils/right.sql", "unique_id": "macro.dbt.default__right", "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.464048, "supported_languages": null}, "macro.dbt.concat": {"name": "concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "unique_id": "macro.dbt.concat", "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', 'dbt')(fields)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.464962, "supported_languages": null}, "macro.dbt.default__concat": {"name": "default__concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/concat.sql", "original_file_path": "macros/utils/concat.sql", "unique_id": "macro.dbt.default__concat", "macro_sql": "{% macro default__concat(fields) -%}\n {{ fields|join(' || ') }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4654868, "supported_languages": null}, "macro.dbt.except": {"name": "except", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "unique_id": "macro.dbt.except", "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4661658, "supported_languages": null}, "macro.dbt.default__except": {"name": "default__except", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/except.sql", "original_file_path": "macros/utils/except.sql", "unique_id": "macro.dbt.default__except", "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.466452, "supported_languages": null}, "macro.dbt.array_construct": {"name": "array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt.array_construct", "macro_sql": "{% macro array_construct(inputs=[], data_type=api.Column.translate_type('integer')) -%}\n {{ return(adapter.dispatch('array_construct', 'dbt')(inputs, data_type)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__array_construct"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4673073, "supported_languages": null}, "macro.dbt.default__array_construct": {"name": "default__array_construct", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_construct.sql", "original_file_path": "macros/utils/array_construct.sql", "unique_id": "macro.dbt.default__array_construct", "macro_sql": "{% macro default__array_construct(inputs, data_type) -%}\n {% if inputs|length > 0 %}\n array[ {{ inputs|join(' , ') }} ]\n {% else %}\n array[]::{{data_type}}[]\n {% endif %}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.46829, "supported_languages": null}, "macro.dbt.intersect": {"name": "intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "unique_id": "macro.dbt.intersect", "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__intersect"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4691658, "supported_languages": null}, "macro.dbt.default__intersect": {"name": "default__intersect", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/intersect.sql", "original_file_path": "macros/utils/intersect.sql", "unique_id": "macro.dbt.default__intersect", "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4694617, "supported_languages": null}, "macro.dbt.hash": {"name": "hash", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "unique_id": "macro.dbt.hash", "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', 'dbt') (field)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__hash"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4702783, "supported_languages": null}, "macro.dbt.default__hash": {"name": "default__hash", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/hash.sql", "original_file_path": "macros/utils/hash.sql", "unique_id": "macro.dbt.default__hash", "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{ field }} as {{ api.Column.translate_type('string') }}))\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4707723, "supported_languages": null}, "macro.dbt.array_concat": {"name": "array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "unique_id": "macro.dbt.array_concat", "macro_sql": "{% macro array_concat(array_1, array_2) -%}\n {{ return(adapter.dispatch('array_concat', 'dbt')(array_1, array_2)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__array_concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4715087, "supported_languages": null}, "macro.dbt.default__array_concat": {"name": "default__array_concat", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/array_concat.sql", "original_file_path": "macros/utils/array_concat.sql", "unique_id": "macro.dbt.default__array_concat", "macro_sql": "{% macro default__array_concat(array_1, array_2) -%}\n array_cat({{ array_1 }}, {{ array_2 }})\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4719594, "supported_languages": null}, "macro.dbt.position": {"name": "position", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "unique_id": "macro.dbt.position", "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', 'dbt') (substring_text, string_text)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__position"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.472673, "supported_languages": null}, "macro.dbt.default__position": {"name": "default__position", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/position.sql", "original_file_path": "macros/utils/position.sql", "unique_id": "macro.dbt.default__position", "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4731948, "supported_languages": null}, "macro.dbt.escape_single_quotes": {"name": "escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt.escape_single_quotes", "macro_sql": "{% macro escape_single_quotes(expression) %}\n {{ return(adapter.dispatch('escape_single_quotes', 'dbt') (expression)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__escape_single_quotes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4740646, "supported_languages": null}, "macro.dbt.default__escape_single_quotes": {"name": "default__escape_single_quotes", "resource_type": "macro", "package_name": "dbt", "path": "macros/utils/escape_single_quotes.sql", "original_file_path": "macros/utils/escape_single_quotes.sql", "unique_id": "macro.dbt.default__escape_single_quotes", "macro_sql": "{% macro default__escape_single_quotes(expression) -%}\n{{ expression | replace(\"'\",\"''\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4745345, "supported_languages": null}, "macro.dbt.make_intermediate_relation": {"name": "make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_intermediate_relation", "macro_sql": "{% macro make_intermediate_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_intermediate_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_intermediate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4791777, "supported_languages": null}, "macro.dbt.default__make_intermediate_relation": {"name": "default__make_intermediate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_intermediate_relation", "macro_sql": "{% macro default__make_intermediate_relation(base_relation, suffix) %}\n {{ return(default__make_temp_relation(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4797115, "supported_languages": null}, "macro.dbt.make_temp_relation": {"name": "make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_temp_relation", "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation', 'dbt')(base_relation, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__make_temp_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.480459, "supported_languages": null}, "macro.dbt.default__make_temp_relation": {"name": "default__make_temp_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_temp_relation", "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {%- set temp_identifier = base_relation.identifier ~ suffix -%}\n {%- set temp_relation = base_relation.incorporate(\n path={\"identifier\": temp_identifier}) -%}\n\n {{ return(temp_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4815214, "supported_languages": null}, "macro.dbt.make_backup_relation": {"name": "make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.make_backup_relation", "macro_sql": "{% macro make_backup_relation(base_relation, backup_relation_type, suffix='__dbt_backup') %}\n {{ return(adapter.dispatch('make_backup_relation', 'dbt')(base_relation, backup_relation_type, suffix)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__make_backup_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4823756, "supported_languages": null}, "macro.dbt.default__make_backup_relation": {"name": "default__make_backup_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__make_backup_relation", "macro_sql": "{% macro default__make_backup_relation(base_relation, backup_relation_type, suffix) %}\n {%- set backup_identifier = base_relation.identifier ~ suffix -%}\n {%- set backup_relation = base_relation.incorporate(\n path={\"identifier\": backup_identifier},\n type=backup_relation_type\n ) -%}\n {{ return(backup_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4833832, "supported_languages": null}, "macro.dbt.truncate_relation": {"name": "truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__truncate_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4839547, "supported_languages": null}, "macro.dbt.default__truncate_relation": {"name": "default__truncate_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__truncate_relation", "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4843714, "supported_languages": null}, "macro.dbt.get_or_create_relation": {"name": "get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.get_or_create_relation", "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) -%}\n {{ return(adapter.dispatch('get_or_create_relation', 'dbt')(database, schema, identifier, type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_or_create_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.484986, "supported_languages": null}, "macro.dbt.default__get_or_create_relation": {"name": "default__get_or_create_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.default__get_or_create_relation", "macro_sql": "{% macro default__get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4868891, "supported_languages": null}, "macro.dbt.load_cached_relation": {"name": "load_cached_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.load_cached_relation", "macro_sql": "{% macro load_cached_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4877708, "supported_languages": null}, "macro.dbt.load_relation": {"name": "load_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/relation.sql", "original_file_path": "macros/adapters/relation.sql", "unique_id": "macro.dbt.load_relation", "macro_sql": "{% macro load_relation(relation) %}\n {{ return(load_cached_relation(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.load_cached_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4883428, "supported_languages": null}, "macro.dbt.alter_column_comment": {"name": "alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.alter_column_comment", "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment', 'dbt')(relation, column_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4902673, "supported_languages": null}, "macro.dbt.default__alter_column_comment": {"name": "default__alter_column_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__alter_column_comment", "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4908524, "supported_languages": null}, "macro.dbt.alter_relation_comment": {"name": "alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.alter_relation_comment", "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment', 'dbt')(relation, relation_comment)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__alter_relation_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.49163, "supported_languages": null}, "macro.dbt.default__alter_relation_comment": {"name": "default__alter_relation_comment", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__alter_relation_comment", "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4920382, "supported_languages": null}, "macro.dbt.persist_docs": {"name": "persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.persist_docs", "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs', 'dbt')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__persist_docs"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4926465, "supported_languages": null}, "macro.dbt.default__persist_docs": {"name": "default__persist_docs", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/persist_docs.sql", "original_file_path": "macros/adapters/persist_docs.sql", "unique_id": "macro.dbt.default__persist_docs", "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.alter_relation_comment", "macro.dbt.alter_column_comment"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4938066, "supported_languages": null}, "macro.dbt.get_create_index_sql": {"name": "get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_create_index_sql", "macro_sql": "{% macro get_create_index_sql(relation, index_dict) -%}\n {{ return(adapter.dispatch('get_create_index_sql', 'dbt')(relation, index_dict)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4962852, "supported_languages": null}, "macro.dbt.default__get_create_index_sql": {"name": "default__get_create_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_create_index_sql", "macro_sql": "{% macro default__get_create_index_sql(relation, index_dict) -%}\n {% do return(None) %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4968514, "supported_languages": null}, "macro.dbt.create_indexes": {"name": "create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.create_indexes", "macro_sql": "{% macro create_indexes(relation) -%}\n {{ adapter.dispatch('create_indexes', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__create_indexes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4974992, "supported_languages": null}, "macro.dbt.default__create_indexes": {"name": "default__create_indexes", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__create_indexes", "macro_sql": "{% macro default__create_indexes(relation) -%}\n {%- set _indexes = config.get('indexes', default=[]) -%}\n\n {% for _index_dict in _indexes %}\n {% set create_index_sql = get_create_index_sql(relation, _index_dict) %}\n {% if create_index_sql %}\n {% do run_query(create_index_sql) %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_create_index_sql", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4990861, "supported_languages": null}, "macro.dbt.get_drop_index_sql": {"name": "get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_drop_index_sql", "macro_sql": "{% macro get_drop_index_sql(relation, index_name) -%}\n {{ adapter.dispatch('get_drop_index_sql', 'dbt')(relation, index_name) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_drop_index_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4995477, "supported_languages": null}, "macro.dbt.default__get_drop_index_sql": {"name": "default__get_drop_index_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_drop_index_sql", "macro_sql": "{% macro default__get_drop_index_sql(relation, index_name) -%}\n {{ exceptions.raise_compiler_error(\"`get_drop_index_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.4998603, "supported_languages": null}, "macro.dbt.get_show_indexes_sql": {"name": "get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.get_show_indexes_sql", "macro_sql": "{% macro get_show_indexes_sql(relation) -%}\n {{ adapter.dispatch('get_show_indexes_sql', 'dbt')(relation) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_show_indexes_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.500201, "supported_languages": null}, "macro.dbt.default__get_show_indexes_sql": {"name": "default__get_show_indexes_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/indexes.sql", "original_file_path": "macros/adapters/indexes.sql", "unique_id": "macro.dbt.default__get_show_indexes_sql", "macro_sql": "{% macro default__get_show_indexes_sql(relation) -%}\n {{ exceptions.raise_compiler_error(\"`get_show_indexes_sql has not been implemented for this adapter.\") }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.50048, "supported_languages": null}, "macro.dbt.copy_grants": {"name": "copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.copy_grants", "macro_sql": "{% macro copy_grants() %}\n {{ return(adapter.dispatch('copy_grants', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5033524, "supported_languages": null}, "macro.dbt.default__copy_grants": {"name": "default__copy_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__copy_grants", "macro_sql": "{% macro default__copy_grants() %}\n {{ return(True) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5036263, "supported_languages": null}, "macro.dbt.support_multiple_grantees_per_dcl_statement": {"name": "support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.support_multiple_grantees_per_dcl_statement", "macro_sql": "{% macro support_multiple_grantees_per_dcl_statement() %}\n {{ return(adapter.dispatch('support_multiple_grantees_per_dcl_statement', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5039856, "supported_languages": null}, "macro.dbt.default__support_multiple_grantees_per_dcl_statement": {"name": "default__support_multiple_grantees_per_dcl_statement", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__support_multiple_grantees_per_dcl_statement", "macro_sql": "\n\n{%- macro default__support_multiple_grantees_per_dcl_statement() -%}\n {{ return(True) }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5042408, "supported_languages": null}, "macro.dbt.should_revoke": {"name": "should_revoke", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.should_revoke", "macro_sql": "{% macro should_revoke(existing_relation, full_refresh_mode=True) %}\n\n {% if not existing_relation %}\n {#-- The table doesn't already exist, so no grants to copy over --#}\n {{ return(False) }}\n {% elif full_refresh_mode %}\n {#-- The object is being REPLACED -- whether grants are copied over depends on the value of user config --#}\n {{ return(copy_grants()) }}\n {% else %}\n {#-- The table is being merged/upserted/inserted -- grants will be carried over --#}\n {{ return(True) }}\n {% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.copy_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.50507, "supported_languages": null}, "macro.dbt.get_show_grant_sql": {"name": "get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_show_grant_sql", "macro_sql": "{% macro get_show_grant_sql(relation) %}\n {{ return(adapter.dispatch(\"get_show_grant_sql\", \"dbt\")(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_show_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.505829, "supported_languages": null}, "macro.dbt.default__get_show_grant_sql": {"name": "default__get_show_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_show_grant_sql", "macro_sql": "{% macro default__get_show_grant_sql(relation) %}\n show grants on {{ relation }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5060954, "supported_languages": null}, "macro.dbt.get_grant_sql": {"name": "get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_grant_sql", "macro_sql": "{% macro get_grant_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_grant_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_grant_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5065856, "supported_languages": null}, "macro.dbt.default__get_grant_sql": {"name": "default__get_grant_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_grant_sql", "macro_sql": "\n\n{%- macro default__get_grant_sql(relation, privilege, grantees) -%}\n grant {{ privilege }} on {{ relation }} to {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5069952, "supported_languages": null}, "macro.dbt.get_revoke_sql": {"name": "get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_revoke_sql", "macro_sql": "{% macro get_revoke_sql(relation, privilege, grantees) %}\n {{ return(adapter.dispatch('get_revoke_sql', 'dbt')(relation, privilege, grantees)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_revoke_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5074852, "supported_languages": null}, "macro.dbt.default__get_revoke_sql": {"name": "default__get_revoke_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_revoke_sql", "macro_sql": "\n\n{%- macro default__get_revoke_sql(relation, privilege, grantees) -%}\n revoke {{ privilege }} on {{ relation }} from {{ grantees | join(', ') }}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5078878, "supported_languages": null}, "macro.dbt.get_dcl_statement_list": {"name": "get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.get_dcl_statement_list", "macro_sql": "{% macro get_dcl_statement_list(relation, grant_config, get_dcl_macro) %}\n {{ return(adapter.dispatch('get_dcl_statement_list', 'dbt')(relation, grant_config, get_dcl_macro)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_dcl_statement_list"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.508373, "supported_languages": null}, "macro.dbt.default__get_dcl_statement_list": {"name": "default__get_dcl_statement_list", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__get_dcl_statement_list", "macro_sql": "\n\n{%- macro default__get_dcl_statement_list(relation, grant_config, get_dcl_macro) -%}\n {#\n -- Unpack grant_config into specific privileges and the set of users who need them granted/revoked.\n -- Depending on whether this database supports multiple grantees per statement, pass in the list of\n -- all grantees per privilege, or (if not) template one statement per privilege-grantee pair.\n -- `get_dcl_macro` will be either `get_grant_sql` or `get_revoke_sql`\n #}\n {%- set dcl_statements = [] -%}\n {%- for privilege, grantees in grant_config.items() %}\n {%- if support_multiple_grantees_per_dcl_statement() and grantees -%}\n {%- set dcl = get_dcl_macro(relation, privilege, grantees) -%}\n {%- do dcl_statements.append(dcl) -%}\n {%- else -%}\n {%- for grantee in grantees -%}\n {% set dcl = get_dcl_macro(relation, privilege, [grantee]) %}\n {%- do dcl_statements.append(dcl) -%}\n {% endfor -%}\n {%- endif -%}\n {%- endfor -%}\n {{ return(dcl_statements) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.support_multiple_grantees_per_dcl_statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5099792, "supported_languages": null}, "macro.dbt.call_dcl_statements": {"name": "call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.call_dcl_statements", "macro_sql": "{% macro call_dcl_statements(dcl_statement_list) %}\n {{ return(adapter.dispatch(\"call_dcl_statements\", \"dbt\")(dcl_statement_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.510394, "supported_languages": null}, "macro.dbt.default__call_dcl_statements": {"name": "default__call_dcl_statements", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__call_dcl_statements", "macro_sql": "{% macro default__call_dcl_statements(dcl_statement_list) %}\n {#\n -- By default, supply all grant + revoke statements in a single semicolon-separated block,\n -- so that they're all processed together.\n\n -- Some databases do not support this. Those adapters will need to override this macro\n -- to run each statement individually.\n #}\n {% call statement('grants') %}\n {% for dcl_statement in dcl_statement_list %}\n {{ dcl_statement }};\n {% endfor %}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5109391, "supported_languages": null}, "macro.dbt.apply_grants": {"name": "apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.apply_grants", "macro_sql": "{% macro apply_grants(relation, grant_config, should_revoke) %}\n {{ return(adapter.dispatch(\"apply_grants\", \"dbt\")(relation, grant_config, should_revoke)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.511425, "supported_languages": null}, "macro.dbt.default__apply_grants": {"name": "default__apply_grants", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/apply_grants.sql", "original_file_path": "macros/adapters/apply_grants.sql", "unique_id": "macro.dbt.default__apply_grants", "macro_sql": "{% macro default__apply_grants(relation, grant_config, should_revoke=True) %}\n {#-- If grant_config is {} or None, this is a no-op --#}\n {% if grant_config %}\n {% if should_revoke %}\n {#-- We think previous grants may have carried over --#}\n {#-- Show current grants and calculate diffs --#}\n {% set current_grants_table = run_query(get_show_grant_sql(relation)) %}\n {% set current_grants_dict = adapter.standardize_grants_dict(current_grants_table) %}\n {% set needs_granting = diff_of_two_dicts(grant_config, current_grants_dict) %}\n {% set needs_revoking = diff_of_two_dicts(current_grants_dict, grant_config) %}\n {% if not (needs_granting or needs_revoking) %}\n {{ log('On ' ~ relation ~': All grants are in place, no revocation or granting needed.')}}\n {% endif %}\n {% else %}\n {#-- We don't think there's any chance of previous grants having carried over. --#}\n {#-- Jump straight to granting what the user has configured. --#}\n {% set needs_revoking = {} %}\n {% set needs_granting = grant_config %}\n {% endif %}\n {% if needs_granting or needs_revoking %}\n {% set revoke_statement_list = get_dcl_statement_list(relation, needs_revoking, get_revoke_sql) %}\n {% set grant_statement_list = get_dcl_statement_list(relation, needs_granting, get_grant_sql) %}\n {% set dcl_statement_list = revoke_statement_list + grant_statement_list %}\n {% if dcl_statement_list %}\n {{ call_dcl_statements(dcl_statement_list) }}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query", "macro.dbt.get_show_grant_sql", "macro.dbt.get_dcl_statement_list", "macro.dbt.call_dcl_statements"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.513944, "supported_languages": null}, "macro.dbt.get_show_sql": {"name": "get_show_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.get_show_sql", "macro_sql": "{% macro get_show_sql(compiled_code, sql_header, limit) -%}\n {%- if sql_header -%}\n {{ sql_header }}\n {%- endif -%}\n {%- if limit is not none -%}\n {{ get_limit_subquery_sql(compiled_code, limit) }}\n {%- else -%}\n {{ compiled_code }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_limit_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.514972, "supported_languages": null}, "macro.dbt.get_limit_subquery_sql": {"name": "get_limit_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.get_limit_subquery_sql", "macro_sql": "{% macro get_limit_subquery_sql(sql, limit) %}\n {{ adapter.dispatch('get_limit_subquery_sql', 'dbt')(sql, limit) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_limit_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5153987, "supported_languages": null}, "macro.dbt.default__get_limit_subquery_sql": {"name": "default__get_limit_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/show.sql", "original_file_path": "macros/adapters/show.sql", "unique_id": "macro.dbt.default__get_limit_subquery_sql", "macro_sql": "{% macro default__get_limit_subquery_sql(sql, limit) %}\n select *\n from (\n {{ sql }}\n ) as model_limit_subq\n limit {{ limit }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5157015, "supported_languages": null}, "macro.dbt.create_schema": {"name": "create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.create_schema", "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__create_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5164263, "supported_languages": null}, "macro.dbt.default__create_schema": {"name": "default__create_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.default__create_schema", "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5168297, "supported_languages": null}, "macro.dbt.drop_schema": {"name": "drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.drop_schema", "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema', 'dbt')(relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__drop_schema"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.517228, "supported_languages": null}, "macro.dbt.default__drop_schema": {"name": "default__drop_schema", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/schema.sql", "original_file_path": "macros/adapters/schema.sql", "unique_id": "macro.dbt.default__drop_schema", "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5176418, "supported_languages": null}, "macro.dbt.current_timestamp": {"name": "current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp", "macro_sql": "{%- macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5185177, "supported_languages": null}, "macro.dbt.default__current_timestamp": {"name": "default__current_timestamp", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter ' + adapter.type()) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5188456, "supported_languages": null}, "macro.dbt.snapshot_get_time": {"name": "snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.snapshot_get_time", "macro_sql": "\n\n{%- macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__snapshot_get_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.519157, "supported_languages": null}, "macro.dbt.default__snapshot_get_time": {"name": "default__snapshot_get_time", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__snapshot_get_time", "macro_sql": "{% macro default__snapshot_get_time() %}\n {{ current_timestamp() }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.519398, "supported_languages": null}, "macro.dbt.current_timestamp_backcompat": {"name": "current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp_backcompat", "macro_sql": "{% macro current_timestamp_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.519765, "supported_languages": null}, "macro.dbt.default__current_timestamp_backcompat": {"name": "default__current_timestamp_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_backcompat", "macro_sql": "{% macro default__current_timestamp_backcompat() %}\n current_timestamp::timestamp\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5200624, "supported_languages": null}, "macro.dbt.current_timestamp_in_utc_backcompat": {"name": "current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.current_timestamp_in_utc_backcompat", "macro_sql": "{% macro current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_in_utc_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__current_timestamp_in_utc_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.520429, "supported_languages": null}, "macro.dbt.default__current_timestamp_in_utc_backcompat": {"name": "default__current_timestamp_in_utc_backcompat", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/timestamps.sql", "original_file_path": "macros/adapters/timestamps.sql", "unique_id": "macro.dbt.default__current_timestamp_in_utc_backcompat", "macro_sql": "{% macro default__current_timestamp_in_utc_backcompat() %}\n {{ return(adapter.dispatch('current_timestamp_backcompat', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.current_timestamp_backcompat", "macro.dbt.default__current_timestamp_backcompat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5207841, "supported_languages": null}, "macro.dbt.validate_sql": {"name": "validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/validate_sql.sql", "original_file_path": "macros/adapters/validate_sql.sql", "unique_id": "macro.dbt.validate_sql", "macro_sql": "{% macro validate_sql(sql) -%}\n {{ return(adapter.dispatch('validate_sql', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__validate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5213873, "supported_languages": null}, "macro.dbt.default__validate_sql": {"name": "default__validate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/validate_sql.sql", "original_file_path": "macros/adapters/validate_sql.sql", "unique_id": "macro.dbt.default__validate_sql", "macro_sql": "{% macro default__validate_sql(sql) -%}\n {% call statement('validate_sql') -%}\n explain {{ sql }}\n {% endcall %}\n {{ return(load_result('validate_sql')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5218697, "supported_languages": null}, "macro.dbt.collect_freshness": {"name": "collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "unique_id": "macro.dbt.collect_freshness", "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness', 'dbt')(source, loaded_at_field, filter))}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__collect_freshness"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.522681, "supported_languages": null}, "macro.dbt.default__collect_freshness": {"name": "default__collect_freshness", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/freshness.sql", "original_file_path": "macros/adapters/freshness.sql", "unique_id": "macro.dbt.default__collect_freshness", "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness')) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.current_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5235648, "supported_languages": null}, "macro.dbt.get_catalog_relations": {"name": "get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog_relations", "macro_sql": "{% macro get_catalog_relations(information_schema, relations) -%}\n {{ return(adapter.dispatch('get_catalog_relations', 'dbt')(information_schema, relations)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_catalog_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5277398, "supported_languages": null}, "macro.dbt.default__get_catalog_relations": {"name": "default__get_catalog_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog_relations", "macro_sql": "{% macro default__get_catalog_relations(information_schema, relations) -%}\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog_relations not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5283065, "supported_languages": null}, "macro.dbt.get_catalog": {"name": "get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_catalog", "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog', 'dbt')(information_schema, schemas)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_catalog"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5287375, "supported_languages": null}, "macro.dbt.default__get_catalog": {"name": "default__get_catalog", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_catalog", "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5293322, "supported_languages": null}, "macro.dbt.information_schema_name": {"name": "information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.information_schema_name", "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__information_schema_name"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5297458, "supported_languages": null}, "macro.dbt.default__information_schema_name": {"name": "default__information_schema_name", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__information_schema_name", "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5300856, "supported_languages": null}, "macro.dbt.list_schemas": {"name": "list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.list_schemas", "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas', 'dbt')(database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__list_schemas"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.530467, "supported_languages": null}, "macro.dbt.default__list_schemas": {"name": "default__list_schemas", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__list_schemas", "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.information_schema_name", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.531115, "supported_languages": null}, "macro.dbt.check_schema_exists": {"name": "check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.check_schema_exists", "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists', 'dbt')(information_schema, schema)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__check_schema_exists"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5318062, "supported_languages": null}, "macro.dbt.default__check_schema_exists": {"name": "default__check_schema_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__check_schema_exists", "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5328648, "supported_languages": null}, "macro.dbt.list_relations_without_caching": {"name": "list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.list_relations_without_caching", "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching', 'dbt')(schema_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__list_relations_without_caching"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.533531, "supported_languages": null}, "macro.dbt.default__list_relations_without_caching": {"name": "default__list_relations_without_caching", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__list_relations_without_caching", "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5341072, "supported_languages": null}, "macro.dbt.get_relations": {"name": "get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_relations", "macro_sql": "{% macro get_relations() %}\n {{ return(adapter.dispatch('get_relations', 'dbt')()) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5347087, "supported_languages": null}, "macro.dbt.default__get_relations": {"name": "default__get_relations", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_relations", "macro_sql": "{% macro default__get_relations() %}\n {{ exceptions.raise_not_implemented(\n 'get_relations macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5352643, "supported_languages": null}, "macro.dbt.get_relation_last_modified": {"name": "get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.get_relation_last_modified", "macro_sql": "{% macro get_relation_last_modified(information_schema, relations) %}\n {{ return(adapter.dispatch('get_relation_last_modified', 'dbt')(information_schema, relations)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_relation_last_modified"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5361345, "supported_languages": null}, "macro.dbt.default__get_relation_last_modified": {"name": "default__get_relation_last_modified", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/metadata.sql", "original_file_path": "macros/adapters/metadata.sql", "unique_id": "macro.dbt.default__get_relation_last_modified", "macro_sql": "{% macro default__get_relation_last_modified(information_schema, relations) %}\n {{ exceptions.raise_not_implemented(\n 'get_relation_last_modified macro not implemented for adapter ' + adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5367653, "supported_languages": null}, "macro.dbt.get_columns_in_relation": {"name": "get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_columns_in_relation", "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5404027, "supported_languages": null}, "macro.dbt.default__get_columns_in_relation": {"name": "default__get_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_columns_in_relation", "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.54076, "supported_languages": null}, "macro.dbt.sql_convert_columns_in_relation": {"name": "sql_convert_columns_in_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.sql_convert_columns_in_relation", "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5414672, "supported_languages": null}, "macro.dbt.get_empty_subquery_sql": {"name": "get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_empty_subquery_sql", "macro_sql": "{% macro get_empty_subquery_sql(select_sql, select_sql_header=none) -%}\n {{ return(adapter.dispatch('get_empty_subquery_sql', 'dbt')(select_sql, select_sql_header)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.541935, "supported_languages": null}, "macro.dbt.default__get_empty_subquery_sql": {"name": "default__get_empty_subquery_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_empty_subquery_sql", "macro_sql": "{% macro default__get_empty_subquery_sql(select_sql, select_sql_header=none) %}\n {%- if select_sql_header is not none -%}\n {{ select_sql_header }}\n {%- endif -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5423977, "supported_languages": null}, "macro.dbt.get_empty_schema_sql": {"name": "get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_empty_schema_sql", "macro_sql": "{% macro get_empty_schema_sql(columns) -%}\n {{ return(adapter.dispatch('get_empty_schema_sql', 'dbt')(columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_empty_schema_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.542781, "supported_languages": null}, "macro.dbt.default__get_empty_schema_sql": {"name": "default__get_empty_schema_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_empty_schema_sql", "macro_sql": "{% macro default__get_empty_schema_sql(columns) %}\n {%- set col_err = [] -%}\n {%- set col_naked_numeric = [] -%}\n select\n {% for i in columns %}\n {%- set col = columns[i] -%}\n {%- if col['data_type'] is not defined -%}\n {%- do col_err.append(col['name']) -%}\n {#-- If this column's type is just 'numeric' then it is missing precision/scale, raise a warning --#}\n {%- elif col['data_type'].strip().lower() in ('numeric', 'decimal', 'number') -%}\n {%- do col_naked_numeric.append(col['name']) -%}\n {%- endif -%}\n {% set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] %}\n cast(null as {{ col['data_type'] }}) as {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n {%- if (col_err | length) > 0 -%}\n {{ exceptions.column_type_missing(column_names=col_err) }}\n {%- elif (col_naked_numeric | length) > 0 -%}\n {{ exceptions.warn(\"Detected columns with numeric type and unspecified precision/scale, this can lead to unintended rounding: \" ~ col_naked_numeric ~ \"`\") }}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5452034, "supported_languages": null}, "macro.dbt.get_column_schema_from_query": {"name": "get_column_schema_from_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_column_schema_from_query", "macro_sql": "{% macro get_column_schema_from_query(select_sql, select_sql_header=none) -%}\n {% set columns = [] %}\n {# -- Using an 'empty subquery' here to get the same schema as the given select_sql statement, without necessitating a data scan.#}\n {% set sql = get_empty_subquery_sql(select_sql, select_sql_header) %}\n {% set column_schema = adapter.get_column_schema_from_query(sql) %}\n {{ return(column_schema) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5459461, "supported_languages": null}, "macro.dbt.get_columns_in_query": {"name": "get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.get_columns_in_query", "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query', 'dbt')(select_sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_columns_in_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.546348, "supported_languages": null}, "macro.dbt.default__get_columns_in_query": {"name": "default__get_columns_in_query", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__get_columns_in_query", "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n {{ get_empty_subquery_sql(select_sql) }}\n {% endcall %}\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_empty_subquery_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.547085, "supported_languages": null}, "macro.dbt.alter_column_type": {"name": "alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.alter_column_type", "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type', 'dbt')(relation, column_name, new_column_type)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__alter_column_type"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.547561, "supported_languages": null}, "macro.dbt.default__alter_column_type": {"name": "default__alter_column_type", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__alter_column_type", "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5488272, "supported_languages": null}, "macro.dbt.alter_relation_add_remove_columns": {"name": "alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.alter_relation_add_remove_columns", "macro_sql": "{% macro alter_relation_add_remove_columns(relation, add_columns = none, remove_columns = none) -%}\n {{ return(adapter.dispatch('alter_relation_add_remove_columns', 'dbt')(relation, add_columns, remove_columns)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__alter_relation_add_remove_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5493994, "supported_languages": null}, "macro.dbt.default__alter_relation_add_remove_columns": {"name": "default__alter_relation_add_remove_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/adapters/columns.sql", "original_file_path": "macros/adapters/columns.sql", "unique_id": "macro.dbt.default__alter_relation_add_remove_columns", "macro_sql": "{% macro default__alter_relation_add_remove_columns(relation, add_columns, remove_columns) %}\n\n {% if add_columns is none %}\n {% set add_columns = [] %}\n {% endif %}\n {% if remove_columns is none %}\n {% set remove_columns = [] %}\n {% endif %}\n\n {% set sql -%}\n\n alter {{ relation.type }} {{ relation }}\n\n {% for column in add_columns %}\n add column {{ column.name }} {{ column.data_type }}{{ ',' if not loop.last }}\n {% endfor %}{{ ',' if add_columns and remove_columns }}\n\n {% for column in remove_columns %}\n drop column {{ column.name }}{{ ',' if not loop.last }}\n {% endfor %}\n\n {%- endset -%}\n\n {% do run_query(sql) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5511029, "supported_languages": null}, "macro.dbt.get_rename_intermediate_sql": {"name": "get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename_intermediate.sql", "original_file_path": "macros/relations/rename_intermediate.sql", "unique_id": "macro.dbt.get_rename_intermediate_sql", "macro_sql": "{%- macro get_rename_intermediate_sql(relation) -%}\n {{- log('Applying RENAME INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_intermediate_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5517654, "supported_languages": null}, "macro.dbt.default__get_rename_intermediate_sql": {"name": "default__get_rename_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename_intermediate.sql", "original_file_path": "macros/relations/rename_intermediate.sql", "unique_id": "macro.dbt.default__get_rename_intermediate_sql", "macro_sql": "{%- macro default__get_rename_intermediate_sql(relation) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n {{ get_rename_sql(intermediate_relation, relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5522065, "supported_languages": null}, "macro.dbt.get_drop_backup_sql": {"name": "get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop_backup.sql", "original_file_path": "macros/relations/drop_backup.sql", "unique_id": "macro.dbt.get_drop_backup_sql", "macro_sql": "{%- macro get_drop_backup_sql(relation) -%}\n {{- log('Applying DROP BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_drop_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5528255, "supported_languages": null}, "macro.dbt.default__get_drop_backup_sql": {"name": "default__get_drop_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop_backup.sql", "original_file_path": "macros/relations/drop_backup.sql", "unique_id": "macro.dbt.default__get_drop_backup_sql", "macro_sql": "{%- macro default__get_drop_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n {{ get_drop_sql(backup_relation) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.553299, "supported_languages": null}, "macro.dbt.get_create_backup_sql": {"name": "get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_backup.sql", "original_file_path": "macros/relations/create_backup.sql", "unique_id": "macro.dbt.get_create_backup_sql", "macro_sql": "{%- macro get_create_backup_sql(relation) -%}\n {{- log('Applying CREATE BACKUP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_backup_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_backup_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5539644, "supported_languages": null}, "macro.dbt.default__get_create_backup_sql": {"name": "default__get_create_backup_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_backup.sql", "original_file_path": "macros/relations/create_backup.sql", "unique_id": "macro.dbt.default__get_create_backup_sql", "macro_sql": "{%- macro default__get_create_backup_sql(relation) -%}\n\n -- get the standard backup name\n {% set backup_relation = make_backup_relation(relation, relation.type) %}\n\n -- drop any pre-existing backup\n {{ get_drop_sql(backup_relation) }};\n\n {{ get_rename_sql(relation, backup_relation.identifier) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_backup_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5545416, "supported_languages": null}, "macro.dbt.get_create_sql": {"name": "get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt.get_create_sql", "macro_sql": "{%- macro get_create_sql(relation, sql) -%}\n {{- log('Applying CREATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5553977, "supported_languages": null}, "macro.dbt.default__get_create_sql": {"name": "default__get_create_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create.sql", "original_file_path": "macros/relations/create.sql", "unique_id": "macro.dbt.default__get_create_sql", "macro_sql": "{%- macro default__get_create_sql(relation, sql) -%}\n\n {%- if relation.is_view -%}\n {{ get_create_view_as_sql(relation, sql) }}\n\n {%- elif relation.is_table -%}\n {{ get_create_table_as_sql(False, relation, sql) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_create_materialized_view_as_sql(relation, sql) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_create_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.get_create_view_as_sql", "macro.dbt.get_create_table_as_sql", "macro.dbt.get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5564582, "supported_languages": null}, "macro.dbt.get_rename_sql": {"name": "get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.get_rename_sql", "macro_sql": "{%- macro get_rename_sql(relation, new_name) -%}\n {{- log('Applying RENAME to: ' ~ relation) -}}\n {{- adapter.dispatch('get_rename_sql', 'dbt')(relation, new_name) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_rename_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5577679, "supported_languages": null}, "macro.dbt.default__get_rename_sql": {"name": "default__get_rename_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.default__get_rename_sql", "macro_sql": "{%- macro default__get_rename_sql(relation, new_name) -%}\n\n {%- if relation.is_view -%}\n {{ get_rename_view_sql(relation, new_name) }}\n\n {%- elif relation.is_table -%}\n {{ get_rename_table_sql(relation, new_name) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ get_rename_materialized_view_sql(relation, new_name) }}\n\n {%- else -%}\n {{- exceptions.raise_compiler_error(\"`get_rename_sql` has not been implemented for: \" ~ relation.type ) -}}\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.get_rename_view_sql", "macro.dbt.get_rename_table_sql", "macro.dbt.get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5586815, "supported_languages": null}, "macro.dbt.rename_relation": {"name": "rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.rename_relation", "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation', 'dbt')(from_relation, to_relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__rename_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5591233, "supported_languages": null}, "macro.dbt.default__rename_relation": {"name": "default__rename_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/rename.sql", "original_file_path": "macros/relations/rename.sql", "unique_id": "macro.dbt.default__rename_relation", "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5597224, "supported_languages": null}, "macro.dbt.get_replace_sql": {"name": "get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt.get_replace_sql", "macro_sql": "{% macro get_replace_sql(existing_relation, target_relation, sql) %}\n {{- log('Applying REPLACE to: ' ~ existing_relation) -}}\n {{- adapter.dispatch('get_replace_sql', 'dbt')(existing_relation, target_relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.561086, "supported_languages": null}, "macro.dbt.default__get_replace_sql": {"name": "default__get_replace_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/replace.sql", "original_file_path": "macros/relations/replace.sql", "unique_id": "macro.dbt.default__get_replace_sql", "macro_sql": "{% macro default__get_replace_sql(existing_relation, target_relation, sql) %}\n\n {# /* use a create or replace statement if possible */ #}\n\n {% set is_replaceable = existing_relation.type == target_relation_type and existing_relation.can_be_replaced %}\n\n {% if is_replaceable and existing_relation.is_view %}\n {{ get_replace_view_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_table %}\n {{ get_replace_table_sql(target_relation, sql) }}\n\n {% elif is_replaceable and existing_relation.is_materialized_view %}\n {{ get_replace_materialized_view_sql(target_relation, sql) }}\n\n {# /* a create or replace statement is not possible, so try to stage and/or backup to be safe */ #}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one using a backup */ #}\n {%- elif target_relation.can_be_renamed and existing_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* create target_relation as an intermediate relation, then swap it out with the existing one without using a backup */ #}\n {%- elif target_relation.can_be_renamed -%}\n {{ get_create_intermediate_sql(target_relation, sql) }};\n {{ get_drop_sql(existing_relation) }};\n {{ get_rename_intermediate_sql(target_relation) }}\n\n {# /* create target_relation in place by first backing up the existing relation */ #}\n {%- elif existing_relation.can_be_renamed -%}\n {{ get_create_backup_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }};\n {{ get_drop_backup_sql(existing_relation) }}\n\n {# /* no renaming is allowed, so just drop and create */ #}\n {%- else -%}\n {{ get_drop_sql(existing_relation) }};\n {{ get_create_sql(target_relation, sql) }}\n\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_replace_view_sql", "macro.dbt.get_replace_table_sql", "macro.dbt.get_replace_materialized_view_sql", "macro.dbt.get_create_intermediate_sql", "macro.dbt.get_create_backup_sql", "macro.dbt.get_rename_intermediate_sql", "macro.dbt.get_drop_backup_sql", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5636232, "supported_languages": null}, "macro.dbt.get_create_intermediate_sql": {"name": "get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_intermediate.sql", "original_file_path": "macros/relations/create_intermediate.sql", "unique_id": "macro.dbt.get_create_intermediate_sql", "macro_sql": "{%- macro get_create_intermediate_sql(relation, sql) -%}\n {{- log('Applying CREATE INTERMEDIATE to: ' ~ relation) -}}\n {{- adapter.dispatch('get_create_intermediate_sql', 'dbt')(relation, sql) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_create_intermediate_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5643528, "supported_languages": null}, "macro.dbt.default__get_create_intermediate_sql": {"name": "default__get_create_intermediate_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/create_intermediate.sql", "original_file_path": "macros/relations/create_intermediate.sql", "unique_id": "macro.dbt.default__get_create_intermediate_sql", "macro_sql": "{%- macro default__get_create_intermediate_sql(relation, sql) -%}\n\n -- get the standard intermediate name\n {% set intermediate_relation = make_intermediate_relation(relation) %}\n\n -- drop any pre-existing intermediate\n {{ get_drop_sql(intermediate_relation) }};\n\n {{ get_create_sql(intermediate_relation, sql) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.make_intermediate_relation", "macro.dbt.get_drop_sql", "macro.dbt.get_create_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.564898, "supported_languages": null}, "macro.dbt.get_drop_sql": {"name": "get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.get_drop_sql", "macro_sql": "{%- macro get_drop_sql(relation) -%}\n {{- log('Applying DROP to: ' ~ relation) -}}\n {{- adapter.dispatch('get_drop_sql', 'dbt')(relation) -}}\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.default__get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5661302, "supported_languages": null}, "macro.dbt.default__get_drop_sql": {"name": "default__get_drop_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.default__get_drop_sql", "macro_sql": "{%- macro default__get_drop_sql(relation) -%}\n\n {%- if relation.is_view -%}\n {{ drop_view(relation) }}\n\n {%- elif relation.is_table -%}\n {{ drop_table(relation) }}\n\n {%- elif relation.is_materialized_view -%}\n {{ drop_materialized_view(relation) }}\n\n {%- else -%}\n drop {{ relation.type }} if exists {{ relation }} cascade\n\n {%- endif -%}\n\n{%- endmacro -%}\n\n\n", "depends_on": {"macros": ["macro.dbt.drop_view", "macro.dbt.drop_table", "macro.dbt.drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.566914, "supported_languages": null}, "macro.dbt.drop_relation": {"name": "drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__drop_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5672956, "supported_languages": null}, "macro.dbt.default__drop_relation": {"name": "default__drop_relation", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.default__drop_relation", "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n {{ get_drop_sql(relation) }}\n {%- endcall %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.get_drop_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5677214, "supported_languages": null}, "macro.dbt.drop_relation_if_exists": {"name": "drop_relation_if_exists", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/drop.sql", "original_file_path": "macros/relations/drop.sql", "unique_id": "macro.dbt.drop_relation_if_exists", "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5681443, "supported_languages": null}, "macro.dbt.get_table_columns_and_constraints": {"name": "get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.get_table_columns_and_constraints", "macro_sql": "{%- macro get_table_columns_and_constraints() -%}\n {{ adapter.dispatch('get_table_columns_and_constraints', 'dbt')() }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt.default__get_table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5698695, "supported_languages": null}, "macro.dbt.default__get_table_columns_and_constraints": {"name": "default__get_table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_table_columns_and_constraints", "macro_sql": "{% macro default__get_table_columns_and_constraints() -%}\n {{ return(table_columns_and_constraints()) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.table_columns_and_constraints"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5701423, "supported_languages": null}, "macro.dbt.table_columns_and_constraints": {"name": "table_columns_and_constraints", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.table_columns_and_constraints", "macro_sql": "{% macro table_columns_and_constraints() %}\n {# loop through user_provided_columns to create DDL with data types and constraints #}\n {%- set raw_column_constraints = adapter.render_raw_columns_constraints(raw_columns=model['columns']) -%}\n {%- set raw_model_constraints = adapter.render_raw_model_constraints(raw_constraints=model['constraints']) -%}\n (\n {% for c in raw_column_constraints -%}\n {{ c }}{{ \",\" if not loop.last or raw_model_constraints }}\n {% endfor %}\n {% for c in raw_model_constraints -%}\n {{ c }}{{ \",\" if not loop.last }}\n {% endfor -%}\n )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5712783, "supported_languages": null}, "macro.dbt.get_assert_columns_equivalent": {"name": "get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.get_assert_columns_equivalent", "macro_sql": "\n\n{%- macro get_assert_columns_equivalent(sql) -%}\n {{ adapter.dispatch('get_assert_columns_equivalent', 'dbt')(sql) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5716355, "supported_languages": null}, "macro.dbt.default__get_assert_columns_equivalent": {"name": "default__get_assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__get_assert_columns_equivalent", "macro_sql": "{% macro default__get_assert_columns_equivalent(sql) -%}\n {{ return(assert_columns_equivalent(sql)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5719285, "supported_languages": null}, "macro.dbt.assert_columns_equivalent": {"name": "assert_columns_equivalent", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.assert_columns_equivalent", "macro_sql": "{% macro assert_columns_equivalent(sql) %}\n\n {#-- First ensure the user has defined 'columns' in yaml specification --#}\n {%- set user_defined_columns = model['columns'] -%}\n {%- if not user_defined_columns -%}\n {{ exceptions.raise_contract_error([], []) }}\n {%- endif -%}\n\n {#-- Obtain the column schema provided by sql file. #}\n {%- set sql_file_provided_columns = get_column_schema_from_query(sql, config.get('sql_header', none)) -%}\n {#--Obtain the column schema provided by the schema file by generating an 'empty schema' query from the model's columns. #}\n {%- set schema_file_provided_columns = get_column_schema_from_query(get_empty_schema_sql(user_defined_columns)) -%}\n\n {#-- create dictionaries with name and formatted data type and strings for exception #}\n {%- set sql_columns = format_columns(sql_file_provided_columns) -%}\n {%- set yaml_columns = format_columns(schema_file_provided_columns) -%}\n\n {%- if sql_columns|length != yaml_columns|length -%}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n\n {%- for sql_col in sql_columns -%}\n {%- set yaml_col = [] -%}\n {%- for this_col in yaml_columns -%}\n {%- if this_col['name'] == sql_col['name'] -%}\n {%- do yaml_col.append(this_col) -%}\n {%- break -%}\n {%- endif -%}\n {%- endfor -%}\n {%- if not yaml_col -%}\n {#-- Column with name not found in yaml #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- if sql_col['formatted'] != yaml_col[0]['formatted'] -%}\n {#-- Column data types don't match #}\n {%- do exceptions.raise_contract_error(yaml_columns, sql_columns) -%}\n {%- endif -%}\n {%- endfor -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.get_column_schema_from_query", "macro.dbt.get_empty_schema_sql", "macro.dbt.format_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.574739, "supported_languages": null}, "macro.dbt.format_columns": {"name": "format_columns", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.format_columns", "macro_sql": "{% macro format_columns(columns) %}\n {% set formatted_columns = [] %}\n {% for column in columns %}\n {%- set formatted_column = adapter.dispatch('format_column', 'dbt')(column) -%}\n {%- do formatted_columns.append(formatted_column) -%}\n {% endfor %}\n {{ return(formatted_columns) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.format_column", "macro.dbt.default__format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5755544, "supported_languages": null}, "macro.dbt.default__format_column": {"name": "default__format_column", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/column/columns_spec_ddl.sql", "original_file_path": "macros/relations/column/columns_spec_ddl.sql", "unique_id": "macro.dbt.default__format_column", "macro_sql": "{% macro default__format_column(column) -%}\n {% set data_type = column.dtype %}\n {% set formatted = column.column.lower() ~ \" \" ~ data_type %}\n {{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.576267, "supported_languages": null}, "macro.dbt.get_create_view_as_sql": {"name": "get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.get_create_view_as_sql", "macro_sql": "{% macro get_create_view_as_sql(relation, sql) -%}\n {{ adapter.dispatch('get_create_view_as_sql', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5771024, "supported_languages": null}, "macro.dbt.default__get_create_view_as_sql": {"name": "default__get_create_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.default__get_create_view_as_sql", "macro_sql": "{% macro default__get_create_view_as_sql(relation, sql) -%}\n {{ return(create_view_as(relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.577462, "supported_languages": null}, "macro.dbt.create_view_as": {"name": "create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.create_view_as", "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as', 'dbt')(relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__create_view_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.577851, "supported_languages": null}, "macro.dbt.default__create_view_as": {"name": "default__create_view_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/create.sql", "original_file_path": "macros/relations/view/create.sql", "unique_id": "macro.dbt.default__create_view_as", "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced %}\n {{ get_assert_columns_equivalent(sql) }}\n {%- endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.578738, "supported_languages": null}, "macro.dbt.get_rename_view_sql": {"name": "get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt.get_rename_view_sql", "macro_sql": "{% macro get_rename_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.579277, "supported_languages": null}, "macro.dbt.default__get_rename_view_sql": {"name": "default__get_rename_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/rename.sql", "original_file_path": "macros/relations/view/rename.sql", "unique_id": "macro.dbt.default__get_rename_view_sql", "macro_sql": "{% macro default__get_rename_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5795968, "supported_languages": null}, "macro.dbt.get_replace_view_sql": {"name": "get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.get_replace_view_sql", "macro_sql": "{% macro get_replace_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5809712, "supported_languages": null}, "macro.dbt.default__get_replace_view_sql": {"name": "default__get_replace_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.default__get_replace_view_sql", "macro_sql": "{% macro default__get_replace_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.581331, "supported_languages": null}, "macro.dbt.create_or_replace_view": {"name": "create_or_replace_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.create_or_replace_view", "macro_sql": "{% macro create_or_replace_view() %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {% set grant_config = config.get('grants') %}\n\n {{ run_hooks(pre_hooks) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ get_create_view_as_sql(target_relation, sql) }}\n {%- endcall %}\n\n {% set should_revoke = should_revoke(exists_as_view, full_refresh_mode=True) %}\n {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %}\n\n {{ run_hooks(post_hooks) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_hooks", "macro.dbt.handle_existing_table", "macro.dbt.should_full_refresh", "macro.dbt.statement", "macro.dbt.get_create_view_as_sql", "macro.dbt.should_revoke", "macro.dbt.apply_grants"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5836282, "supported_languages": null}, "macro.dbt.handle_existing_table": {"name": "handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.handle_existing_table", "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch('handle_existing_table', 'dbt')(full_refresh, old_relation) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__handle_existing_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5840387, "supported_languages": null}, "macro.dbt.default__handle_existing_table": {"name": "default__handle_existing_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/replace.sql", "original_file_path": "macros/relations/view/replace.sql", "unique_id": "macro.dbt.default__handle_existing_table", "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5844953, "supported_languages": null}, "macro.dbt.drop_view": {"name": "drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt.drop_view", "macro_sql": "{% macro drop_view(relation) -%}\n {{ return(adapter.dispatch('drop_view', 'dbt')(relation)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5850437, "supported_languages": null}, "macro.dbt.default__drop_view": {"name": "default__drop_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/view/drop.sql", "original_file_path": "macros/relations/view/drop.sql", "unique_id": "macro.dbt.default__drop_view", "macro_sql": "{% macro default__drop_view(relation) -%}\n drop view if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5852838, "supported_languages": null}, "macro.dbt.refresh_materialized_view": {"name": "refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/refresh.sql", "original_file_path": "macros/relations/materialized_view/refresh.sql", "unique_id": "macro.dbt.refresh_materialized_view", "macro_sql": "{% macro refresh_materialized_view(relation) %}\n {{- log('Applying REFRESH to: ' ~ relation) -}}\n {{- adapter.dispatch('refresh_materialized_view', 'dbt')(relation) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__refresh_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.585887, "supported_languages": null}, "macro.dbt.default__refresh_materialized_view": {"name": "default__refresh_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/refresh.sql", "original_file_path": "macros/relations/materialized_view/refresh.sql", "unique_id": "macro.dbt.default__refresh_materialized_view", "macro_sql": "{% macro default__refresh_materialized_view(relation) %}\n {{ exceptions.raise_compiler_error(\"`refresh_materialized_view` has not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5861776, "supported_languages": null}, "macro.dbt.get_create_materialized_view_as_sql": {"name": "get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/create.sql", "original_file_path": "macros/relations/materialized_view/create.sql", "unique_id": "macro.dbt.get_create_materialized_view_as_sql", "macro_sql": "{% macro get_create_materialized_view_as_sql(relation, sql) -%}\n {{- adapter.dispatch('get_create_materialized_view_as_sql', 'dbt')(relation, sql) -}}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__get_create_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5867167, "supported_languages": null}, "macro.dbt.default__get_create_materialized_view_as_sql": {"name": "default__get_create_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/create.sql", "original_file_path": "macros/relations/materialized_view/create.sql", "unique_id": "macro.dbt.default__get_create_materialized_view_as_sql", "macro_sql": "{% macro default__get_create_materialized_view_as_sql(relation, sql) -%}\n {{ exceptions.raise_compiler_error(\n \"`get_create_materialized_view_as_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5870214, "supported_languages": null}, "macro.dbt.get_rename_materialized_view_sql": {"name": "get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/rename.sql", "original_file_path": "macros/relations/materialized_view/rename.sql", "unique_id": "macro.dbt.get_rename_materialized_view_sql", "macro_sql": "{% macro get_rename_materialized_view_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_materialized_view_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5875504, "supported_languages": null}, "macro.dbt.default__get_rename_materialized_view_sql": {"name": "default__get_rename_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/rename.sql", "original_file_path": "macros/relations/materialized_view/rename.sql", "unique_id": "macro.dbt.default__get_rename_materialized_view_sql", "macro_sql": "{% macro default__get_rename_materialized_view_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5878687, "supported_languages": null}, "macro.dbt.get_replace_materialized_view_sql": {"name": "get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/replace.sql", "original_file_path": "macros/relations/materialized_view/replace.sql", "unique_id": "macro.dbt.get_replace_materialized_view_sql", "macro_sql": "{% macro get_replace_materialized_view_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_materialized_view_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_materialized_view_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5884073, "supported_languages": null}, "macro.dbt.default__get_replace_materialized_view_sql": {"name": "default__get_replace_materialized_view_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/replace.sql", "original_file_path": "macros/relations/materialized_view/replace.sql", "unique_id": "macro.dbt.default__get_replace_materialized_view_sql", "macro_sql": "{% macro default__get_replace_materialized_view_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_materialized_view_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5887208, "supported_languages": null}, "macro.dbt.drop_materialized_view": {"name": "drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/drop.sql", "original_file_path": "macros/relations/materialized_view/drop.sql", "unique_id": "macro.dbt.drop_materialized_view", "macro_sql": "{% macro drop_materialized_view(relation) -%}\n {{ return(adapter.dispatch('drop_materialized_view', 'dbt')(relation)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_materialized_view"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.589378, "supported_languages": null}, "macro.dbt.default__drop_materialized_view": {"name": "default__drop_materialized_view", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/drop.sql", "original_file_path": "macros/relations/materialized_view/drop.sql", "unique_id": "macro.dbt.default__drop_materialized_view", "macro_sql": "{% macro default__drop_materialized_view(relation) -%}\n drop materialized view if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5896137, "supported_languages": null}, "macro.dbt.get_alter_materialized_view_as_sql": {"name": "get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.get_alter_materialized_view_as_sql", "macro_sql": "{% macro get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{- log('Applying ALTER to: ' ~ relation) -}}\n {{- adapter.dispatch('get_alter_materialized_view_as_sql', 'dbt')(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n ) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_alter_materialized_view_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5906994, "supported_languages": null}, "macro.dbt.default__get_alter_materialized_view_as_sql": {"name": "default__get_alter_materialized_view_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.default__get_alter_materialized_view_as_sql", "macro_sql": "{% macro default__get_alter_materialized_view_as_sql(\n relation,\n configuration_changes,\n sql,\n existing_relation,\n backup_relation,\n intermediate_relation\n) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5910969, "supported_languages": null}, "macro.dbt.get_materialized_view_configuration_changes": {"name": "get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.get_materialized_view_configuration_changes", "macro_sql": "{% macro get_materialized_view_configuration_changes(existing_relation, new_config) %}\n /* {#\n It's recommended that configuration changes be formatted as follows:\n {\"\": [{\"action\": \"\", \"context\": ...}]}\n\n For example:\n {\n \"indexes\": [\n {\"action\": \"drop\", \"context\": \"index_abc\"},\n {\"action\": \"create\", \"context\": {\"columns\": [\"column_1\", \"column_2\"], \"type\": \"hash\", \"unique\": True}},\n ],\n }\n\n Either way, `get_materialized_view_configuration_changes` needs to align with `get_alter_materialized_view_as_sql`.\n #} */\n {{- log('Determining configuration changes on: ' ~ existing_relation) -}}\n {%- do return(adapter.dispatch('get_materialized_view_configuration_changes', 'dbt')(existing_relation, new_config)) -%}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_materialized_view_configuration_changes"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5916898, "supported_languages": null}, "macro.dbt.default__get_materialized_view_configuration_changes": {"name": "default__get_materialized_view_configuration_changes", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/materialized_view/alter.sql", "original_file_path": "macros/relations/materialized_view/alter.sql", "unique_id": "macro.dbt.default__get_materialized_view_configuration_changes", "macro_sql": "{% macro default__get_materialized_view_configuration_changes(existing_relation, new_config) %}\n {{ exceptions.raise_compiler_error(\"Materialized views have not been implemented for this adapter.\") }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.592011, "supported_languages": null}, "macro.dbt.get_create_table_as_sql": {"name": "get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.get_create_table_as_sql", "macro_sql": "{% macro get_create_table_as_sql(temporary, relation, sql) -%}\n {{ adapter.dispatch('get_create_table_as_sql', 'dbt')(temporary, relation, sql) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_create_table_as_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5935194, "supported_languages": null}, "macro.dbt.default__get_create_table_as_sql": {"name": "default__get_create_table_as_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_create_table_as_sql", "macro_sql": "{% macro default__get_create_table_as_sql(temporary, relation, sql) -%}\n {{ return(create_table_as(temporary, relation, sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5939074, "supported_languages": null}, "macro.dbt.create_table_as": {"name": "create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.create_table_as", "macro_sql": "{% macro create_table_as(temporary, relation, compiled_code, language='sql') -%}\n {# backward compatibility for create_table_as that does not support language #}\n {% if language == \"sql\" %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code)}}\n {% else %}\n {{ adapter.dispatch('create_table_as', 'dbt')(temporary, relation, compiled_code, language) }}\n {% endif %}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__create_table_as"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.59481, "supported_languages": null}, "macro.dbt.default__create_table_as": {"name": "default__create_table_as", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__create_table_as", "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n {% set contract_config = config.get('contract') %}\n {% if contract_config.enforced and (not temporary) %}\n {{ get_assert_columns_equivalent(sql) }}\n {{ get_table_columns_and_constraints() }}\n {%- set sql = get_select_subquery(sql) %}\n {% endif %}\n as (\n {{ sql }}\n );\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.get_assert_columns_equivalent", "macro.dbt.get_table_columns_and_constraints", "macro.dbt.get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.596277, "supported_languages": null}, "macro.dbt.default__get_column_names": {"name": "default__get_column_names", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_column_names", "macro_sql": "{% macro default__get_column_names() %}\n {#- loop through user_provided_columns to get column names -#}\n {%- set user_provided_columns = model['columns'] -%}\n {%- for i in user_provided_columns %}\n {%- set col = user_provided_columns[i] -%}\n {%- set col_name = adapter.quote(col['name']) if col.get('quote') else col['name'] -%}\n {{ col_name }}{{ \", \" if not loop.last }}\n {%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5972784, "supported_languages": null}, "macro.dbt.get_select_subquery": {"name": "get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.get_select_subquery", "macro_sql": "{% macro get_select_subquery(sql) %}\n {{ return(adapter.dispatch('get_select_subquery', 'dbt')(sql)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_select_subquery"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5977046, "supported_languages": null}, "macro.dbt.default__get_select_subquery": {"name": "default__get_select_subquery", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/create.sql", "original_file_path": "macros/relations/table/create.sql", "unique_id": "macro.dbt.default__get_select_subquery", "macro_sql": "{% macro default__get_select_subquery(sql) %}\n select {{ adapter.dispatch('get_column_names', 'dbt')() }}\n from (\n {{ sql }}\n ) as model_subq\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_column_names"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5980885, "supported_languages": null}, "macro.dbt.get_rename_table_sql": {"name": "get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt.get_rename_table_sql", "macro_sql": "{% macro get_rename_table_sql(relation, new_name) %}\n {{- adapter.dispatch('get_rename_table_sql', 'dbt')(relation, new_name) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_rename_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5986295, "supported_languages": null}, "macro.dbt.default__get_rename_table_sql": {"name": "default__get_rename_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/rename.sql", "original_file_path": "macros/relations/table/rename.sql", "unique_id": "macro.dbt.default__get_rename_table_sql", "macro_sql": "{% macro default__get_rename_table_sql(relation, new_name) %}\n {{ exceptions.raise_compiler_error(\n \"`get_rename_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.598946, "supported_languages": null}, "macro.dbt.get_replace_table_sql": {"name": "get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt.get_replace_table_sql", "macro_sql": "{% macro get_replace_table_sql(relation, sql) %}\n {{- adapter.dispatch('get_replace_table_sql', 'dbt')(relation, sql) -}}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.default__get_replace_table_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.599472, "supported_languages": null}, "macro.dbt.default__get_replace_table_sql": {"name": "default__get_replace_table_sql", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/replace.sql", "original_file_path": "macros/relations/table/replace.sql", "unique_id": "macro.dbt.default__get_replace_table_sql", "macro_sql": "{% macro default__get_replace_table_sql(relation, sql) %}\n {{ exceptions.raise_compiler_error(\n \"`get_replace_table_sql` has not been implemented for this adapter.\"\n ) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.5997822, "supported_languages": null}, "macro.dbt.drop_table": {"name": "drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt.drop_table", "macro_sql": "{% macro drop_table(relation) -%}\n {{ return(adapter.dispatch('drop_table', 'dbt')(relation)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.default__drop_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6003, "supported_languages": null}, "macro.dbt.default__drop_table": {"name": "default__drop_table", "resource_type": "macro", "package_name": "dbt", "path": "macros/relations/table/drop.sql", "original_file_path": "macros/relations/table/drop.sql", "unique_id": "macro.dbt.default__drop_table", "macro_sql": "{% macro default__drop_table(relation) -%}\n drop table if exists {{ relation }} cascade\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6005318, "supported_languages": null}, "macro.dbt.test_unique": {"name": "test_unique", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_unique", "macro_sql": "{% test unique(model, column_name) %}\n {% set macro = adapter.dispatch('test_unique', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_unique"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6015007, "supported_languages": null}, "macro.dbt.test_not_null": {"name": "test_not_null", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_not_null", "macro_sql": "{% test not_null(model, column_name) %}\n {% set macro = adapter.dispatch('test_not_null', 'dbt') %}\n {{ macro(model, column_name) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_not_null"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6020098, "supported_languages": null}, "macro.dbt.test_accepted_values": {"name": "test_accepted_values", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_accepted_values", "macro_sql": "{% test accepted_values(model, column_name, values, quote=True) %}\n {% set macro = adapter.dispatch('test_accepted_values', 'dbt') %}\n {{ macro(model, column_name, values, quote) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt.default__test_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.602644, "supported_languages": null}, "macro.dbt.test_relationships": {"name": "test_relationships", "resource_type": "macro", "package_name": "dbt", "path": "tests/generic/builtin.sql", "original_file_path": "tests/generic/builtin.sql", "unique_id": "macro.dbt.test_relationships", "macro_sql": "{% test relationships(model, column_name, to, field) %}\n {% set macro = adapter.dispatch('test_relationships', 'dbt') %}\n {{ macro(model, column_name, to, field) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_clickhouse.clickhouse__test_relationships"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6033509, "supported_languages": null}, "macro.dbt_utils.test_fewer_rows_than": {"name": "test_fewer_rows_than", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/fewer_rows_than.sql", "original_file_path": "macros/generic_tests/fewer_rows_than.sql", "unique_id": "macro.dbt_utils.test_fewer_rows_than", "macro_sql": "{% test fewer_rows_than(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_fewer_rows_than', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_fewer_rows_than"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6051033, "supported_languages": null}, "macro.dbt_utils.default__test_fewer_rows_than": {"name": "default__test_fewer_rows_than", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/fewer_rows_than.sql", "original_file_path": "macros/generic_tests/fewer_rows_than.sql", "unique_id": "macro.dbt_utils.default__test_fewer_rows_than", "macro_sql": "{% macro default__test_fewer_rows_than(model, compare_model, group_by_columns) %}\n\n{{ config(fail_calc = 'sum(coalesce(row_count_delta, 0))') }}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in equal_rowcount. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_fewer_rows_than'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_our_model \n from {{ model }}\n {{ groupby_gb_cols }}\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_fewer_rows_than,\n count(*) as count_comparison_model \n from {{ compare_model }}\n {{ groupby_gb_cols }}\n\n),\ncounts as (\n\n select\n\n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_our_model,\n count_comparison_model\n from a\n full join b on \n a.id_dbtutils_test_fewer_rows_than = b.id_dbtutils_test_fewer_rows_than\n {{ join_gb_cols }}\n\n),\nfinal as (\n\n select *,\n case\n -- fail the test if we have more rows than the reference model and return the row count delta\n when count_our_model > count_comparison_model then (count_our_model - count_comparison_model)\n -- fail the test if they are the same number\n when count_our_model = count_comparison_model then 1\n -- pass the test if the delta is positive (i.e. return the number 0)\n else 0\n end as row_count_delta\n from counts\n\n)\n\nselect * from final\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6072788, "supported_languages": null}, "macro.dbt_utils.test_not_empty_string": {"name": "test_not_empty_string", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_empty_string.sql", "original_file_path": "macros/generic_tests/not_empty_string.sql", "unique_id": "macro.dbt_utils.test_not_empty_string", "macro_sql": "{% test not_empty_string(model, column_name, trim_whitespace=true) %}\n\n {{ return(adapter.dispatch('test_not_empty_string', 'dbt_utils')(model, column_name, trim_whitespace)) }}\n\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_empty_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6081822, "supported_languages": null}, "macro.dbt_utils.default__test_not_empty_string": {"name": "default__test_not_empty_string", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_empty_string.sql", "original_file_path": "macros/generic_tests/not_empty_string.sql", "unique_id": "macro.dbt_utils.default__test_not_empty_string", "macro_sql": "{% macro default__test_not_empty_string(model, column_name, trim_whitespace=true) %}\n\n with\n \n all_values as (\n\n select \n\n\n {% if trim_whitespace == true -%}\n\n trim({{ column_name }}) as {{ column_name }}\n\n {%- else -%}\n\n {{ column_name }}\n\n {%- endif %}\n \n from {{ model }}\n\n ),\n\n errors as (\n\n select * from all_values\n where {{ column_name }} = ''\n\n )\n\n select * from errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.608823, "supported_languages": null}, "macro.dbt_utils.test_not_accepted_values": {"name": "test_not_accepted_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_accepted_values.sql", "original_file_path": "macros/generic_tests/not_accepted_values.sql", "unique_id": "macro.dbt_utils.test_not_accepted_values", "macro_sql": "{% test not_accepted_values(model, column_name, values, quote=True) %}\n {{ return(adapter.dispatch('test_not_accepted_values', 'dbt_utils')(model, column_name, values, quote)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_accepted_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6098397, "supported_languages": null}, "macro.dbt_utils.default__test_not_accepted_values": {"name": "default__test_not_accepted_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_accepted_values.sql", "original_file_path": "macros/generic_tests/not_accepted_values.sql", "unique_id": "macro.dbt_utils.default__test_not_accepted_values", "macro_sql": "{% macro default__test_not_accepted_values(model, column_name, values, quote=True) %}\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field in (\n {% for value in values -%}\n {% if quote -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.610658, "supported_languages": null}, "macro.dbt_utils.test_equality": {"name": "test_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equality.sql", "original_file_path": "macros/generic_tests/equality.sql", "unique_id": "macro.dbt_utils.test_equality", "macro_sql": "{% test equality(model, compare_model, compare_columns=None) %}\n {{ return(adapter.dispatch('test_equality', 'dbt_utils')(model, compare_model, compare_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6119301, "supported_languages": null}, "macro.dbt_utils.default__test_equality": {"name": "default__test_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equality.sql", "original_file_path": "macros/generic_tests/equality.sql", "unique_id": "macro.dbt_utils.default__test_equality", "macro_sql": "{% macro default__test_equality(model, compare_model, compare_columns=None) %}\n\n{% set set_diff %}\n count(*) + coalesce(abs(\n sum(case when which_diff = 'a_minus_b' then 1 else 0 end) -\n sum(case when which_diff = 'b_minus_a' then 1 else 0 end)\n ), 0)\n{% endset %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = set_diff) }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n-- setup\n{%- do dbt_utils._is_relation(model, 'test_equality') -%}\n\n{#-\nIf the compare_cols arg is provided, we can run this test without querying the\ninformation schema\u00a0\u2014 this allows the model to be an ephemeral model\n-#}\n\n{%- if not compare_columns -%}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%}\n{%- endif -%}\n\n{% set compare_cols_csv = compare_columns | join(', ') %}\n\nwith a as (\n\n select * from {{ model }}\n\n),\n\nb as (\n\n select * from {{ compare_model }}\n\n),\n\na_minus_b as (\n\n select {{compare_cols_csv}} from a\n {{ dbt.except() }}\n select {{compare_cols_csv}} from b\n\n),\n\nb_minus_a as (\n\n select {{compare_cols_csv}} from b\n {{ dbt.except() }}\n select {{compare_cols_csv}} from a\n\n),\n\nunioned as (\n\n select 'a_minus_b' as which_diff, a_minus_b.* from a_minus_b\n union all\n select 'b_minus_a' as which_diff, b_minus_a.* from b_minus_a\n\n)\n\nselect * from unioned\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6138766, "supported_languages": null}, "macro.dbt_utils.test_not_constant": {"name": "test_not_constant", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_constant.sql", "original_file_path": "macros/generic_tests/not_constant.sql", "unique_id": "macro.dbt_utils.test_not_constant", "macro_sql": "{% test not_constant(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_constant', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_constant"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6147242, "supported_languages": null}, "macro.dbt_utils.default__test_not_constant": {"name": "default__test_not_constant", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_constant.sql", "original_file_path": "macros/generic_tests/not_constant.sql", "unique_id": "macro.dbt_utils.default__test_not_constant", "macro_sql": "{% macro default__test_not_constant(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nselect\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count(distinct {{ column_name }}) as filler_column\n\nfrom {{ model }}\n\n {{groupby_gb_cols}}\n\nhaving count(distinct {{ column_name }}) = 1\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6156993, "supported_languages": null}, "macro.dbt_utils.test_unique_combination_of_columns": {"name": "test_unique_combination_of_columns", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/unique_combination_of_columns.sql", "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", "unique_id": "macro.dbt_utils.test_unique_combination_of_columns", "macro_sql": "{% test unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n {{ return(adapter.dispatch('test_unique_combination_of_columns', 'dbt_utils')(model, combination_of_columns, quote_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_unique_combination_of_columns"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6167638, "supported_languages": null}, "macro.dbt_utils.default__test_unique_combination_of_columns": {"name": "default__test_unique_combination_of_columns", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/unique_combination_of_columns.sql", "original_file_path": "macros/generic_tests/unique_combination_of_columns.sql", "unique_id": "macro.dbt_utils.default__test_unique_combination_of_columns", "macro_sql": "{% macro default__test_unique_combination_of_columns(model, combination_of_columns, quote_columns=false) %}\n\n{% if not quote_columns %}\n {%- set column_list=combination_of_columns %}\n{% elif quote_columns %}\n {%- set column_list=[] %}\n {% for column in combination_of_columns -%}\n {% set column_list = column_list.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set columns_csv=column_list | join(', ') %}\n\n\nwith validation_errors as (\n\n select\n {{ columns_csv }}\n from {{ model }}\n group by {{ columns_csv }}\n having count(*) > 1\n\n)\n\nselect *\nfrom validation_errors\n\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.61818, "supported_languages": null}, "macro.dbt_utils.test_recency": {"name": "test_recency", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/recency.sql", "original_file_path": "macros/generic_tests/recency.sql", "unique_id": "macro.dbt_utils.test_recency", "macro_sql": "{% test recency(model, field, datepart, interval, ignore_time_component=False, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_recency', 'dbt_utils')(model, field, datepart, interval, ignore_time_component, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_recency"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6194503, "supported_languages": null}, "macro.dbt_utils.default__test_recency": {"name": "default__test_recency", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/recency.sql", "original_file_path": "macros/generic_tests/recency.sql", "unique_id": "macro.dbt_utils.default__test_recency", "macro_sql": "{% macro default__test_recency(model, field, datepart, interval, ignore_time_component, group_by_columns) %}\n\n{% set threshold = 'cast(' ~ dbt.dateadd(datepart, interval * -1, dbt.current_timestamp()) ~ ' as ' ~ ('date' if ignore_time_component else dbt.type_timestamp()) ~ ')' %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n\nwith recency as (\n\n select \n\n {{ select_gb_cols }}\n {% if ignore_time_component %}\n cast(max({{ field }}) as date) as most_recent\n {%- else %}\n max({{ field }}) as most_recent\n {%- endif %}\n\n from {{ model }}\n\n {{ groupby_gb_cols }}\n\n)\n\nselect\n\n {{ select_gb_cols }}\n most_recent,\n {{ threshold }} as threshold\n\nfrom recency\nwhere most_recent < {{ threshold }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.dateadd", "macro.dbt.current_timestamp", "macro.dbt.type_timestamp"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.621239, "supported_languages": null}, "macro.dbt_utils.test_relationships_where": {"name": "test_relationships_where", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/relationships_where.sql", "original_file_path": "macros/generic_tests/relationships_where.sql", "unique_id": "macro.dbt_utils.test_relationships_where", "macro_sql": "{% test relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n {{ return(adapter.dispatch('test_relationships_where', 'dbt_utils')(model, column_name, to, field, from_condition, to_condition)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_relationships_where"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6223729, "supported_languages": null}, "macro.dbt_utils.default__test_relationships_where": {"name": "default__test_relationships_where", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/relationships_where.sql", "original_file_path": "macros/generic_tests/relationships_where.sql", "unique_id": "macro.dbt_utils.default__test_relationships_where", "macro_sql": "{% macro default__test_relationships_where(model, column_name, to, field, from_condition=\"1=1\", to_condition=\"1=1\") %}\n\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n\nwith left_table as (\n\n select\n {{column_name}} as id\n\n from {{model}}\n\n where {{column_name}} is not null\n and {{from_condition}}\n\n),\n\nright_table as (\n\n select\n {{field}} as id\n\n from {{to}}\n\n where {{field}} is not null\n and {{to_condition}}\n\n),\n\nexceptions as (\n\n select\n left_table.id,\n right_table.id as right_id\n\n from left_table\n\n left join right_table\n on left_table.id = right_table.id\n\n where right_table.id is null\n\n)\n\nselect * from exceptions\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6230772, "supported_languages": null}, "macro.dbt_utils.test_accepted_range": {"name": "test_accepted_range", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/accepted_range.sql", "original_file_path": "macros/generic_tests/accepted_range.sql", "unique_id": "macro.dbt_utils.test_accepted_range", "macro_sql": "{% test accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n {{ return(adapter.dispatch('test_accepted_range', 'dbt_utils')(model, column_name, min_value, max_value, inclusive)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_accepted_range"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6241724, "supported_languages": null}, "macro.dbt_utils.default__test_accepted_range": {"name": "default__test_accepted_range", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/accepted_range.sql", "original_file_path": "macros/generic_tests/accepted_range.sql", "unique_id": "macro.dbt_utils.default__test_accepted_range", "macro_sql": "{% macro default__test_accepted_range(model, column_name, min_value=none, max_value=none, inclusive=true) %}\n\nwith meet_condition as(\n select *\n from {{ model }}\n),\n\nvalidation_errors as (\n select *\n from meet_condition\n where\n -- never true, defaults to an empty result set. Exists to ensure any combo of the `or` clauses below succeeds\n 1 = 2\n\n {%- if min_value is not none %}\n -- records with a value >= min_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} > {{- \"=\" if inclusive }} {{ min_value }}\n {%- endif %}\n\n {%- if max_value is not none %}\n -- records with a value <= max_value are permitted. The `not` flips this to find records that don't meet the rule.\n or not {{ column_name }} < {{- \"=\" if inclusive }} {{ max_value }}\n {%- endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6252449, "supported_languages": null}, "macro.dbt_utils.test_cardinality_equality": {"name": "test_cardinality_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/cardinality_equality.sql", "original_file_path": "macros/generic_tests/cardinality_equality.sql", "unique_id": "macro.dbt_utils.test_cardinality_equality", "macro_sql": "{% test cardinality_equality(model, column_name, to, field) %}\n {{ return(adapter.dispatch('test_cardinality_equality', 'dbt_utils')(model, column_name, to, field)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_cardinality_equality"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6261876, "supported_languages": null}, "macro.dbt_utils.default__test_cardinality_equality": {"name": "default__test_cardinality_equality", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/cardinality_equality.sql", "original_file_path": "macros/generic_tests/cardinality_equality.sql", "unique_id": "macro.dbt_utils.default__test_cardinality_equality", "macro_sql": "{% macro default__test_cardinality_equality(model, column_name, to, field) %}\n\n{# T-SQL does not let you use numbers as aliases for columns #}\n{# Thus, no \"GROUP BY 1\" #}\n\nwith table_a as (\nselect\n {{ column_name }},\n count(*) as num_rows\nfrom {{ model }}\ngroup by {{ column_name }}\n),\n\ntable_b as (\nselect\n {{ field }},\n count(*) as num_rows\nfrom {{ to }}\ngroup by {{ field }}\n),\n\nexcept_a as (\n select *\n from table_a\n {{ dbt.except() }}\n select *\n from table_b\n),\n\nexcept_b as (\n select *\n from table_b\n {{ dbt.except() }}\n select *\n from table_a\n),\n\nunioned as (\n select *\n from except_a\n union all\n select *\n from except_b\n)\n\nselect *\nfrom unioned\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.except"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6269126, "supported_languages": null}, "macro.dbt_utils.test_equal_rowcount": {"name": "test_equal_rowcount", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equal_rowcount.sql", "original_file_path": "macros/generic_tests/equal_rowcount.sql", "unique_id": "macro.dbt_utils.test_equal_rowcount", "macro_sql": "{% test equal_rowcount(model, compare_model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_equal_rowcount', 'dbt_utils')(model, compare_model, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_equal_rowcount"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.628329, "supported_languages": null}, "macro.dbt_utils.default__test_equal_rowcount": {"name": "default__test_equal_rowcount", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/equal_rowcount.sql", "original_file_path": "macros/generic_tests/equal_rowcount.sql", "unique_id": "macro.dbt_utils.default__test_equal_rowcount", "macro_sql": "{% macro default__test_equal_rowcount(model, compare_model, group_by_columns) %}\n\n{#-- Needs to be set at parse time, before we return '' below --#}\n{{ config(fail_calc = 'sum(coalesce(diff_count, 0))') }}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(', ') + ', ' %}\n {% set join_gb_cols %}\n {% for c in group_by_columns %}\n and a.{{c}} = b.{{c}}\n {% endfor %}\n {% endset %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\n{#-- We must add a fake join key in case additional grouping variables are not provided --#}\n{#-- Redshift does not allow for dynamically created join conditions (e.g. full join on 1 = 1 --#}\n{#-- The same logic is used in fewer_rows_than. In case of changes, maintain consistent logic --#}\n{% set group_by_columns = ['id_dbtutils_test_equal_rowcount'] + group_by_columns %}\n{% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n\nwith a as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_a \n from {{ model }}\n {{groupby_gb_cols}}\n\n\n),\nb as (\n\n select \n {{select_gb_cols}}\n 1 as id_dbtutils_test_equal_rowcount,\n count(*) as count_b \n from {{ compare_model }}\n {{groupby_gb_cols}}\n\n),\nfinal as (\n\n select\n \n {% for c in group_by_columns -%}\n a.{{c}} as {{c}}_a,\n b.{{c}} as {{c}}_b,\n {% endfor %}\n\n count_a,\n count_b,\n abs(count_a - count_b) as diff_count\n\n from a\n full join b\n on\n a.id_dbtutils_test_equal_rowcount = b.id_dbtutils_test_equal_rowcount\n {{join_gb_cols}}\n\n\n)\n\nselect * from final\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6308184, "supported_languages": null}, "macro.dbt_utils.test_at_least_one": {"name": "test_at_least_one", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/at_least_one.sql", "original_file_path": "macros/generic_tests/at_least_one.sql", "unique_id": "macro.dbt_utils.test_at_least_one", "macro_sql": "{% test at_least_one(model, column_name, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_at_least_one', 'dbt_utils')(model, column_name, group_by_columns)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_at_least_one"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6316812, "supported_languages": null}, "macro.dbt_utils.default__test_at_least_one": {"name": "default__test_at_least_one", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/at_least_one.sql", "original_file_path": "macros/generic_tests/at_least_one.sql", "unique_id": "macro.dbt_utils.default__test_at_least_one", "macro_sql": "{% macro default__test_at_least_one(model, column_name, group_by_columns) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nselect *\nfrom (\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n {{select_gb_cols}}\n count({{ column_name }}) as filler_column\n\n from {{ model }}\n\n {{groupby_gb_cols}}\n\n having count({{ column_name }}) = 0\n\n) validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6326814, "supported_languages": null}, "macro.dbt_utils.test_sequential_values": {"name": "test_sequential_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/sequential_values.sql", "original_file_path": "macros/generic_tests/sequential_values.sql", "unique_id": "macro.dbt_utils.test_sequential_values", "macro_sql": "{% test sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n {{ return(adapter.dispatch('test_sequential_values', 'dbt_utils')(model, column_name, interval, datepart, group_by_columns)) }}\n\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_sequential_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6343513, "supported_languages": null}, "macro.dbt_utils.default__test_sequential_values": {"name": "default__test_sequential_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/sequential_values.sql", "original_file_path": "macros/generic_tests/sequential_values.sql", "unique_id": "macro.dbt_utils.default__test_sequential_values", "macro_sql": "{% macro default__test_sequential_values(model, column_name, interval=1, datepart=None, group_by_columns = []) %}\n\n{% set previous_column_name = \"previous_\" ~ dbt_utils.slugify(column_name) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(',') + ', ' %}\n {% set partition_gb_cols = 'partition by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith windowed as (\n\n select\n {{ select_gb_cols }}\n {{ column_name }},\n lag({{ column_name }}) over (\n {{partition_gb_cols}}\n order by {{ column_name }}\n ) as {{ previous_column_name }}\n from {{ model }}\n),\n\nvalidation_errors as (\n select\n *\n from windowed\n {% if datepart %}\n where not(cast({{ column_name }} as {{ dbt.type_timestamp() }})= cast({{ dbt.dateadd(datepart, interval, previous_column_name) }} as {{ dbt.type_timestamp() }}))\n {% else %}\n where not({{ column_name }} = {{ previous_column_name }} + {{ interval }})\n {% endif %}\n)\n\nselect *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.slugify", "macro.dbt.type_timestamp", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6362865, "supported_languages": null}, "macro.dbt_utils.test_mutually_exclusive_ranges": {"name": "test_mutually_exclusive_ranges", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", "unique_id": "macro.dbt_utils.test_mutually_exclusive_ranges", "macro_sql": "{% test mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n {{ return(adapter.dispatch('test_mutually_exclusive_ranges', 'dbt_utils')(model, lower_bound_column, upper_bound_column, partition_by, gaps, zero_length_range_allowed)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_mutually_exclusive_ranges"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6411502, "supported_languages": null}, "macro.dbt_utils.default__test_mutually_exclusive_ranges": {"name": "default__test_mutually_exclusive_ranges", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/generic_tests/mutually_exclusive_ranges.sql", "unique_id": "macro.dbt_utils.default__test_mutually_exclusive_ranges", "macro_sql": "{% macro default__test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed', zero_length_range_allowed=False) %}\n{% if gaps == 'not_allowed' %}\n {% set allow_gaps_operator='=' %}\n {% set allow_gaps_operator_in_words='equal_to' %}\n{% elif gaps == 'allowed' %}\n {% set allow_gaps_operator='<=' %}\n {% set allow_gaps_operator_in_words='less_than_or_equal_to' %}\n{% elif gaps == 'required' %}\n {% set allow_gaps_operator='<' %}\n {% set allow_gaps_operator_in_words='less_than' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '\" ~ gaps ~\"'.'\"\n ) }}\n{% endif %}\n{% if not zero_length_range_allowed %}\n {% set allow_zero_length_operator='<' %}\n {% set allow_zero_length_operator_in_words='less_than' %}\n{% elif zero_length_range_allowed %}\n {% set allow_zero_length_operator='<=' %}\n {% set allow_zero_length_operator_in_words='less_than_or_equal_to' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`zero_length_range_allowed` argument for mutually_exclusive_ranges test must be one of [true, false] Got: '\" ~ zero_length_range_allowed ~\"'.'\"\n ) }}\n{% endif %}\n\n{% set partition_clause=\"partition by \" ~ partition_by if partition_by else '' %}\n\nwith window_functions as (\n\n select\n {% if partition_by %}\n {{ partition_by }} as partition_by_col,\n {% endif %}\n {{ lower_bound_column }} as lower_bound,\n {{ upper_bound_column }} as upper_bound,\n\n lead({{ lower_bound_column }}) over (\n {{ partition_clause }}\n order by {{ lower_bound_column }}, {{ upper_bound_column }}\n ) as next_lower_bound,\n\n row_number() over (\n {{ partition_clause }}\n order by {{ lower_bound_column }} desc, {{ upper_bound_column }} desc\n ) = 1 as is_last_record\n\n from {{ model }}\n\n),\n\ncalc as (\n -- We want to return records where one of our assumptions fails, so we'll use\n -- the `not` function with `and` statements so we can write our assumptions more cleanly\n select\n *,\n\n -- For each record: lower_bound should be < upper_bound.\n -- Coalesce it to return an error on the null case (implicit assumption\n -- these columns are not_null)\n coalesce(\n lower_bound {{ allow_zero_length_operator }} upper_bound,\n false\n ) as lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound,\n\n -- For each record: upper_bound {{ allow_gaps_operator }} the next lower_bound.\n -- Coalesce it to handle null cases for the last record.\n coalesce(\n upper_bound {{ allow_gaps_operator }} next_lower_bound,\n is_last_record,\n false\n ) as upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n\n from window_functions\n\n),\n\nvalidation_errors as (\n\n select\n *\n from calc\n\n where not(\n -- THE FOLLOWING SHOULD BE TRUE --\n lower_bound_{{ allow_zero_length_operator_in_words }}_upper_bound\n and upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n )\n)\n\nselect * from validation_errors\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6445327, "supported_languages": null}, "macro.dbt_utils.test_expression_is_true": {"name": "test_expression_is_true", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/expression_is_true.sql", "original_file_path": "macros/generic_tests/expression_is_true.sql", "unique_id": "macro.dbt_utils.test_expression_is_true", "macro_sql": "{% test expression_is_true(model, expression, column_name=None) %}\n {{ return(adapter.dispatch('test_expression_is_true', 'dbt_utils')(model, expression, column_name)) }}\n{% endtest %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_expression_is_true"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6453822, "supported_languages": null}, "macro.dbt_utils.default__test_expression_is_true": {"name": "default__test_expression_is_true", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/expression_is_true.sql", "original_file_path": "macros/generic_tests/expression_is_true.sql", "unique_id": "macro.dbt_utils.default__test_expression_is_true", "macro_sql": "{% macro default__test_expression_is_true(model, expression, column_name) %}\n\n{% set column_list = '*' if should_store_failures() else \"1\" %}\n\nselect\n {{ column_list }}\nfrom {{ model }}\n{% if column_name is none %}\nwhere not({{ expression }})\n{%- else %}\nwhere not({{ column_name }} {{ expression }})\n{%- endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.should_store_failures"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.646166, "supported_languages": null}, "macro.dbt_utils.test_not_null_proportion": {"name": "test_not_null_proportion", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_null_proportion.sql", "original_file_path": "macros/generic_tests/not_null_proportion.sql", "unique_id": "macro.dbt_utils.test_not_null_proportion", "macro_sql": "{% macro test_not_null_proportion(model, group_by_columns = []) %}\n {{ return(adapter.dispatch('test_not_null_proportion', 'dbt_utils')(model, group_by_columns, **kwargs)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__test_not_null_proportion"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6472743, "supported_languages": null}, "macro.dbt_utils.default__test_not_null_proportion": {"name": "default__test_not_null_proportion", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/generic_tests/not_null_proportion.sql", "original_file_path": "macros/generic_tests/not_null_proportion.sql", "unique_id": "macro.dbt_utils.default__test_not_null_proportion", "macro_sql": "{% macro default__test_not_null_proportion(model, group_by_columns) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n{% set at_least = kwargs.get('at_least', kwargs.get('arg')) %}\n{% set at_most = kwargs.get('at_most', kwargs.get('arg', 1)) %}\n\n{% if group_by_columns|length() > 0 %}\n {% set select_gb_cols = group_by_columns|join(' ,') + ', ' %}\n {% set groupby_gb_cols = 'group by ' + group_by_columns|join(',') %}\n{% endif %}\n\nwith validation as (\n select\n {{select_gb_cols}}\n sum(case when {{ column_name }} is null then 0 else 1 end) / cast(count(*) as numeric) as not_null_proportion\n from {{ model }}\n {{groupby_gb_cols}}\n),\nvalidation_errors as (\n select\n {{select_gb_cols}}\n not_null_proportion\n from validation\n where not_null_proportion < {{ at_least }} or not_null_proportion > {{ at_most }}\n)\nselect\n *\nfrom validation_errors\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6490524, "supported_languages": null}, "macro.dbt_utils.nullcheck": {"name": "nullcheck", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "unique_id": "macro.dbt_utils.nullcheck", "macro_sql": "{% macro nullcheck(cols) %}\n {{ return(adapter.dispatch('nullcheck', 'dbt_utils')(cols)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.649723, "supported_languages": null}, "macro.dbt_utils.default__nullcheck": {"name": "default__nullcheck", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "unique_id": "macro.dbt_utils.default__nullcheck", "macro_sql": "{% macro default__nullcheck(cols) %}\n{%- for col in cols %}\n\n {% if col.is_string() -%}\n\n nullif({{col.name}},'') as {{col.name}}\n\n {%- else -%}\n\n {{col.name}}\n\n {%- endif -%}\n\n{%- if not loop.last -%} , {%- endif -%}\n\n{%- endfor -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.650449, "supported_languages": null}, "macro.dbt_utils.union_relations": {"name": "union_relations", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "unique_id": "macro.dbt_utils.union_relations", "macro_sql": "{%- macro union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n {{ return(adapter.dispatch('union_relations', 'dbt_utils')(relations, column_override, include, exclude, source_column_name, where)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__union_relations"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.655165, "supported_languages": null}, "macro.dbt_utils.default__union_relations": {"name": "default__union_relations", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "unique_id": "macro.dbt_utils.default__union_relations", "macro_sql": "\n\n{%- macro default__union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation', where=none) -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n {%- set all_excludes = [] -%}\n {%- set all_includes = [] -%}\n\n {%- if exclude -%}\n {%- for exc in exclude -%}\n {%- do all_excludes.append(exc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- if include -%}\n {%- for inc in include -%}\n {%- do all_includes.append(inc | lower) -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column | lower in all_excludes -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column | lower not in all_includes -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n {%- set dbt_command = flags.WHICH -%}\n\n\n {% if dbt_command in ['run', 'build'] %}\n {% if (include | length > 0 or exclude | length > 0) and not column_superset.keys() %}\n {%- set relations_string -%}\n {%- for relation in relations -%}\n {{ relation.name }}\n {%- if not loop.last %}, {% endif -%}\n {%- endfor -%}\n {%- endset -%}\n\n {%- set error_message -%}\n There were no columns found to union for relations {{ relations_string }}\n {%- endset -%}\n\n {{ exceptions.raise_compiler_error(error_message) }}\n {%- endif -%}\n {%- endif -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n {%- if source_column_name is not none %}\n cast({{ dbt.string_literal(relation) }} as {{ dbt.type_string() }}) as {{ source_column_name }},\n {%- endif %}\n\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ relation }}\n\n {% if where -%}\n where {{ where }}\n {%- endif %}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.string_literal", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6628067, "supported_languages": null}, "macro.dbt_utils.get_powers_of_two": {"name": "get_powers_of_two", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6642215, "supported_languages": null}, "macro.dbt_utils.default__get_powers_of_two": {"name": "default__get_powers_of_two", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6651485, "supported_languages": null}, "macro.dbt_utils.generate_series": {"name": "generate_series", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', 'dbt_utils')(upper_bound)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__generate_series"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.665615, "supported_languages": null}, "macro.dbt_utils.default__generate_series": {"name": "default__generate_series", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "unique_id": "macro.dbt_utils.default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_utils.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * power(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_powers_of_two"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6667473, "supported_languages": null}, "macro.dbt_utils.pivot": {"name": "pivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "unique_id": "macro.dbt_utils.pivot", "macro_sql": "{% macro pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {{ return(adapter.dispatch('pivot', 'dbt_utils')(column, values, alias, agg, cmp, prefix, suffix, then_value, else_value, quote_identifiers, distinct)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6685786, "supported_languages": null}, "macro.dbt_utils.default__pivot": {"name": "default__pivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "unique_id": "macro.dbt_utils.default__pivot", "macro_sql": "{% macro default__pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {% for value in values %}\n {{ agg }}(\n {% if distinct %} distinct {% endif %}\n case\n when {{ column }} {{ cmp }} '{{ dbt.escape_single_quotes(value) }}'\n then {{ then_value }}\n else {{ else_value }}\n end\n )\n {% if alias %}\n {% if quote_identifiers %}\n as {{ adapter.quote(prefix ~ value ~ suffix) }}\n {% else %}\n as {{ dbt_utils.slugify(prefix ~ value ~ suffix) }}\n {% endif %}\n {% endif %}\n {% if not loop.last %},{% endif %}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.escape_single_quotes", "macro.dbt_utils.slugify"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.670413, "supported_languages": null}, "macro.dbt_utils.get_query_results_as_dict": {"name": "get_query_results_as_dict", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "unique_id": "macro.dbt_utils.get_query_results_as_dict", "macro_sql": "{% macro get_query_results_as_dict(query) %}\n {{ return(adapter.dispatch('get_query_results_as_dict', 'dbt_utils')(query)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_query_results_as_dict"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6711504, "supported_languages": null}, "macro.dbt_utils.default__get_query_results_as_dict": {"name": "default__get_query_results_as_dict", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "unique_id": "macro.dbt_utils.default__get_query_results_as_dict", "macro_sql": "{% macro default__get_query_results_as_dict(query) %}\n\n{# This macro returns a dictionary of the form {column_name: (tuple_of_results)} #}\n\n {%- call statement('get_query_results', fetch_result=True,auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {% set sql_results={} %}\n\n {%- if execute -%}\n {% set sql_results_table = load_result('get_query_results').table.columns %}\n {% for column_name, column in sql_results_table.items() %}\n {% do sql_results.update({column_name: column.values()}) %}\n {% endfor %}\n {%- endif -%}\n\n {{ return(sql_results) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6724155, "supported_languages": null}, "macro.dbt_utils.star": {"name": "star", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "unique_id": "macro.dbt_utils.star", "macro_sql": "{% macro star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix, quote_identifiers)) }}\r\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__star"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.674518, "supported_languages": null}, "macro.dbt_utils.default__star": {"name": "default__star", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "unique_id": "macro.dbt_utils.default__star", "macro_sql": "{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%}\r\n {%- do dbt_utils._is_relation(from, 'star') -%}\r\n {%- do dbt_utils._is_ephemeral(from, 'star') -%}\r\n\r\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\r\n {%- if not execute -%}\r\n {% do return('*') %}\r\n {%- endif -%}\r\n\r\n {% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %}\r\n\r\n {%- if cols|length <= 0 -%}\r\n {% if flags.WHICH == 'compile' %}\r\n {% set response %}\r\n*\r\n/* No columns were returned. Maybe the relation doesn't exist yet \r\nor all columns were excluded. This star is only output during \r\ndbt compile, and exists to keep SQLFluff happy. */\r\n {% endset %}\r\n {% do return(response) %}\r\n {% else %}\r\n {% do return(\"/* no columns returned from star() macro */\") %}\r\n {% endif %}\r\n {%- else -%}\r\n {%- for col in cols %}\r\n {%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}\r\n {%- if quote_identifiers -%}\r\n {{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {%- else -%}\r\n {{ col|trim }} {%- if prefix!='' or suffix!='' %} as {{ (prefix ~ col ~ suffix)|trim }} {%- endif -%}\r\n {% endif %}\r\n {%- if not loop.last %},{{ '\\n ' }}{%- endif -%}\r\n {%- endfor -%}\r\n {% endif %}\r\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6775982, "supported_languages": null}, "macro.dbt_utils.get_single_value": {"name": "get_single_value", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_single_value.sql", "original_file_path": "macros/sql/get_single_value.sql", "unique_id": "macro.dbt_utils.get_single_value", "macro_sql": "{% macro get_single_value(query, default=none) %}\n {{ return(adapter.dispatch('get_single_value', 'dbt_utils')(query, default)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_single_value"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6785455, "supported_languages": null}, "macro.dbt_utils.default__get_single_value": {"name": "default__get_single_value", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_single_value.sql", "original_file_path": "macros/sql/get_single_value.sql", "unique_id": "macro.dbt_utils.default__get_single_value", "macro_sql": "{% macro default__get_single_value(query, default) %}\n\n{# This macro returns the (0, 0) record in a query, i.e. the first row of the first column #}\n\n {%- call statement('get_query_result', fetch_result=True, auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {%- if execute -%}\n\n {% set r = load_result('get_query_result').table.columns[0].values() %}\n {% if r | length == 0 %}\n {% do print('Query `' ~ query ~ '` returned no rows. Using the default value: ' ~ default) %}\n {% set sql_result = default %}\n {% else %}\n {% set sql_result = r[0] %}\n {% endif %}\n \n {%- else -%}\n \n {% set sql_result = default %}\n \n {%- endif -%}\n\n {% do return(sql_result) %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6800997, "supported_languages": null}, "macro.dbt_utils.get_tables_by_pattern_sql": {"name": "get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.get_tables_by_pattern_sql", "macro_sql": "{% macro get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_pattern_sql', 'dbt_utils')\n (schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.682706, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_pattern_sql": {"name": "default__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.default__get_tables_by_pattern_sql", "macro_sql": "{% macro default__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n select distinct\n table_schema as {{ adapter.quote('table_schema') }},\n table_name as {{ adapter.quote('table_name') }},\n {{ dbt_utils.get_table_types_sql() }}\n from {{ database }}.information_schema.tables\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.68349, "supported_languages": null}, "macro.dbt_utils.bigquery__get_tables_by_pattern_sql": {"name": "bigquery__get_tables_by_pattern_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils.bigquery__get_tables_by_pattern_sql", "macro_sql": "{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% if '%' in schema_pattern %}\n {% set schemata=dbt_utils._bigquery__get_matching_schemata(schema_pattern, database) %}\n {% else %}\n {% set schemata=[schema_pattern] %}\n {% endif %}\n\n {% set sql %}\n {% for schema in schemata %}\n select distinct\n table_schema,\n table_name,\n {{ dbt_utils.get_table_types_sql() }}\n\n from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES\n where lower(table_name) like lower ('{{ table_pattern }}')\n and lower(table_name) not like lower ('{{ exclude }}')\n\n {% if not loop.last %} union all {% endif %}\n\n {% endfor %}\n {% endset %}\n\n {{ return(sql) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._bigquery__get_matching_schemata", "macro.dbt_utils.get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.685027, "supported_languages": null}, "macro.dbt_utils._bigquery__get_matching_schemata": {"name": "_bigquery__get_matching_schemata", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "unique_id": "macro.dbt_utils._bigquery__get_matching_schemata", "macro_sql": "{% macro _bigquery__get_matching_schemata(schema_pattern, database) %}\n {% if execute %}\n\n {% set sql %}\n select schema_name from {{ adapter.quote(database) }}.INFORMATION_SCHEMA.SCHEMATA\n where lower(schema_name) like lower('{{ schema_pattern }}')\n {% endset %}\n\n {% set results=run_query(sql) %}\n\n {% set schemata=results.columns['schema_name'].values() %}\n\n {{ return(schemata) }}\n\n {% else %}\n\n {{ return([]) }}\n\n {% endif %}\n\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.run_query"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6862068, "supported_languages": null}, "macro.dbt_utils.group_by": {"name": "group_by", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "unique_id": "macro.dbt_utils.group_by", "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', 'dbt_utils')(n)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__group_by"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.686879, "supported_languages": null}, "macro.dbt_utils.default__group_by": {"name": "default__group_by", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "unique_id": "macro.dbt_utils.default__group_by", "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }} \n {%- endfor -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6874475, "supported_languages": null}, "macro.dbt_utils.get_relations_by_pattern": {"name": "get_relations_by_pattern", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "unique_id": "macro.dbt_utils.get_relations_by_pattern", "macro_sql": "{% macro get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_pattern', 'dbt_utils')(schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_pattern"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6886706, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_pattern": {"name": "default__get_relations_by_pattern", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "unique_id": "macro.dbt_utils.default__get_relations_by_pattern", "macro_sql": "{% macro default__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6904774, "supported_languages": null}, "macro.dbt_utils.get_intervals_between": {"name": "get_intervals_between", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', 'dbt_utils')(start_date, end_date, datepart)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_intervals_between"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6916318, "supported_languages": null}, "macro.dbt_utils.default__get_intervals_between": {"name": "default__get_intervals_between", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{ dbt.datediff(start_date, end_date, datepart) }}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt.datediff"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.692917, "supported_languages": null}, "macro.dbt_utils.date_spine": {"name": "date_spine", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', 'dbt_utils')(datepart, start_date, end_date)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__date_spine"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6934297, "supported_languages": null}, "macro.dbt_utils.default__date_spine": {"name": "default__date_spine", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/date_spine.sql", "original_file_path": "macros/sql/date_spine.sql", "unique_id": "macro.dbt_utils.default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n\n{# call as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dbt.dateadd(week, 1, current_date)\"\n) #}\n\n\nwith rawdata as (\n\n {{dbt_utils.generate_series(\n dbt_utils.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.generate_series", "macro.dbt_utils.get_intervals_between", "macro.dbt.dateadd"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6941898, "supported_languages": null}, "macro.dbt_utils.safe_subtract": {"name": "safe_subtract", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_subtract.sql", "original_file_path": "macros/sql/safe_subtract.sql", "unique_id": "macro.dbt_utils.safe_subtract", "macro_sql": "{%- macro safe_subtract(field_list) -%}\n {{ return(adapter.dispatch('safe_subtract', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_subtract"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6949089, "supported_languages": null}, "macro.dbt_utils.default__safe_subtract": {"name": "default__safe_subtract", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_subtract.sql", "original_file_path": "macros/sql/safe_subtract.sql", "unique_id": "macro.dbt_utils.default__safe_subtract", "macro_sql": "\n\n{%- macro default__safe_subtract(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_subtract` macro takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' -\\n ') }}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6960368, "supported_languages": null}, "macro.dbt_utils.width_bucket": {"name": "width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.width_bucket", "macro_sql": "{% macro width_bucket(expr, min_value, max_value, num_buckets) %}\n {{ return(adapter.dispatch('width_bucket', 'dbt_utils') (expr, min_value, max_value, num_buckets)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__width_bucket"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6973348, "supported_languages": null}, "macro.dbt_utils.default__width_bucket": {"name": "default__width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.default__width_bucket", "macro_sql": "{% macro default__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is eaxtly at the bucket egde\n case\n when\n mod(\n {{ dbt.safe_cast(expr, dbt.type_numeric() ) }},\n {{ dbt.safe_cast(bin_size, dbt.type_numeric() ) }}\n ) = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.safe_cast", "macro.dbt.type_numeric"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6983104, "supported_languages": null}, "macro.dbt_utils.snowflake__width_bucket": {"name": "snowflake__width_bucket", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/width_bucket.sql", "original_file_path": "macros/sql/width_bucket.sql", "unique_id": "macro.dbt_utils.snowflake__width_bucket", "macro_sql": "{% macro snowflake__width_bucket(expr, min_value, max_value, num_buckets) %}\n width_bucket({{ expr }}, {{ min_value }}, {{ max_value }}, {{ num_buckets }} )\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.698716, "supported_languages": null}, "macro.dbt_utils.get_table_types_sql": {"name": "get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.get_table_types_sql", "macro_sql": "{%- macro get_table_types_sql() -%}\n {{ return(adapter.dispatch('get_table_types_sql', 'dbt_utils')()) }}\n{%- endmacro -%}\n\n", "depends_on": {"macros": ["macro.dbt_utils.default__get_table_types_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.6995769, "supported_languages": null}, "macro.dbt_utils.default__get_table_types_sql": {"name": "default__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.default__get_table_types_sql", "macro_sql": "{% macro default__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'EXTERNAL TABLE' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.69987, "supported_languages": null}, "macro.dbt_utils.postgres__get_table_types_sql": {"name": "postgres__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.postgres__get_table_types_sql", "macro_sql": "{% macro postgres__get_table_types_sql() %}\n case table_type\n when 'BASE TABLE' then 'table'\n when 'FOREIGN' then 'external'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.700159, "supported_languages": null}, "macro.dbt_utils.databricks__get_table_types_sql": {"name": "databricks__get_table_types_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_table_types_sql.sql", "original_file_path": "macros/sql/get_table_types_sql.sql", "unique_id": "macro.dbt_utils.databricks__get_table_types_sql", "macro_sql": "{% macro databricks__get_table_types_sql() %}\n case table_type\n when 'MANAGED' then 'table'\n when 'BASE TABLE' then 'table'\n when 'MATERIALIZED VIEW' then 'materializedview'\n else lower(table_type)\n end as {{ adapter.quote('table_type') }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7004495, "supported_languages": null}, "macro.dbt_utils.get_filtered_columns_in_relation": {"name": "get_filtered_columns_in_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_filtered_columns_in_relation.sql", "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", "unique_id": "macro.dbt_utils.get_filtered_columns_in_relation", "macro_sql": "{% macro get_filtered_columns_in_relation(from, except=[]) -%}\n {{ return(adapter.dispatch('get_filtered_columns_in_relation', 'dbt_utils')(from, except)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_filtered_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7013235, "supported_languages": null}, "macro.dbt_utils.default__get_filtered_columns_in_relation": {"name": "default__get_filtered_columns_in_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_filtered_columns_in_relation.sql", "original_file_path": "macros/sql/get_filtered_columns_in_relation.sql", "unique_id": "macro.dbt_utils.default__get_filtered_columns_in_relation", "macro_sql": "{% macro default__get_filtered_columns_in_relation(from, except=[]) -%}\n {%- do dbt_utils._is_relation(from, 'get_filtered_columns_in_relation') -%}\n {%- do dbt_utils._is_ephemeral(from, 'get_filtered_columns_in_relation') -%}\n\n {# -- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n\n {%- set include_cols = [] %}\n {%- set cols = adapter.get_columns_in_relation(from) -%}\n {%- set except = except | map(\"lower\") | list %}\n {%- for col in cols -%}\n {%- if col.column|lower not in except -%}\n {% do include_cols.append(col.column) %}\n {%- endif %}\n {%- endfor %}\n\n {{ return(include_cols) }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7029831, "supported_languages": null}, "macro.dbt_utils.safe_divide": {"name": "safe_divide", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_divide.sql", "original_file_path": "macros/sql/safe_divide.sql", "unique_id": "macro.dbt_utils.safe_divide", "macro_sql": "{% macro safe_divide(numerator, denominator) -%}\n {{ return(adapter.dispatch('safe_divide', 'dbt_utils')(numerator, denominator)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_divide"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7035537, "supported_languages": null}, "macro.dbt_utils.default__safe_divide": {"name": "default__safe_divide", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_divide.sql", "original_file_path": "macros/sql/safe_divide.sql", "unique_id": "macro.dbt_utils.default__safe_divide", "macro_sql": "{% macro default__safe_divide(numerator, denominator) %}\n ( {{ numerator }} ) / nullif( ( {{ denominator }} ), 0)\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7038438, "supported_languages": null}, "macro.dbt_utils.deduplicate": {"name": "deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.deduplicate", "macro_sql": "{%- macro deduplicate(relation, partition_by, order_by) -%}\n {{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__deduplicate"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.705317, "supported_languages": null}, "macro.dbt_utils.default__deduplicate": {"name": "default__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.default__deduplicate", "macro_sql": "\n\n{%- macro default__deduplicate(relation, partition_by, order_by) -%}\n\n with row_numbered as (\n select\n _inner.*,\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) as rn\n from {{ relation }} as _inner\n )\n\n select\n distinct data.*\n from {{ relation }} as data\n {#\n -- Not all DBs will support natural joins but the ones that do include:\n -- Oracle, MySQL, SQLite, Redshift, Teradata, Materialize, Databricks\n -- Apache Spark, SingleStore, Vertica\n -- Those that do not appear to support natural joins include:\n -- SQLServer, Trino, Presto, Rockset, Athena\n #}\n natural join row_numbered\n where row_numbered.rn = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.705796, "supported_languages": null}, "macro.dbt_utils.redshift__deduplicate": {"name": "redshift__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.redshift__deduplicate", "macro_sql": "{% macro redshift__deduplicate(relation, partition_by, order_by) -%}\n\n {{ return(dbt_utils.default__deduplicate(relation, partition_by, order_by=order_by)) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__deduplicate"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.706228, "supported_languages": null}, "macro.dbt_utils.postgres__deduplicate": {"name": "postgres__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.postgres__deduplicate", "macro_sql": "\n{%- macro postgres__deduplicate(relation, partition_by, order_by) -%}\n\n select\n distinct on ({{ partition_by }}) *\n from {{ relation }}\n order by {{ partition_by }}{{ ',' ~ order_by }}\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7066555, "supported_languages": null}, "macro.dbt_utils.snowflake__deduplicate": {"name": "snowflake__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.snowflake__deduplicate", "macro_sql": "\n{%- macro snowflake__deduplicate(relation, partition_by, order_by) -%}\n\n select *\n from {{ relation }}\n qualify\n row_number() over (\n partition by {{ partition_by }}\n order by {{ order_by }}\n ) = 1\n\n{%- endmacro -%}\n\n", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.707027, "supported_languages": null}, "macro.dbt_utils.bigquery__deduplicate": {"name": "bigquery__deduplicate", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/deduplicate.sql", "original_file_path": "macros/sql/deduplicate.sql", "unique_id": "macro.dbt_utils.bigquery__deduplicate", "macro_sql": "\n{%- macro bigquery__deduplicate(relation, partition_by, order_by) -%}\n\n select unique.*\n from (\n select\n array_agg (\n original\n order by {{ order_by }}\n limit 1\n )[offset(0)] unique\n from {{ relation }} original\n group by {{ partition_by }}\n )\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.707389, "supported_languages": null}, "macro.dbt_utils.get_relations_by_prefix": {"name": "get_relations_by_prefix", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "unique_id": "macro.dbt_utils.get_relations_by_prefix", "macro_sql": "{% macro get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_prefix', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_relations_by_prefix"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7085774, "supported_languages": null}, "macro.dbt_utils.default__get_relations_by_prefix": {"name": "default__get_relations_by_prefix", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "unique_id": "macro.dbt_utils.default__get_relations_by_prefix", "macro_sql": "{% macro default__get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_prefix_sql(schema, prefix, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt.statement", "macro.dbt_utils.get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7103727, "supported_languages": null}, "macro.dbt_utils.safe_add": {"name": "safe_add", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "unique_id": "macro.dbt_utils.safe_add", "macro_sql": "{%- macro safe_add(field_list) -%}\n {{ return(adapter.dispatch('safe_add', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__safe_add"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7110965, "supported_languages": null}, "macro.dbt_utils.default__safe_add": {"name": "default__safe_add", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "unique_id": "macro.dbt_utils.default__safe_add", "macro_sql": "\n\n{%- macro default__safe_add(field_list) -%}\n\n{%- if field_list is not iterable or field_list is string or field_list is mapping -%}\n\n{%- set error_message = '\nWarning: the `safe_add` macro now takes a single list argument instead of \\\nstring arguments. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.warn(error_message) -%}\n\n{%- endif -%}\n\n{% set fields = [] %}\n\n{%- for field in field_list -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' +\\n ') }}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7122297, "supported_languages": null}, "macro.dbt_utils.unpivot": {"name": "unpivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "unique_id": "macro.dbt_utils.unpivot", "macro_sql": "{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n {{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__unpivot"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7144172, "supported_languages": null}, "macro.dbt_utils.default__unpivot": {"name": "default__unpivot", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "unique_id": "macro.dbt_utils.default__unpivot", "macro_sql": "{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}\n\n {% if not relation %}\n {{ exceptions.raise_compiler_error(\"Error: argument `relation` is required for `unpivot` macro.\") }}\n {% endif %}\n\n {%- set exclude = exclude if exclude is not none else [] %}\n {%- set remove = remove if remove is not none else [] %}\n\n {%- set include_cols = [] %}\n\n {%- set table_columns = {} %}\n\n {%- do table_columns.update({relation: []}) %}\n\n {%- do dbt_utils._is_relation(relation, 'unpivot') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'unpivot') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) %}\n\n {%- for col in cols -%}\n {%- if col.column.lower() not in remove|map('lower') and col.column.lower() not in exclude|map('lower') -%}\n {% do include_cols.append(col) %}\n {%- endif %}\n {%- endfor %}\n\n\n {%- for col in include_cols -%}\n select\n {%- for exclude_col in exclude %}\n {{ exclude_col }},\n {%- endfor %}\n\n cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ field_name }},\n cast( {% if col.data_type == 'boolean' %}\n {{ dbt.cast_bool_to_text(col.column) }}\n {% else %}\n {{ col.column }}\n {% endif %}\n as {{ cast_to }}) as {{ value_name }}\n\n from {{ relation }}\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt.type_string", "macro.dbt.cast_bool_to_text"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.717916, "supported_languages": null}, "macro.dbt_utils.degrees_to_radians": {"name": "degrees_to_radians", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.degrees_to_radians", "macro_sql": "{% macro degrees_to_radians(degrees) -%}\n acos(-1) * {{degrees}} / 180\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7195668, "supported_languages": null}, "macro.dbt_utils.haversine_distance": {"name": "haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.haversine_distance", "macro_sql": "{% macro haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n {{ return(adapter.dispatch('haversine_distance', 'dbt_utils')(lat1,lon1,lat2,lon2,unit)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__haversine_distance"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7201545, "supported_languages": null}, "macro.dbt_utils.default__haversine_distance": {"name": "default__haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.default__haversine_distance", "macro_sql": "{% macro default__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n\n 2 * 3961 * asin(sqrt(power((sin(radians(({{ lat2 }} - {{ lat1 }}) / 2))), 2) +\n cos(radians({{lat1}})) * cos(radians({{lat2}})) *\n power((sin(radians(({{ lon2 }} - {{ lon1 }}) / 2))), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7214367, "supported_languages": null}, "macro.dbt_utils.bigquery__haversine_distance": {"name": "bigquery__haversine_distance", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/haversine_distance.sql", "original_file_path": "macros/sql/haversine_distance.sql", "unique_id": "macro.dbt_utils.bigquery__haversine_distance", "macro_sql": "{% macro bigquery__haversine_distance(lat1, lon1, lat2, lon2, unit='mi') -%}\n{% set radians_lat1 = dbt_utils.degrees_to_radians(lat1) %}\n{% set radians_lat2 = dbt_utils.degrees_to_radians(lat2) %}\n{% set radians_lon1 = dbt_utils.degrees_to_radians(lon1) %}\n{% set radians_lon2 = dbt_utils.degrees_to_radians(lon2) %}\n{%- if unit == 'mi' %}\n {% set conversion_rate = 1 %}\n{% elif unit == 'km' %}\n {% set conversion_rate = 1.60934 %}\n{% else %}\n {{ exceptions.raise_compiler_error(\"unit input must be one of 'mi' or 'km'. Got \" ~ unit) }}\n{% endif %}\n 2 * 3961 * asin(sqrt(power(sin(({{ radians_lat2 }} - {{ radians_lat1 }}) / 2), 2) +\n cos({{ radians_lat1 }}) * cos({{ radians_lat2 }}) *\n power(sin(({{ radians_lon2 }} - {{ radians_lon1 }}) / 2), 2))) * {{ conversion_rate }}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.degrees_to_radians"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7231877, "supported_languages": null}, "macro.dbt_utils.surrogate_key": {"name": "surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "unique_id": "macro.dbt_utils.surrogate_key", "macro_sql": "{%- macro surrogate_key(field_list) -%}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('surrogate_key', 'dbt_utils')(field_list, *varargs)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7239454, "supported_languages": null}, "macro.dbt_utils.default__surrogate_key": {"name": "default__surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "unique_id": "macro.dbt_utils.default__surrogate_key", "macro_sql": "\n\n{%- macro default__surrogate_key(field_list) -%}\n\n{%- set error_message = '\nWarning: `dbt_utils.surrogate_key` has been replaced by \\\n`dbt_utils.generate_surrogate_key`. The new macro treats null values \\\ndifferently to empty strings. To restore the behaviour of the original \\\nmacro, add a global variable in dbt_project.yml called \\\n`surrogate_key_treat_nulls_as_empty_strings` to your \\\ndbt_project.yml file with a value of True. \\\nThe {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.raise_compiler_error(error_message) -%}\n\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.724443, "supported_languages": null}, "macro.dbt_utils.generate_surrogate_key": {"name": "generate_surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_surrogate_key.sql", "original_file_path": "macros/sql/generate_surrogate_key.sql", "unique_id": "macro.dbt_utils.generate_surrogate_key", "macro_sql": "{%- macro generate_surrogate_key(field_list) -%}\n {{ return(adapter.dispatch('generate_surrogate_key', 'dbt_utils')(field_list)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__generate_surrogate_key"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7253218, "supported_languages": null}, "macro.dbt_utils.default__generate_surrogate_key": {"name": "default__generate_surrogate_key", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/generate_surrogate_key.sql", "original_file_path": "macros/sql/generate_surrogate_key.sql", "unique_id": "macro.dbt_utils.default__generate_surrogate_key", "macro_sql": "\n\n{%- macro default__generate_surrogate_key(field_list) -%}\n\n{%- if var('surrogate_key_treat_nulls_as_empty_strings', False) -%}\n {%- set default_null_value = \"\" -%}\n{%- else -%}\n {%- set default_null_value = '_dbt_utils_surrogate_key_null_' -%}\n{%- endif -%}\n\n{%- set fields = [] -%}\n\n{%- for field in field_list -%}\n\n {%- do fields.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ dbt.type_string() ~ \"), '\" ~ default_null_value ~\"')\"\n ) -%}\n\n {%- if not loop.last %}\n {%- do fields.append(\"'-'\") -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{{ dbt.hash(dbt.concat(fields)) }}\n\n{%- endmacro -%}", "depends_on": {"macros": ["macro.dbt.type_string", "macro.dbt.hash", "macro.dbt.concat"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7266626, "supported_languages": null}, "macro.dbt_utils.nullcheck_table": {"name": "nullcheck_table", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "unique_id": "macro.dbt_utils.nullcheck_table", "macro_sql": "{% macro nullcheck_table(relation) %}\n {{ return(adapter.dispatch('nullcheck_table', 'dbt_utils')(relation)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__nullcheck_table"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7272806, "supported_languages": null}, "macro.dbt_utils.default__nullcheck_table": {"name": "default__nullcheck_table", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "unique_id": "macro.dbt_utils.default__nullcheck_table", "macro_sql": "{% macro default__nullcheck_table(relation) %}\n\n {%- do dbt_utils._is_relation(relation, 'nullcheck_table') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'nullcheck_table') -%}\n {% set cols = adapter.get_columns_in_relation(relation) %}\n\n select {{ dbt_utils.nullcheck(cols) }}\n from {{relation}}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_relation", "macro.dbt_utils._is_ephemeral", "macro.dbt_utils.nullcheck"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7280035, "supported_languages": null}, "macro.dbt_utils.get_tables_by_prefix_sql": {"name": "get_tables_by_prefix_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "unique_id": "macro.dbt_utils.get_tables_by_prefix_sql", "macro_sql": "{% macro get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_prefix_sql', 'dbt_utils')(schema, prefix, exclude, database)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_tables_by_prefix_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.728785, "supported_languages": null}, "macro.dbt_utils.default__get_tables_by_prefix_sql": {"name": "default__get_tables_by_prefix_sql", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "unique_id": "macro.dbt_utils.default__get_tables_by_prefix_sql", "macro_sql": "{% macro default__get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(\n schema_pattern = schema,\n table_pattern = prefix ~ '%',\n exclude = exclude,\n database = database\n ) }}\n \n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_tables_by_pattern_sql"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7293966, "supported_languages": null}, "macro.dbt_utils.get_column_values": {"name": "get_column_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "unique_id": "macro.dbt_utils.get_column_values", "macro_sql": "{% macro get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {{ return(adapter.dispatch('get_column_values', 'dbt_utils')(table, column, order_by, max_records, default, where)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_column_values"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7312922, "supported_languages": null}, "macro.dbt_utils.default__get_column_values": {"name": "default__get_column_values", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "unique_id": "macro.dbt_utils.default__get_column_values", "macro_sql": "{% macro default__get_column_values(table, column, order_by='count(*) desc', max_records=none, default=none, where=none) -%}\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {% set default = [] if not default %}\n {{ return(default) }}\n {% endif %}\n\n {%- do dbt_utils._is_ephemeral(table, 'get_column_values') -%}\n\n {# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #}\n {# TODO: Change the method signature in a future 0.x.0 release #}\n {%- set target_relation = table -%}\n\n {# adapter.load_relation is a convenience wrapper to avoid building a Relation when we already have one #}\n {% set relation_exists = (load_relation(target_relation)) is not none %}\n\n {%- call statement('get_column_values', fetch_result=true) %}\n\n {%- if not relation_exists and default is none -%}\n\n {{ exceptions.raise_compiler_error(\"In get_column_values(): relation \" ~ target_relation ~ \" does not exist and no default value was provided.\") }}\n\n {%- elif not relation_exists and default is not none -%}\n\n {{ log(\"Relation \" ~ target_relation ~ \" does not exist. Returning the default value: \" ~ default) }}\n\n {{ return(default) }}\n\n {%- else -%}\n\n\n select\n {{ column }} as value\n\n from {{ target_relation }}\n\n {% if where is not none %}\n where {{ where }}\n {% endif %}\n\n group by {{ column }}\n order by {{ order_by }}\n\n {% if max_records is not none %}\n limit {{ max_records }}\n {% endif %}\n\n {% endif %}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_column_values') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values) }}\n {%- else -%}\n {{ return(default) }}\n {%- endif -%}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt_utils._is_ephemeral", "macro.dbt.load_relation", "macro.dbt.statement"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.734602, "supported_languages": null}, "macro.dbt_utils.get_url_host": {"name": "get_url_host", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "unique_id": "macro.dbt_utils.get_url_host", "macro_sql": "{% macro get_url_host(field) -%}\n {{ return(adapter.dispatch('get_url_host', 'dbt_utils')(field)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_host"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7352836, "supported_languages": null}, "macro.dbt_utils.default__get_url_host": {"name": "default__get_url_host", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "unique_id": "macro.dbt_utils.default__get_url_host", "macro_sql": "{% macro default__get_url_host(field) -%}\n\n{%- set parsed =\n dbt.split_part(\n dbt.split_part(\n dbt.replace(\n dbt.replace(\n dbt.replace(field, \"'android-app://'\", \"''\"\n ), \"'http://'\", \"''\"\n ), \"'https://'\", \"''\"\n ), \"'/'\", 1\n ), \"'?'\", 1\n )\n\n-%}\n\n\n {{ dbt.safe_cast(\n parsed,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.split_part", "macro.dbt.replace", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.736236, "supported_languages": null}, "macro.dbt_utils.get_url_path": {"name": "get_url_path", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "unique_id": "macro.dbt_utils.get_url_path", "macro_sql": "{% macro get_url_path(field) -%}\n {{ return(adapter.dispatch('get_url_path', 'dbt_utils')(field)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_path"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7370803, "supported_languages": null}, "macro.dbt_utils.default__get_url_path": {"name": "default__get_url_path", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "unique_id": "macro.dbt_utils.default__get_url_path", "macro_sql": "{% macro default__get_url_path(field) -%}\n\n {%- set stripped_url =\n dbt.replace(\n dbt.replace(field, \"'http://'\", \"''\"), \"'https://'\", \"''\")\n -%}\n\n {%- set first_slash_pos -%}\n coalesce(\n nullif({{ dbt.position(\"'/'\", stripped_url) }}, 0),\n {{ dbt.position(\"'?'\", stripped_url) }} - 1\n )\n {%- endset -%}\n\n {%- set parsed_path =\n dbt.split_part(\n dbt.right(\n stripped_url,\n dbt.length(stripped_url) ~ \"-\" ~ first_slash_pos\n ),\n \"'?'\", 1\n )\n -%}\n\n {{ dbt.safe_cast(\n parsed_path,\n dbt.type_string()\n )}}\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.replace", "macro.dbt.position", "macro.dbt.split_part", "macro.dbt.right", "macro.dbt.length", "macro.dbt.safe_cast", "macro.dbt.type_string"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7384374, "supported_languages": null}, "macro.dbt_utils.get_url_parameter": {"name": "get_url_parameter", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "unique_id": "macro.dbt_utils.get_url_parameter", "macro_sql": "{% macro get_url_parameter(field, url_parameter) -%}\n {{ return(adapter.dispatch('get_url_parameter', 'dbt_utils')(field, url_parameter)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__get_url_parameter"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.739058, "supported_languages": null}, "macro.dbt_utils.default__get_url_parameter": {"name": "default__get_url_parameter", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "unique_id": "macro.dbt_utils.default__get_url_parameter", "macro_sql": "{% macro default__get_url_parameter(field, url_parameter) -%}\n\n{%- set formatted_url_parameter = \"'\" + url_parameter + \"='\" -%}\n\n{%- set split = dbt.split_part(dbt.split_part(field, formatted_url_parameter, 2), \"'&'\", 1) -%}\n\nnullif({{ split }},'')\n\n{%- endmacro %}", "depends_on": {"macros": ["macro.dbt.split_part"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7397368, "supported_languages": null}, "macro.dbt_utils._is_ephemeral": {"name": "_is_ephemeral", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/_is_ephemeral.sql", "original_file_path": "macros/jinja_helpers/_is_ephemeral.sql", "unique_id": "macro.dbt_utils._is_ephemeral", "macro_sql": "{% macro _is_ephemeral(obj, macro) %}\n {%- if obj.is_cte -%}\n {% set ephemeral_prefix = api.Relation.add_ephemeral_prefix('') %}\n {% if obj.name.startswith(ephemeral_prefix) %}\n {% set model_name = obj.name[(ephemeral_prefix|length):] %}\n {% else %}\n {% set model_name = obj.name %}\n {%- endif -%}\n {% set error_message %}\nThe `{{ macro }}` macro cannot be used with ephemeral models, as it relies on the information schema.\n\n`{{ model_name }}` is an ephemeral model. Consider making it a view or table instead.\n {% endset %}\n {%- do exceptions.raise_compiler_error(error_message) -%}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7413783, "supported_languages": null}, "macro.dbt_utils.slugify": {"name": "slugify", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/slugify.sql", "original_file_path": "macros/jinja_helpers/slugify.sql", "unique_id": "macro.dbt_utils.slugify", "macro_sql": "{% macro slugify(string) %}\n\n{#- Lower case the string -#}\n{% set string = string | lower %}\n{#- Replace spaces and dashes with underscores -#}\n{% set string = modules.re.sub('[ -]+', '_', string) %}\n{#- Only take letters, numbers, and underscores -#}\n{% set string = modules.re.sub('[^a-z0-9_]+', '', string) %}\n{#- Prepends \"_\" if string begins with a number -#}\n{% set string = modules.re.sub('^[0-9]', '_' + string[0], string) %}\n\n{{ return(string) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7426386, "supported_languages": null}, "macro.dbt_utils.pretty_log_format": {"name": "pretty_log_format", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_log_format.sql", "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", "unique_id": "macro.dbt_utils.pretty_log_format", "macro_sql": "{% macro pretty_log_format(message) %}\n {{ return(adapter.dispatch('pretty_log_format', 'dbt_utils')(message)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.743163, "supported_languages": null}, "macro.dbt_utils.default__pretty_log_format": {"name": "default__pretty_log_format", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_log_format.sql", "original_file_path": "macros/jinja_helpers/pretty_log_format.sql", "unique_id": "macro.dbt_utils.default__pretty_log_format", "macro_sql": "{% macro default__pretty_log_format(message) %}\n {{ return( dbt_utils.pretty_time() ~ ' + ' ~ message) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7435162, "supported_languages": null}, "macro.dbt_utils.log_info": {"name": "log_info", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/log_info.sql", "original_file_path": "macros/jinja_helpers/log_info.sql", "unique_id": "macro.dbt_utils.log_info", "macro_sql": "{% macro log_info(message) %}\n {{ return(adapter.dispatch('log_info', 'dbt_utils')(message)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__log_info"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.744023, "supported_languages": null}, "macro.dbt_utils.default__log_info": {"name": "default__log_info", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/log_info.sql", "original_file_path": "macros/jinja_helpers/log_info.sql", "unique_id": "macro.dbt_utils.default__log_info", "macro_sql": "{% macro default__log_info(message) %}\n {{ log(dbt_utils.pretty_log_format(message), info=True) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.pretty_log_format"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7443848, "supported_languages": null}, "macro.dbt_utils.pretty_time": {"name": "pretty_time", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_time.sql", "original_file_path": "macros/jinja_helpers/pretty_time.sql", "unique_id": "macro.dbt_utils.pretty_time", "macro_sql": "{% macro pretty_time(format='%H:%M:%S') %}\n {{ return(adapter.dispatch('pretty_time', 'dbt_utils')(format)) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.default__pretty_time"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7449312, "supported_languages": null}, "macro.dbt_utils.default__pretty_time": {"name": "default__pretty_time", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/pretty_time.sql", "original_file_path": "macros/jinja_helpers/pretty_time.sql", "unique_id": "macro.dbt_utils.default__pretty_time", "macro_sql": "{% macro default__pretty_time(format='%H:%M:%S') %}\n {{ return(modules.datetime.datetime.now().strftime(format)) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7453725, "supported_languages": null}, "macro.dbt_utils._is_relation": {"name": "_is_relation", "resource_type": "macro", "package_name": "dbt_utils", "path": "macros/jinja_helpers/_is_relation.sql", "original_file_path": "macros/jinja_helpers/_is_relation.sql", "unique_id": "macro.dbt_utils._is_relation", "macro_sql": "{% macro _is_relation(obj, macro) %}\n {%- if not (obj is mapping and obj.get('metadata', {}).get('type', '').endswith('Relation')) -%}\n {%- do exceptions.raise_compiler_error(\"Macro \" ~ macro ~ \" expected a Relation but received the value: \" ~ obj) -%}\n {%- endif -%}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7462654, "supported_languages": null}, "macro.codegen.generate_model_import_ctes": {"name": "generate_model_import_ctes", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_model_import_ctes.sql", "original_file_path": "macros/generate_model_import_ctes.sql", "unique_id": "macro.codegen.generate_model_import_ctes", "macro_sql": "{% macro generate_model_import_ctes(model_name, leading_commas = false) %}\n\n {%- if execute -%}\n {%- set nodes = graph.nodes.values() -%}\n\n {%- set model = (nodes\n | selectattr('name', 'equalto', model_name) \n | selectattr('resource_type', 'equalto', 'model')\n | list).pop() -%}\n\n {%- set model_raw_sql = model.raw_sql or model.raw_code -%}\n {%- else -%}\n {%- set model_raw_sql = '' -%}\n {%- endif -%}\n\n {#-\n\n REGEX Explanations\n\n # with_regex\n - matches (start of file followed by anything then whitespace\n or whitespace\n or a comma) followed by the word with then a space \n\n # from_ref \n - matches (from or join) followed by some spaces and then {{ref()}}\n\n # from_source \n - matches (from or join) followed by some spaces and then {{source(,)}}\n\n # from_var_1\n - matches (from or join) followed by some spaces and then {{var()}}\n\n # from_var_2\n - matches (from or join) followed by some spaces and then {{var(,)}}\n\n # from_table_1\n - matches (from or join) followed by some spaces and then .\n where each is enclosed by (` or [ or \" or ' or nothing)\n\n # from_table_2\n - matches (from or join) followed by some spaces and then ..\n where each is enclosed by (` or [ or \" or ' or nothing)\n\n # from_table_3\n - matches (from or join) followed by some spaces and then \n where is enclosed by (` or [ or \" or ')\n\n # config block\n - matches the start of the file followed by anything and then {{config()}}\n\n -#}\n\n {%- set re = modules.re -%}\n\n {%- set with_regex = '(?i)(?s)(^.*\\s*|\\s+|,)with\\s' -%}\n {%- set does_raw_sql_contain_cte = re.search(with_regex, model_raw_sql) -%}\n\n {%- set from_regexes = {\n 'from_ref':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character\n (from|join)\\s+\n\n # second matching group\n # opening {{, 0 or more whitespace character(s), ref, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark\n ({{\\s*ref\\s*\\(\\s*[\\'\\\"]?)\n \n # third matching group\n # at least 1 of anything except a parenthesis or quotation mark\n ([^)\\'\\\"]+)\n \n # fourth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # fifth matching group\n # a closing parenthesis, 0 or more whitespace character(s), closing }}\n (\\)\\s*}})\n \n ',\n 'from_source':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character\n (from|join)\\s+\n\n # second matching group\n # opening {{, 0 or more whitespace character(s), source, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark\n ({{\\s*source\\s*\\(\\s*[\\'\\\"]?)\n\n # third matching group\n # at least 1 of anything except a parenthesis or quotation mark\n ([^)\\'\\\"]+)\n\n # fourth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # fifth matching group\n # a comma\n (,)\n\n # sixth matching group\n # 0 or more whitespace character(s), 1 or 0 quotation mark\n (\\s*[\\'\\\"]?)\n\n # seventh matching group\n # at least 1 of anything except a parenthesis or quotation mark\n ([^)\\'\\\"]+)\n\n # eighth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # ninth matching group\n # a closing parenthesis, 0 or more whitespace character(s), closing }}\n (\\)\\s*}})\n\n ',\n 'from_var_1':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character\n (from|join)\\s+\n\n # second matching group\n # opening {{, 0 or more whitespace character(s), var, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark\n ({{\\s*var\\s*\\(\\s*[\\'\\\"]?)\n\n # third matching group\n # at least 1 of anything except a parenthesis or quotation mark\n ([^)\\'\\\"]+)\n\n # fourth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # fifth matching group\n # a closing parenthesis, 0 or more whitespace character(s), closing }}\n (\\)\\s*}})\n \n ',\n 'from_var_2':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character\n (from|join)\\s+\n \n # second matching group\n # opening {{, 0 or more whitespace character(s), var, 0 or more whitespace character(s), an opening parenthesis, 0 or more whitespace character(s), 1 or 0 quotation mark\n ({{\\s*var\\s*\\(\\s*[\\'\\\"]?)\n\n # third matching group\n # at least 1 of anything except a parenthesis or quotation mark \n ([^)\\'\\\"]+)\n \n # fourth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s)\n ([\\'\\\"]?\\s*)\n\n # fifth matching group\n # a comma\n (,)\n\n # sixth matching group\n # 0 or more whitespace character(s), 1 or 0 quotation mark \n (\\s*[\\'\\\"]?)\n\n # seventh matching group\n # at least 1 of anything except a parenthesis or quotation mark \n ([^)\\'\\\"]+)\n\n # eighth matching group\n # 1 or 0 quotation mark, 0 or more whitespace character(s) \n ([\\'\\\"]?\\s*)\n\n # ninth matching group\n # a closing parenthesis, 0 or more whitespace character(s), closing }} \n (\\)\\s*}})\n \n ',\n 'from_table_1':\n '(?ix)\n \n # first matching group\n # from or join followed by at least 1 whitespace character \n (from|join)\\s+\n \n # second matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark)\n ([\\[`\\\"\\']?)\n \n # third matching group\n # at least 1 word character\n (\\w+)\n \n # fouth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark)\n ([\\]`\\\"\\']?)\n \n # fifth matching group\n # a period\n (\\.)\n \n # sixth matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark)\n ([\\[`\\\"\\']?)\n \n # seventh matching group\n # at least 1 word character\n (\\w+)\n \n # eighth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string\n ([\\]`\\\"\\']?)(?=\\s|$)\n \n ',\n 'from_table_2':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character \n (from|join)\\s+\n \n # second matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark) \n ([\\[`\\\"\\']?)\n \n # third matching group\n # at least 1 word character\n (\\w+)\n\n # fouth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) \n ([\\]`\\\"\\']?)\n \n # fifth matching group\n # a period \n (\\.)\n \n # sixth matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark)\n ([\\[`\\\"\\']?)\n\n # seventh matching group\n # at least 1 word character \n (\\w+)\n \n # eighth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) \n ([\\]`\\\"\\']?)\n \n # ninth matching group\n # a period \n (\\.)\n \n # tenth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) \n ([\\[`\\\"\\']?)\n \n # eleventh matching group\n # at least 1 word character \n (\\w+)\n\n # twelfth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string\n ([\\]`\\\"\\']?)(?=\\s|$)\n \n ',\n 'from_table_3':\n '(?ix)\n\n # first matching group\n # from or join followed by at least 1 whitespace character \n (from|join)\\s+\n \n # second matching group\n # 1 or 0 of (opening bracket, backtick, or quotation mark) \n ([\\[`\\\"\\'])\n \n # third matching group\n # at least 1 word character or space \n ([\\w ]+)\n\n # fourth matching group\n # 1 or 0 of (closing bracket, backtick, or quotation mark) folowed by a whitespace character or end of string\n ([\\]`\\\"\\'])(?=\\s|$)\n \n ',\n 'config_block':'(?i)(?s)^.*{{\\s*config\\s*\\([^)]+\\)\\s*}}'\n } -%}\n\n {%- set from_list = [] -%}\n {%- set config_list = [] -%}\n {%- set ns = namespace(model_sql = model_raw_sql) -%}\n\n {%- for regex_name, regex_pattern in from_regexes.items() -%}\n\n {%- set all_regex_matches = re.findall(regex_pattern, model_raw_sql) -%}\n\n {%- for match in all_regex_matches -%}\n\n {%- if regex_name == 'config_block' -%}\n {%- set match_tuple = (match|trim, regex_name) -%}\n {%- do config_list.append(match_tuple) -%}\n {%- elif regex_name == 'from_source' -%} \n {%- set full_from_clause = match[1:]|join|trim -%}\n {%- set cte_name = 'source_' + match[6]|lower -%}\n {%- set match_tuple = (cte_name, full_from_clause, regex_name) -%}\n {%- do from_list.append(match_tuple) -%} \n {%- elif regex_name == 'from_table_1' -%}\n {%- set full_from_clause = match[1:]|join()|trim -%}\n {%- set cte_name = match[2]|lower + '_' + match[6]|lower -%}\n {%- set match_tuple = (cte_name, full_from_clause, regex_name) -%}\n {%- do from_list.append(match_tuple) -%} \n {%- elif regex_name == 'from_table_2' -%}\n {%- set full_from_clause = match[1:]|join()|trim -%}\n {%- set cte_name = match[2]|lower + '_' + match[6]|lower + '_' + match[10]|lower -%}\n {%- set match_tuple = (cte_name, full_from_clause, regex_name) -%}\n {%- do from_list.append(match_tuple) -%} \n {%- else -%}\n {%- set full_from_clause = match[1:]|join|trim -%}\n {%- set cte_name = match[2]|trim|lower -%}\n {%- set match_tuple = (cte_name, full_from_clause, regex_name) -%}\n {%- do from_list.append(match_tuple) -%}\n {%- endif -%}\n\n {%- endfor -%}\n\n {%- if regex_name == 'config_block' -%}\n {%- elif regex_name == 'from_source' -%}\n {%- set ns.model_sql = re.sub(regex_pattern, '\\g<1> source_\\g<7>', ns.model_sql) -%} \n {%- elif regex_name == 'from_table_1' -%}\n {%- set ns.model_sql = re.sub(regex_pattern, '\\g<1> \\g<3>_\\g<7>', ns.model_sql) -%} \n {%- elif regex_name == 'from_table_2' -%}\n {%- set ns.model_sql = re.sub(regex_pattern, '\\g<1> \\g<3>_\\g<7>_\\g<11>', ns.model_sql) -%} \n {%- else -%} \n {%- set ns.model_sql = re.sub(regex_pattern, '\\g<1> \\g<3>', ns.model_sql) -%} \n {% endif %}\n\n {%- endfor -%}\n\n{%- if from_list|length > 0 -%}\n\n{%- set model_import_ctes -%}\n\n {%- for config_obj in config_list -%}\n\n {%- set ns.model_sql = ns.model_sql|replace(config_obj[0], '') -%}\n\n{{ config_obj[0] }}\n\n{% endfor -%}\n\n {%- for from_obj in from_list|unique|sort -%}\n\n{%- if loop.first -%}with {% else -%}{%- if leading_commas -%},{%- endif -%}{%- endif -%}{{ from_obj[0] }} as (\n\n select * from {{ from_obj[1] }}\n {%- if from_obj[2] == 'from_source' and from_list|length > 1 %} \n -- CAUTION: It's best practice to create staging layer for raw sources\n {%- elif from_obj[2] == 'from_table_1' or from_obj[2] == 'from_table_2' or from_obj[2] == 'from_table_3' %}\n -- CAUTION: It's best practice to use the ref or source function instead of a direct reference\n {%- elif from_obj[2] == 'from_var_1' or from_obj[2] == 'from_var_2' %}\n -- CAUTION: It's best practice to use the ref or source function instead of a var\n {%- endif %}\n \n){%- if ((loop.last and does_raw_sql_contain_cte) or (not loop.last)) and not leading_commas -%},{%- endif %}\n\n{% endfor -%}\n\n{%- if does_raw_sql_contain_cte -%}\n {%- if leading_commas -%}\n {%- set replace_with = '\\g<1>,' -%}\n {%- else -%}\n {%- set replace_with = '\\g<1>' -%}\n {%- endif -%}\n{{ re.sub(with_regex, replace_with, ns.model_sql, 1)|trim }}\n{%- else -%}\n{{ ns.model_sql|trim }}\n{%- endif -%}\n\n{%- endset -%}\n\n{%- else -%}\n\n{% set model_import_ctes = model_raw_sql %}\n\n{%- endif -%}\n\n{%- if execute -%}\n\n{{ log(model_import_ctes, info=True) }}\n{% do return(model_import_ctes) %}\n\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.766253, "supported_languages": null}, "macro.codegen.generate_base_model": {"name": "generate_base_model", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_base_model.sql", "original_file_path": "macros/generate_base_model.sql", "unique_id": "macro.codegen.generate_base_model", "macro_sql": "{% macro generate_base_model(source_name, table_name, leading_commas=False, case_sensitive_cols=False, materialized=None) %}\n\n{%- set source_relation = source(source_name, table_name) -%}\n\n{%- set columns = adapter.get_columns_in_relation(source_relation) -%}\n{% set column_names=columns | map(attribute='name') %}\n{% set base_model_sql %}\n\n{%- if materialized is not none -%}\n {{ \"{{ config(materialized='\" ~ materialized ~ \"') }}\" }}\n{%- endif %}\n\nwith source as (\n\n select * from {% raw %}{{ source({% endraw %}'{{ source_name }}', '{{ table_name }}'{% raw %}) }}{% endraw %}\n\n),\n\nrenamed as (\n\n select\n {%- if leading_commas -%}\n {%- for column in column_names %}\n {{\", \" if not loop.first}}{% if not case_sensitive_cols %}{{ column | lower }}{% elif target.type == \"bigquery\" %}{{ column }}{% else %}{{ \"\\\"\" ~ column ~ \"\\\"\" }}{% endif %}\n {%- endfor %}\n {%- else -%}\n {%- for column in column_names %}\n {% if not case_sensitive_cols %}{{ column | lower }}{% elif target.type == \"bigquery\" %}{{ column }}{% else %}{{ \"\\\"\" ~ column ~ \"\\\"\" }}{% endif %}{{\",\" if not loop.last}}\n {%- endfor -%}\n {%- endif %}\n\n from source\n\n)\n\nselect * from renamed\n{% endset %}\n\n{% if execute %}\n\n{{ log(base_model_sql, info=True) }}\n{% do return(base_model_sql) %}\n\n{% endif %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.770337, "supported_languages": null}, "macro.codegen.generate_column_yaml": {"name": "generate_column_yaml", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_model_yaml.sql", "original_file_path": "macros/generate_model_yaml.sql", "unique_id": "macro.codegen.generate_column_yaml", "macro_sql": "{% macro generate_column_yaml(column, model_yaml, column_desc_dict, include_data_types, parent_column_name=\"\") %}\n {% if parent_column_name %}\n {% set column_name = parent_column_name ~ \".\" ~ column.name %}\n {% else %}\n {% set column_name = column.name %}\n {% endif %}\n\n {% do model_yaml.append(' - name: ' ~ column_name | lower ) %}\n {% if include_data_types %}\n {% do model_yaml.append(' data_type: ' ~ codegen.data_type_format_model(column)) %}\n {% endif %}\n {% do model_yaml.append(' description: \"' ~ column_desc_dict.get(column.name | lower,'') ~ '\"') %}\n {% do model_yaml.append('') %}\n\n {% if column.fields|length > 0 %}\n {% for child_column in column.fields %}\n {% set model_yaml = codegen.generate_column_yaml(child_column, model_yaml, column_desc_dict, include_data_types, parent_column_name=column_name) %}\n {% endfor %}\n {% endif %}\n {% do return(model_yaml) %}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.data_type_format_model", "macro.codegen.generate_column_yaml"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7747447, "supported_languages": null}, "macro.codegen.generate_model_yaml": {"name": "generate_model_yaml", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_model_yaml.sql", "original_file_path": "macros/generate_model_yaml.sql", "unique_id": "macro.codegen.generate_model_yaml", "macro_sql": "{% macro generate_model_yaml(model_names=[], upstream_descriptions=False, include_data_types=True) %}\n\n {% set model_yaml=[] %}\n\n {% do model_yaml.append('version: 2') %}\n {% do model_yaml.append('') %}\n {% do model_yaml.append('models:') %}\n\n {% if model_names is string %}\n {{ exceptions.raise_compiler_error(\"The `model_names` argument must always be a list, even if there is only one model.\") }}\n {% else %}\n {% for model in model_names %}\n {% do model_yaml.append(' - name: ' ~ model | lower) %}\n {% do model_yaml.append(' description: \"\"') %}\n {% do model_yaml.append(' columns:') %}\n\n {% set relation=ref(model) %}\n {%- set columns = adapter.get_columns_in_relation(relation) -%}\n {% set column_desc_dict = codegen.build_dict_column_descriptions(model) if upstream_descriptions else {} %}\n\n {% for column in columns %}\n {% set model_yaml = codegen.generate_column_yaml(column, model_yaml, column_desc_dict, include_data_types) %}\n {% endfor %}\n {% endfor %}\n {% endif %}\n\n{% if execute %}\n\n {% set joined = model_yaml | join ('\\n') %}\n {{ log(joined, info=True) }}\n {% do return(joined) %}\n\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.build_dict_column_descriptions", "macro.codegen.generate_column_yaml"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7775965, "supported_languages": null}, "macro.codegen.create_base_models": {"name": "create_base_models", "resource_type": "macro", "package_name": "codegen", "path": "macros/create_base_models.sql", "original_file_path": "macros/create_base_models.sql", "unique_id": "macro.codegen.create_base_models", "macro_sql": "{% macro create_base_models(source_name, tables) %}\n\n{% set source_name = \"\"~ source_name ~\"\" %}\n\n{% set zsh_command_models = \"source dbt_packages/codegen/bash_scripts/base_model_creation.sh \"\"\"~ source_name ~\"\"\" \" %}\n\n{%- set models_array = [] -%}\n\n{% for t in tables %}\n {% set help_command = zsh_command_models + t %}\n {{ models_array.append(help_command) }}\n{% endfor %}\n\n{{ log(\"Run these commands in your shell to generate the models:\\n\" ~ models_array|join(' && \\n'), info=True) }}\n\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7789588, "supported_languages": null}, "macro.codegen.get_tables_in_schema": {"name": "get_tables_in_schema", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_source.sql", "original_file_path": "macros/generate_source.sql", "unique_id": "macro.codegen.get_tables_in_schema", "macro_sql": "{% macro get_tables_in_schema(schema_name, database_name=target.database, table_pattern='%', exclude='') %}\n \n {% set tables=dbt_utils.get_relations_by_pattern(\n schema_pattern=schema_name,\n database=database_name,\n table_pattern=table_pattern,\n exclude=exclude\n ) %}\n\n {% set table_list= tables | map(attribute='identifier') %}\n\n {{ return(table_list | sort) }}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.dbt_utils.get_relations_by_pattern"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7825463, "supported_languages": null}, "macro.codegen.generate_source": {"name": "generate_source", "resource_type": "macro", "package_name": "codegen", "path": "macros/generate_source.sql", "original_file_path": "macros/generate_source.sql", "unique_id": "macro.codegen.generate_source", "macro_sql": "{% macro generate_source(schema_name, database_name=target.database, generate_columns=False, include_descriptions=False, include_data_types=True, table_pattern='%', exclude='', name=schema_name, table_names=None, include_database=False, include_schema=False) %}\n\n{% set sources_yaml=[] %}\n{% do sources_yaml.append('version: 2') %}\n{% do sources_yaml.append('') %}\n{% do sources_yaml.append('sources:') %}\n{% do sources_yaml.append(' - name: ' ~ name | lower) %}\n\n{% if include_descriptions %}\n {% do sources_yaml.append(' description: \"\"' ) %}\n{% endif %}\n\n{% if database_name != target.database or include_database %}\n{% do sources_yaml.append(' database: ' ~ database_name | lower) %}\n{% endif %}\n\n{% if schema_name != name or include_schema %}\n{% do sources_yaml.append(' schema: ' ~ schema_name | lower) %}\n{% endif %}\n\n{% do sources_yaml.append(' tables:') %}\n\n{% if table_names is none %}\n{% set tables=codegen.get_tables_in_schema(schema_name, database_name, table_pattern, exclude) %}\n{% else %}\n{% set tables = table_names %}\n{% endif %}\n\n{% for table in tables %}\n {% do sources_yaml.append(' - name: ' ~ table | lower ) %}\n {% if include_descriptions %}\n {% do sources_yaml.append(' description: \"\"' ) %}\n {% endif %}\n {% if generate_columns %}\n {% do sources_yaml.append(' columns:') %}\n\n {% set table_relation=api.Relation.create(\n database=database_name,\n schema=schema_name,\n identifier=table\n ) %}\n\n {% set columns=adapter.get_columns_in_relation(table_relation) %}\n\n {% for column in columns %}\n {% do sources_yaml.append(' - name: ' ~ column.name | lower ) %}\n {% if include_data_types %}\n {% do sources_yaml.append(' data_type: ' ~ codegen.data_type_format_source(column)) %}\n {% endif %}\n {% if include_descriptions %}\n {% do sources_yaml.append(' description: \"\"' ) %}\n {% endif %}\n {% endfor %}\n {% do sources_yaml.append('') %}\n\n {% endif %}\n\n{% endfor %}\n\n{% if execute %}\n\n {% set joined = sources_yaml | join ('\\n') %}\n {{ log(joined, info=True) }}\n {% do return(joined) %}\n\n{% endif %}\n\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.get_tables_in_schema", "macro.codegen.data_type_format_source"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7879388, "supported_languages": null}, "macro.codegen.format_column": {"name": "format_column", "resource_type": "macro", "package_name": "codegen", "path": "macros/vendored/dbt_core/format_column.sql", "original_file_path": "macros/vendored/dbt_core/format_column.sql", "unique_id": "macro.codegen.format_column", "macro_sql": "{% macro format_column(column) -%}\n {% set data_type = column.dtype %}\n {% set formatted = column.column.lower() ~ \" \" ~ data_type %}\n {{ return({'name': column.name, 'data_type': data_type, 'formatted': formatted}) }}\n{%- endmacro -%}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7888105, "supported_languages": null}, "macro.codegen.get_model_dependencies": {"name": "get_model_dependencies", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.get_model_dependencies", "macro_sql": "{% macro get_model_dependencies(model_name) %}\n {% for node in graph.nodes.values() | selectattr('name', \"equalto\", model_name) %}\n {{ return(node.depends_on.nodes) }}\n {% endfor %}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.791115, "supported_languages": null}, "macro.codegen.add_model_column_descriptions_to_dict": {"name": "add_model_column_descriptions_to_dict", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.add_model_column_descriptions_to_dict", "macro_sql": "{% macro add_model_column_descriptions_to_dict(model_name,dict_with_descriptions={}) %}\n {% for node in graph.nodes.values() | selectattr('name', \"equalto\", model_name) %}\n {% for col_name, col_values in node.columns.items() %}\n {% do dict_with_descriptions.update( {col_name: col_values.description} ) %}\n {% endfor %}\n {% endfor %}\n {{ return(dict_with_descriptions) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.792147, "supported_languages": null}, "macro.codegen.build_dict_column_descriptions": {"name": "build_dict_column_descriptions", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.build_dict_column_descriptions", "macro_sql": "{% macro build_dict_column_descriptions(model_name) %}\n {% if execute %}\n {% set glob_dict = {} %}\n {% for full_model in codegen.get_model_dependencies(model_name) %}\n {% do codegen.add_model_column_descriptions_to_dict(full_model.split('.')[-1],glob_dict) %}\n {% endfor %}\n {{ return(glob_dict) }}\n {% endif %}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.get_model_dependencies", "macro.codegen.add_model_column_descriptions_to_dict"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7930727, "supported_languages": null}, "macro.codegen.get_models": {"name": "get_models", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.get_models", "macro_sql": "{% macro get_models(directory=None, prefix=None) %}\n {% set model_names=[] %}\n {% set models = graph.nodes.values() | selectattr('resource_type', \"equalto\", 'model') %}\n {% if directory and prefix %}\n {% for model in models %}\n {% set model_path = \"/\".join(model.path.split(\"/\")[:-1]) %}\n {% if model_path == directory and model.name.startswith(prefix) %}\n {% do model_names.append(model.name) %}\n {% endif %} \n {% endfor %}\n {% elif directory %}\n {% for model in models %}\n {% set model_path = \"/\".join(model.path.split(\"/\")[:-1]) %}\n {% if model_path == directory %}\n {% do model_names.append(model.name) %}\n {% endif %}\n {% endfor %}\n {% elif prefix %}\n {% for model in models if model.name.startswith(prefix) %}\n {% do model_names.append(model.name) %}\n {% endfor %}\n {% else %}\n {% for model in models %}\n {% do model_names.append(model.name) %}\n {% endfor %}\n {% endif %}\n {{ return(model_names) }}\n{% endmacro %}", "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.796096, "supported_languages": null}, "macro.codegen.data_type_format_source": {"name": "data_type_format_source", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.data_type_format_source", "macro_sql": "{% macro data_type_format_source(column) -%}\n {{ return(adapter.dispatch('data_type_format_source', 'codegen')(column)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.codegen.default__data_type_format_source"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7964888, "supported_languages": null}, "macro.codegen.default__data_type_format_source": {"name": "default__data_type_format_source", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.default__data_type_format_source", "macro_sql": "{% macro default__data_type_format_source(column) %}\n {% set formatted = codegen.format_column(column) %}\n {{ return(formatted['data_type'] | lower) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.796966, "supported_languages": null}, "macro.codegen.data_type_format_model": {"name": "data_type_format_model", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.data_type_format_model", "macro_sql": "{% macro data_type_format_model(column) -%}\n {{ return(adapter.dispatch('data_type_format_model', 'codegen')(column)) }}\n{%- endmacro %}", "depends_on": {"macros": ["macro.codegen.default__data_type_format_model"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7973602, "supported_languages": null}, "macro.codegen.default__data_type_format_model": {"name": "default__data_type_format_model", "resource_type": "macro", "package_name": "codegen", "path": "macros/helpers/helpers.sql", "original_file_path": "macros/helpers/helpers.sql", "unique_id": "macro.codegen.default__data_type_format_model", "macro_sql": "{% macro default__data_type_format_model(column) %}\n {% set formatted = codegen.format_column(column) %}\n {{ return(formatted['data_type'] | lower) }}\n{% endmacro %}", "depends_on": {"macros": ["macro.codegen.format_column"]}, "description": "", "meta": {}, "docs": {"show": true, "node_color": null}, "patch_path": null, "arguments": [], "created_at": 1706549583.7978337, "supported_languages": null}}, "docs": {"doc.dbt.__overview__": {"name": "__overview__", "resource_type": "doc", "package_name": "dbt", "path": "overview.md", "original_file_path": "docs/overview.md", "unique_id": "doc.dbt.__overview__", "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--select` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/introduction)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [dbt Community](https://www.getdbt.com/community/) for questions and discussion"}}, "exposures": {}, "metrics": {}, "groups": {}, "selectors": {}, "disabled": {}, "parent_map": {"model.aspects.enrollment_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_enrollments": ["model.aspects.enrollment_events", "source.aspects.event_sink.course_names"], "model.aspects.xapi_events_all_parsed": ["source.aspects.xapi.xapi_events_all"], "model.aspects.dim_course_blocks": ["source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names"], "model.aspects.navigation_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_navigation": ["model.aspects.dim_course_blocks", "model.aspects.navigation_events"], "model.aspects.completion_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_completions": ["model.aspects.completion_events", "source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names"], "model.aspects.fact_forum_interactions": ["model.aspects.forum_events", "source.aspects.event_sink.course_names"], "model.aspects.forum_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.grading_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_grades": ["model.aspects.grading_events", "source.aspects.event_sink.course_block_names", "source.aspects.event_sink.course_names"], "model.aspects.int_problem_hints": ["model.aspects.dim_course_blocks", "model.aspects.problem_events"], "model.aspects.int_problem_results": ["model.aspects.fact_problem_responses"], "model.aspects.fact_learner_problem_summary": ["model.aspects.int_problem_hints", "model.aspects.int_problem_results"], "model.aspects.fact_problem_responses": ["model.aspects.dim_course_blocks", "model.aspects.problem_events"], "model.aspects.problem_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_video_plays": ["model.aspects.dim_course_blocks", "model.aspects.video_playback_events"], "model.aspects.video_playback_events": ["model.aspects.xapi_events_all_parsed"], "model.aspects.fact_transcript_usage": ["model.aspects.dim_course_blocks", "model.aspects.video_transcript_events"], "model.aspects.video_transcript_events": ["model.aspects.xapi_events_all_parsed"], "test.aspects.problem_results_uniqueness": ["model.aspects.int_problem_results"], "test.aspects.learner_problem_summary_uniqueness": ["model.aspects.fact_learner_problem_summary"], "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4": ["model.aspects.fact_enrollments"], "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f": ["model.aspects.fact_grades"], "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da": ["model.aspects.fact_learner_problem_summary"], "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b": ["model.aspects.fact_learner_problem_summary"], "source.aspects.xapi.xapi_events_all": [], "source.aspects.event_sink.course_block_names": [], "source.aspects.event_sink.course_names": []}, "child_map": {"model.aspects.enrollment_events": ["model.aspects.fact_enrollments"], "model.aspects.fact_enrollments": ["test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4"], "model.aspects.xapi_events_all_parsed": ["model.aspects.completion_events", "model.aspects.enrollment_events", "model.aspects.forum_events", "model.aspects.grading_events", "model.aspects.navigation_events", "model.aspects.problem_events", "model.aspects.video_playback_events", "model.aspects.video_transcript_events"], "model.aspects.dim_course_blocks": ["model.aspects.fact_navigation", "model.aspects.fact_problem_responses", "model.aspects.fact_transcript_usage", "model.aspects.fact_video_plays", "model.aspects.int_problem_hints"], "model.aspects.navigation_events": ["model.aspects.fact_navigation"], "model.aspects.fact_navigation": [], "model.aspects.completion_events": ["model.aspects.fact_completions"], "model.aspects.fact_completions": [], "model.aspects.fact_forum_interactions": [], "model.aspects.forum_events": ["model.aspects.fact_forum_interactions"], "model.aspects.grading_events": ["model.aspects.fact_grades"], "model.aspects.fact_grades": ["test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f"], "model.aspects.int_problem_hints": ["model.aspects.fact_learner_problem_summary"], "model.aspects.int_problem_results": ["model.aspects.fact_learner_problem_summary", "test.aspects.problem_results_uniqueness"], "model.aspects.fact_learner_problem_summary": ["test.aspects.learner_problem_summary_uniqueness", "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b", "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da"], "model.aspects.fact_problem_responses": ["model.aspects.int_problem_results"], "model.aspects.problem_events": ["model.aspects.fact_problem_responses", "model.aspects.int_problem_hints"], "model.aspects.fact_video_plays": [], "model.aspects.video_playback_events": ["model.aspects.fact_video_plays"], "model.aspects.fact_transcript_usage": [], "model.aspects.video_transcript_events": ["model.aspects.fact_transcript_usage"], "test.aspects.problem_results_uniqueness": [], "test.aspects.learner_problem_summary_uniqueness": [], "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4": [], "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f": [], "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da": [], "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b": [], "source.aspects.xapi.xapi_events_all": ["model.aspects.xapi_events_all_parsed"], "source.aspects.event_sink.course_block_names": ["model.aspects.dim_course_blocks", "model.aspects.fact_completions", "model.aspects.fact_grades"], "source.aspects.event_sink.course_names": ["model.aspects.dim_course_blocks", "model.aspects.fact_completions", "model.aspects.fact_enrollments", "model.aspects.fact_forum_interactions", "model.aspects.fact_grades"]}, "group_map": {}, "saved_queries": {}, "semantic_models": {}} \ No newline at end of file diff --git a/partial_parse.msgpack b/partial_parse.msgpack index 1063228690803f9a00d31a559d45929f6f8a4fb0..7a2eeee59379fbfbc7f1322aee1d8a08f2210484 100644 GIT binary patch delta 21679 zcmbt+cR*Cf^Z57O-FxreqYHu!DRvP!j(SETYGR2EdoNTgmS~J6wlsS^Wi&Q4#@Izq zT@wqI7)vY|dqKcnP}KCq=x=uC4)F8)Gyj;}?#%4$^qt+u{m1o-AJtz_)js^BkNreZ zkfY1##N=~rFrbnlz#70?CQXNGjW=f9t&a9P`%s;yXK00lW>^sEX?Oc|0$6n~;aAfC& zNse>pTNv!S+W5iN7|G3ktZ8+}n}c?RBSeMww0nmI+kfih>G<(jTa)8^eWH|@k{TbI zVU3TAwPvIy$7ZC*rC4my*0}W8)RfdTYn;UvV~exK+hWoz2`MS*F|ko8F>!HG(FxIM zsqs7CFHTuP3XYD0tlE6o=^FiDN1 zMbI=%>t?T`+X-RiZ6C*pqSjKPB|bGOJv}ZpE;`y~iM7SrqS9J<`q@`y> zC#1*N(vxi&=?T`j)YP<;cw1_+usi#o)muAm1&$K77ksCfGn=JL!|mb0o-oKwsx3L3 zjON-ct%uoj&%4`m$40Qt9@0&T8>B=2DhP(xT(y6Vg&s(ScG^ zqf+86R!fR4In@$tv8JS17@Pqcf%JU7h~ z-M6~qPE#)_F+DCSJvknIH6|4o&#+ihZE-Q_$FJdv2=| z$IjLUgJW7mU!mzn?qh|0niAG&!WJR2istT!nbkvhVCeQBF}-u{JlU~g$LC_OhW~gm z*kbo5n&aoy5kzR$VjK){)Y&-JY~QDQ*`H7FcX&-G5ISmfdZWPb`%G3HiS~9?X+G08FM(blMBw5ceoH8m#AYK@Mf z-8;Hv-4+H^!^ig)7CrcEx=BZyiUU zm17N#U2R?nLunlGvtaY5PD!#OZ1`9yF)9Ovonni&q{YQpGSE&k(qb%8Y00T+$FD5kvlfbXb&6i1&11I6&+7gj4Ib{i1xPq(I}SYs{d zxf#~fw6v78gfvG~^I4K(aPLDxk~RP6=ZNgqySr0VRlmt+)BVd1Yh6ho*VB<3A1#mamqvD186 z8>^IQFkI^mKH*X*Oi9peY<(4JnTgLgs-6KjUzzm_k}3<`G|C?(2=xz>8cN_EDw$b9 zZK)SQ|I1u+ITG6&BXu)KpMh7r^s9YpeFb_aNaKX~`nmJC8^KhY)J-5ZPJU)TuhnI< z8%sxx-dw`zLF+Shl{535$`Q5s=4%%egt&@{87^$G+t-j z-+!dMd$e zdmE_(p>%HzQg_K8g2$TOU~W$>97?vy3hU8cszm?;RtgkA6nC(+$A9|nmfhL$Bq>Ib zIj6HBYM?m)I!rX_kThNjfC1ekPu8Nlw3;iW^N}?{WdyRuDwUYmAgQrIpgx1BB9lKX z_{`+SQ7eHZOH$dwA<_<7`!9cpN|6%S)J)VKCwA0ONwCYbkb+|EaRUeU<+A4wy{ zf=7dVz~_yW0Ei{C%<_)QE^AzJkMvY9Q_A{BvpkGw`G})n=b7oGJQ|Ojw#4=;%v!>O_?RFq2WP8VTWoCfrupr zH}Gy@@MnYON@i|PosUks>0J4ZtTVUXQZV=1&PQ1WL!m7u>6}_6_yy#*DofgHh$InR z+C!)vmKj1|K$yYI7S}i2rn#4+VaH>s5lk9naAyUoVXQAF`$NekZi9X>a)YF>kE$AS z1QW-!t^d2b!pa7f^$Rvc2o8?b=|K|PUdxb8C=KTk%A49Kkn6*=YOKj}DZqp4;249D zJf$MTMZOZ;96Q;ClsO<(^I-cHN^OL$juk`GPtnv0x|-cs_!22kto5UhlQI`ILs7T$ z;H>}ntV%i7SAHj*6^i-sS06TNpX4RhIj&gAb*fB21vjnEXf z<+P*=y&WI6O&B{&df(v2-dvEz5#HqQ2oLQ$6h;ow0wCwUNnt-loHLmy7%tf4Bweb&Qp z(M^mriy?pU{@UQfnyfWsiCv#J@!DqOgNA+FjwjEd%$rVx03Q}Sc8 z))~Gcr1mWc$)%cLHe$A60nH6=PIKrfp{(&-!x9?K3=+#T@A-y&8W}Z(0H-v=IEYqM ziG?jRETXxO!f9?mAnHEs6D^1t?FNe3XD1a3Niy_sgOKgn&!(4K5@magh|G);!wflT zLx2m436L8e!-y75!>e1D1zgBpVW`03R~Zfxk#8ToJy(%6$~NqxxtvHM=Sl?uVA*ak zv4R{!vao=&4_P^6?>>?@^x1=m+@t~^_m1qpBv?1YPp1@}?Kq_@B-B2yVBs`l2vj|=9(MgxJc{bz+@{<*9ku+ZNe#LjMVE%9R#_m*l9uuZAJKHsX;79Mr31Z#;laxlx= zsoW5blcx=2JN78gh2rvjzJ?ukV=xRGC}}Kjui_Bu%4=34h_P=DCF zNs*c3kn$(t57@*3D`v%_*m4#rztQOIXxc6sv|E;!jIv44E3gNP70PRQ3(k~bUCL7I zChos^TPTS(S!i@)^Oh??BI@MrgQo9eqAzSOyTP2*iVwTHN|{1CIoA}{+{eAmT&ra9 z;;VCBQ9T-Yf1{En38HtQs1Ii5qzIJkm-{ej*PLsdOI(&b0cjYPJXZ&z9X+0BY)Cu( zXA%$D!O-Zip(5+Q(AZWCpV!(l6u?Bm)cG);YfxWvkg2w-jNU8-jJpNZ^VaraZ*Xvn z$&EE$X51zCI3EvD-CTTZIDmZAT5jA*7>&D?!}xOrV(`73Z}wfOkYK_!Qw8?*byK)7 zm-9*B6N<|pTC7yulW%GubauX1O%7iTe(Gd&gMV*nDyy{4^nhsX3Wum{b1+2QH(((# z&Zt6g0Rl8$Z%U@!9sZhlIM7ekLA!49Wal@So)Pki1F&#_QlFJqOdc%MVLIn7 zWbpSo?wi5T@S4dBysnvK7Iw(=S}ggq^e<1l^`XsClOM}GVmc$}{_GY)K8YyR*ra2o zG@-GdtB}aH^Ay@E-{=F0Cr#e0?nzSLXUV&>)|7fU#eP=ci@-=MiQNkz+j{nOX{6U5J5>)3L_ouE0KdVzLNBz0iI} zDM_8(d|?VBl3ix~4@oW*miViQjPOFQ^*l2N!(VSq-f->@Qzdr&chg_|?ArOlY_Bqs zOG;$V-9GXNQ660Qt_z98tAgweSTM<8Icrpz-&tcdFOGV#LIti*XMvWKZ>%MXpNoUa z7e7lL8~dum3NMZ8h5219t_B^C7(-aW@5Z{qJum+1l#d8{9ZV))miV{v z5kG}@z7+CHnf4jZjS>65RPO~(6CtqmgjR!jsHTqv?MqG3doap?u+DdW#=H;~XF5+P z=e`lv35B6X89FpHnVHRIsxMZ#jK@5FLSZQU0|NSTg%9{hFuXcx@MI(3H-!iZU5=|y z>_mQvzB6a42~UP?P3s7yNpm4{mfgYR5cY7n>p;#{65NoDS#riZ@VJg$xeX}sz*kD#HZo&xvk%>NU(Y;~q-HjOL{q5UR} zG)FdB##L=43hw||O?JMt>ZI74yP;hf?3jd@m({}y5A+R3o8HDOH^Ie_g{WlyocYnO}5Wrfqa zY-ayx@&=kKI$JI%jnCEGS;;EnVR5Fo{y}URO?Gah(O;lkKk$mw@3zIbQ3QtT`GHj3 zT+cB^63o5EVz01ir_qbGav1%D&s_f_9@cDCgV?k^#y3I)*I$QIYB`XI^+|9N29I-l zjSBmIuko$`xPeKMmsoK1Ft(I0es4TU!|H3n1RxVw%3Z=L_xyh2Mw)Yv=6pK?!-!lg zt+yRC9;Z2+F@jXFl5Ac}Ysj$p+5`k1kp zD1|Sje4KmSSV3fy8$Gv{?nQ^3eFhUW*=$zWjl%}YD>qUS%JeA;vb@6v84`aod$3kN z7#<7J-56F#kyOkD-!PkCz#`qm(sK>e!MO49S<1Kq;M`8L2Is7j0*Om-t&{r<{Y9p| zF^i6gKdqMC*oy}8Vq)4J%QaOGBJpg`zK@VUp<(c$f~`Rh`H83&Zfu27GtlGr`WAzsS8w?Y5!ioQSb!+OnOk4^G7TSH$<2UQ%^obczkHgc zdg-u`YStoT&01Ba!~BiHnSuwH9V~mW=s@{8k+|q$ap zt5_j;)@ry+f##;EHJq=FHR;79d9y&c>Ar>RsAL^h2qRu$*|ocqJcj1H=aQO5y6Dga zMf2-&`3B8Z-e2lG8svU1D-gU20rXY!dLgNs)p_ir%9!Pc$`5I@HmpfE24u~}I<9dq zT(SQP%?F-^BBpySIhSCfxQaqpAB((+)@oa`)POu8CklZRtuh^BZ+6^DM*Z7Da|LFK zk+%~{_ZFr0tizP1vJA6-*EIGbR$fT}eKyeEg!~-w@;5Y`(uBv#dIE*bvB?W*c;LKp zk|=%$+k_q7k=M~&rf8xB0~VJW;nis@XVX?jlMwP#@Bs4kUDtlb4((cmPDw$c~uc7Jys!A-bZ8# zr;|u{5-41TQE+>@tT8!Vo=Us93u}6zePw5$w|Fgene)@zrC1EH9uloz=^O|`+14O= zzZlN{zm9@a78oK^!z5p(5XpwklYbx>53IahXA?GHf&2vxd;iJMks^d3@@q6L=R<{4 z6%(`8la~pn&bPiIkLxo_zDlUgAC-gloGYtr$Q-$l=Guf4^uKGJ5hTCgAOX$LKl2D? z@CdQRJ&WX{G%(3tN>GDUi!qP=WtaVkwRsws2&aqUmvL{xl zP6N4D{wHZ7f($t`3?6JiyfU1C&NrdRS-c+mg64(_8SJfscPUj0l=+PmFE*i(a*0q% z4w1#wPgLlRfX!*5&^h|nUxDHj1@HDkJ4II`CdU%=*jsONqQijavKLr7U^iRb3ia9{2N39_ z@{zu6HIqC0+9CT3r4~$gwwSR6MA3fx9?S&4?v`U{Q(qy#k8(|T_BYQ2f#_^0-^tXb zC^%Y!GaLcWzn8t);(hYhwBgf3xLTcUk;yHv-8}Swyo2VhsAZvt+9HXEaHG9)u|i`TV({PzWN_07 zC*Or?K9#11zmP3{f+~!oZs7CoCZ0++Dla7HdYnt z{1m3%Do4j(QxqaU^gfl2q8?6iQ>g7!_~8l;?W~8Zcw+B#sE5;}3n!oSwE$YMI zK*blZL#(g~)s$hhWk*BW0gqJQx(7Qqu+LI1Q00Uu?yO~~GSDp4aTh{zv2}+CUa)PB zVrIT`l=o<%-`WY5+0=Q;W7@>4Hf4^$u+#gu7%q~UmXq6${S<1<7kPv*Y^_BJVnx0O zgdxD+7TulwlHzpDqAJbFk%cAX*)3JKkAdW@S;E%^5{#SANAbWhe{x)MxmC8?#^*8}=@HJjn! zEX5NLKw-Hvl~97})t3Up!BaA2=G#ktBNcHGGHkR`_Pf2jTnCxGb55>D_}^xbPtH9r z*QAl{-eo??Z(nf93vvba#|60?0qpsP(u(B@Hb_@r#hQNZWjq~no4>uEu8XnGsKn-9 zmDh-vbNlW}>Rz~o=+)ThTe7DxuiMX05FxJ+U4cd+y3Y0$IZNc*fApj9-#!F(Kq!+aNigiDYBVz2nHsQFazx1W&PpTq5oaR7?dYufD}zMP zJI9gVVIuK{>~L)4RDFfj!4}s~Htw}yHjz0zlB(r;1|vD&ofBKBTCTbruVgYz#u2o` zpQ(#mI0h5!Ki!S)%(ujlK+8S6#IUolOf;(QRv1W|6Jo}qB!G=MZb%V;cdHA>4`$eE zZX}k!TjzsPPxk_>BxE-Gs-Zxb+1+>OnoC@M;W@VoVYKQ*7`*Y#&gC1Z>2bIHB4?+@ zj`#N0@P>|7>^g@e(e|dX5(~U-I7FoTaMA&ANJ4MLW~&U58!kVNSqm4zx+k7m^aRgRwmI5KMH=602cq6&y z-6dOvTo_(2CldXyh>54$(1q7GGOicR!@DQG6nbUD-#7k1d$@F)w$^hKZf!&>V`~~N znoqUCly9-j&T4O@>&v?(*i7J0kjiQUVPPvfVuU-LWTaEb-QQ}^DtI$Sg~{E2J|jt$ z-iNVAU5v$Ise5=J7nc8OkkOa59pvn~-K&7zv1!H#;VV!$*l1=GhZsEwrBa}9d-kTg z@h=eu??tR7XMg@2uL!bx8qMH^FBRddeONvw^)gaba4%*$b?F=THTtvZeT)}HJMUhv z`V5`u9ilzJ`78nb$B&&(H`1;3y+QryIDhK{BQ+-Ojp{9IMf7yVah}%->_}TYBkd-{)Jq)WehQyRdUiWqG^8Hbllb2MXfTJf_I3e%Gw;X{uvy^WN<@6Gu^$a;^j zaXG;)JVL@3neF?pG7yHwD8hyEYRw00K4UAoh%<6R_ zqzThxQ)?PiX?VlOWI`C%76}u&w-weDAV+_=8LJY=-u`cEUk6bhWqKNYSPxHUANSt= zcNp$+hiFdTJ4@GqiNV+)`JkcE3!bjk0@=FC#?3_X;tV1wO6%T6Qy5!Q&G=lz-g~#4 z#)eh3AHQx2W5prH!Gw1Qn?<~u?Kjft0{33o%1H;4mKTgXX;2`0H+H&DeQ2Zu!hOSH zibzk!7{znN&i8%#iHOATmNr@@5pADCjK zmgfD$pBNe|-7?&7S&@>GNCT54qsG?HFjDP!zr#ziQ=S1JaTdka?}V-0A4+{6p%3=eaN{Z(9uY`KojI43pJ``{qK$3sDs(_C+64Ua`1ls22v2lZfqzYHm3?JyI)L2l6aH2 z&)1A8Xih1p)=bRd4W~hikN&Yo>ef2S<`=ecZY~v_E0?Wh0K87t%r(f8)E3 z<#!6cfWr#3Sc1Y^c@lrlJ8s?t+ovfy1ZJTu5o9zmT{wkXb_krUWLAVwlGb3s=(F8S z0qViaQT$z72xR}PdU0m(j%FuHZQl;_72z5WO=S%bA6T$lugsE`nLCNyJoF_+ZeNdG zSIcs9DBzUB{#b5~A>5#D|Fd|zEqw7?W_n@zFpl1Mj2wq|daHjXX~^)r02zQn^ERQW zhyA-S)D(rRhndchg#q!7*x7vOdBq9>kg@R(rhgC&39rPUwl!<7Idu&1(d{e%2$ryWDnLEf(r|y!l^- zw}R31C?SwEOnnXJ+Q=Sik`l_1I(&LZ{~r>f(K z>X(O!dtA99JRhr9WQF%tN{CN(lvy}pg#ykf?D!*ftJu(!gY78uE`6qk)7+`2YP>MD zCs!sCS(kOFF!f_Sn6>{!rMFd29*g5&H8|J{FOu4Ss+-y12=hvz|0lm)5DLRJb=V$h z#*VkeObv}EZ)%na8?rM|h!LHgreEwE!9#>aXpJBL{FqNSvrX_*Y&k)AuGpgz@_cWz zMd-D-xp*rb0{eZN0P#+0$*C{&!uEk>M?ec-?s zC|#c~R64B|k5A?PX@U7^Xhe0Vt9Bwdo4Q;KV`Ku zy_;}JSUpG&V58TnkA>M5GkOH|T*1n8WS*)K*<-j61~`TRE{{e|Z4r42Fi)wFvlt~j z|FY@}Iag7&hc2n>2k(D6rIqOPQAHwWEk-+akT$vsA6XmM>K4kpI+L)>{|3M(njBdt+Cr_;_l&N|CckmP&{8 zr%j%{tpYR={_5lOQgtJ7@qWIDhzuhlJt%qFvn!!+p)ibr?}$A=9h=KN)oI&(7NBiU zOgB^S^{FeoT)|+4E~~@T1=wXCGSEC&n8wp34Jdu$iOh$M?QL#CYk!C31^4M2ea*v! zmp^^kO$156AgRG?FS9q>Z8X!Z$1{(V(m9n)l$|#IEWpU{1<(-@@SioHdcl=`REE1f zC}P61R@g}6apm97RWl5qjy1xPcg@~{k!M|lghjI(iRQI}<7a(a2uVW3Y~7!I)z;}J z&xURx*@#4x*TGz!y=rf!yTWJF@Y!8yI4@|38|b$Ywg2@7r+GY^O=kfSQ(@|6wG#Vb zlX`_XfE7eo#Cu_cg(I<{d*zf$Y4X{+AtDYijNaD?WgA|&@eCjW#_QkJ4@Cxlc82;4 zBGf01*L@iKOU)ILCpE6hV0QQ)x9O2ciy&F3mCo8FZNI0LO7jqm9E<+8dZMba z=@V7@=A@+iHK8fSGk|c1k`Ki>o1ysx5LAQYfId*YEq2CM*HIS`$`3WU^8~W%ca=86 zW?x(%D~Pa85o$Ft^0H!MF3D=xkx(az-pk8O;Jx2!EV7YGEz6e^3t&x0wHC{MSEUo; z%Qb5lesj}|NbH=+gKZ$I{hn&0k;A(v5OnW|&y(#f)$xMYm%rdzykbCeP+4RLyI}7l|8Jb#}0$O7;9N>MuNw2eK!f)fgecU%Yk;!7}Z4 za~EDbwsn8@e~|31^IG4e0$i=pp7ZF zNH2S;)C2|?wa)OSI&It|a;A`2;(z`Am~VVGObgWJ@daIE?ISKF!nW#KDs%|drj=u* z_q+e?Q(_@!{%!IHus`^1Ny6q3Z4pGM+LChX^|a5el?W+jt(Q~>B2}#t+>ODru{w7y)MAKcNcDt)Qj7 z1(4*cEt47$ol_NYHKC0|6}71HVE_4p;Zpf{*{3Y>gaUuf#`W@Lxka9EcdP*YJT!Ov zU&DPlBmK)w_x#Ua19Kjl*@JrGL!}B@D{itC?EN|^P~S`AAE=gzze!pmhwTAvJ;;7t zl281PANyK3*=Sf|*1YTkG6Q&cvccL~+MM#s!`#~1I{3SWw(_mfmOfG<#MRP<*+Y-j zffX&Zu6(*Q*e12qIve3iBucREyZ9Ya=Q>(ad4R-d{L27wu^AcGs5o160)EV%VM$5P zu%t#u;b-?5_$MoplhYHTqY|vC*0`vYgqVcb82p+#8b_mJ;_(kgKuEaOkbP2Dt0YNw zSW-`mWEbmc+jtTvowP9c?E|fT`JJ%IZM1k^OqQYfb=K@A z`;Pjdd|&mUhDEFW*8B#Gc3LdtQUtpYt@+7tukqWOWBcFLzEj~rg7)ECEAF*v;U;v< zkf9iJ4t3WC;B1F2Iq@L%(`K^mJ+z^cRFh`UP1DS9XryFWPl z_tG+41kR7tX0dv`wR$|Sm6F7dbF_^Tc3L?2vAu@sJQCCg_s_K$0rmn1D|JtbI^s?9Dx4Exfw z+kCV>^k0PEJKspwdcHM(G)225S!q$P{gMWG=~}Py5bV1QZ8jG-=YT|XVX!7TtFDn* ztlKbcfCNcnwNvE)XTheAwWCr?=r~r3a>r|t7`23aKboWsDvuAtCTou{!HCHdvvC;|eur`p zv)S(xvhHLd8X!1!NwJy7v}Uf6Z*e&Tg#L&* zG_enU^ZpKDl1JnynL1LLqjw4B4@1x=V&ciaMKs}Ig$#%)3niK9%O(E2X&bM%VV z$_d7h(0zl{g0`LHZBk)-ps5P{c?#iPpC(f+C0BSx%Y~z-L^2SIa0$b&KVjW`{)D!} zwKVQ%9{8WaZ_iQ6K@jl>1CJ0ywMSYL0n~CQOMaw@o7N88RD@m*KhXfb$i?yjF%%f^ zKoc5Hb&(Z7z7Mr;VeMli8@UfJ``$f>5%Sdmk(`C$Cm+=Ix-=rlvMq zUqp)QuzY4C+Ku6#S_A9}9k7_NoTZ0@gGiffi@leKVgb-IDN;F)y{{BrqZCt+Qkm zX1VJwsWJ5Z#u7~YhJX3$Uph>}92uamAWiwf885xBYiq&+4tnc*rTxTa)u||k-l{GF zdnrSW&H7TZ5nnji234~B6{@7@4^dCJRI&h8{^>F$Uuc_+V9)(@UM;yG=E8-F`d5Z) zPFs3CP4>RvNB_5%y+XANv;RU2Zxv zTnmLYm36!y*p1(^O|GZ&asgU~cm4}f`d@Qd?5V@R_u=ZBlI`b9{L)J3!`9c^jR3$XMO zoCYP~6Q-GyP+_MV==`))#>Jd)eV4@94S*4U;A5snp`?sbI(2L4-=Z`HolW722OO$H z^5zf}KI-ZxAb1$2<V>q6~E*u6v?+{(i3$t-OTmZ4JtkA>bR3@S{?!^bNb z^R(W42_BWXG@ZNz7j62L_86vsD24?Y5n5(1 z#dLs-E_A^PIea`ha;+3@MtS_25yk>Y^m zR2e!2J0JS4&<=yVT3hbI5^{>k)-J;r-;|A_^UjCe>$P*77C(iN2DwW+)@eUWQN)PF z$B2h>Ph=!%rIua_#&bsNRoZ@+GzHiyf8?j}nlh2{)WYJ|YHcK_u?=+^IT}BMw5>*Q zp$IHaVho{vlU$-|vX=_gQafqVUU}Zar zcW7%Mvzg9MN*$IvlN}q~TyG+Bd8uc;|GxeyR<)xR=^-$s7%#_jx9DpzC&kiG&Jz5f zF7Ghj15El_KOq7B4uCzmS{NI?RR3Ipl<~SB1bvHF(A(EwY=$*6v1$HhgU%$W8BtjE ztvQ6D!=1s&kDb6!IM?hZ@+sS#rB9RK%_(yL>+_AiomZrSmu=he#`o!JJzHWgm+8e~ ze6b!1Icszi%in~tS*#`2-m^mADB*cbAV&O*SB`?i%y0F{5*xWlziY(5GbAR(cHS(| zec^Z}nq%ft&g}wy6t}*pWW4$s`nf(s!muxX9L&_`NUY;%T{XCdB8TZ8^HTuMS7i$( z=}AUrN!AazhQRVnt<2_rr2850QL6qGXPbjU|5&_$&z_B8PO2q{!%$xw!9;&aLLKwv z;M^cxW_qe_m)PwLJ|021NK=Mt*Hll|eU$#UB)ubsS?+ZGHg{OTD&j71{eVyA;w3b% zR@k#N{Z|QY_t5>a=IbU%9EJZND*GsZ*&RW1*j&sF z3^g2JaI(nUzC`7m4JbaMhAh#QC8u-7SP%;rO;#Tz67o!w)?~(?4!$wRMS#Zx|ij&|;0S*`jQ5QN6Yf9zJ$NYVw%D zBZl`MoOZ1y{HgYf z2n$LTRHR5$1gQoQL8Juu6j91=cIPe${_FRAk56uQc4l_^&hE?g-G^rN_LPjwqM|fMW}Yq0=`5?7Tw1X@c!-&EQ}oW-iqNork~F$v zO88bu?mJ@S@UrHSFVG*eBU{rS-$mN!4ho$$wPbjU6IYTzkzaW#!{;(h3{}Hm4)qk(qAG zEXXKG%gs+Ka2BMb+KN*0Q|x&TTV`f%T6(U-<|uHaI&+H(a*Hx-g{cmEW=2KT zJ7JtuQ8LI(YFf2~tEpn~@XqFnKC`lQp}YIzEB3#0P%k@r!Uu}$>E30^sK|=>lYFGC zJkCaDy0b7ZE#2wJC@8e26{e-8W;k#-Key0sw`CONJ8dbbCPzkLMoMZ50%bZHq<`=$E~Ym~2RXA9zBAgBs4IHUG?~ggjDU(h7tgDlp=tfzt!Q(#L}7TGVGbDDMjfS znW=dNh54BoPJ2dfQF@9kFFnJVUyz>aNO9Wob8Y#~ltO#HJuTmsnwLjvuC6{P*c{M$ zb&ZQv{ zmtk`_9fi&mG{%C=)S|SaqN3c?qWrv!0$WB#fg=w+HUmYUnIhOP>v=l6qV$yz&BkKGD`lI4}SNa1Dxh(R+ zJn^Gq!-eIhitn~2(=NZdC-xDyYqX_e!>TvL<^~1-A_lvy9j{k-7?r}Rra#xB;-c^C zGMB}cuwGJ@JtN)jNXc{NIg1>5MfsU|Md_L8>Gm`Ss;wy1S(KN82Ayk9L%rqa=cc4* z|e7GVFtlYBIr2G)RP_Bk^eptS^i*43zTJ_Zn~`fz&&@@q zo$0os^n%pfOlNw&Eyae$PRwMbETz4key!qSX1FAU2$5Gc_pR99e1OZ}nzZaC89YQK z8dm&YSyJm~%D!opO~OrRZ57T4t+I5Fis~MBE!-n#M1~;0$rZtQJ#{X>iW?n}=c3%g zjH059+`Np8!n8ExqkzZllr(!$sy#gu%_I#4mSRgQ%FoYq7NUt4721kY3v$sXk?YhV z;@KV71~08&V=aBVPLP-oV(BaCE+Mx3Gr8iAZs#P>gCsk=>mx<7X9Fd(Q26jAPjPud zwL|h?V?(5!66E?yjTl1RF!2ox|1;SQV6bie(o-hsRp=Wo#ei?Dl*|%iqz`2d_eN1E z42hCL*{wJ!l!DRS6MQ8@)XgMV-dM7*l4PlufSw){>Ym#yF?)R}P2otU_pmTTGQ`Bn zQ>AVuX}{q(n|{3-d2jDfirLNfke2~Ll0pC+DQpC{EJz@ zvCS_@`80BE5Fg2arX3YemfcB86_V2ew+KMkchjOl;}_NXP~KhgX6L#|E6obZNoxYb zc51<}VW48L_R}P*2(DWG_i%BQYK6!gDFpWIFv+lTj-;_|v!%{LyxQn~49QIqw6){U zK1n2uWo1h{Xzui%0uw__(`n@AQv#ap&65@qvOCLZq@=%8BDk{rA588g1=n!h2rj&+ zs?0uE`pm?+wiuARMG1x*@0((veX-=jGK-}~LJOAADzMKrWw4dQrI!Uki}ePf_kK;< zN+XFAh+z~TT3@yv!~(`hha`d84sE)agTecx6akju?HTgh`dsZ6N~7M;^pc zNoUny6F-wuytu*Xv0GpmnCrudX?hHxP&LRJpleL}S}G7obmw^2-cCy0#S$ZIpIE}C zUy{BNW@f}pg=nj6g%(5f`mF4-^n>8oNZlotE^3P#_1-S|v-MY{RGMm?1@k*9QDC%{ zyddWXNoQfdOBP}FMsMPjwZ0`iAn1O*S(`gjeVQISpXL53wG?J#EPJQcj28WgapB5C zX^ddp*wD|l;r^(Ca+4{TeIl9K6T-hkXwGf4VXT#Gve4Y49e`3xgu$9A9Fk+rDtKp@ zTP-q~Cc@?;W`pHurX>Q>!|PkZf@+Ten}^Aty=a))8eFa(olsloXKYh|$;(%aoIXKf zJJ-MzEOz4YTiL(35DH)!jZIyJ5qeZZ^dmIFM;%lH)+d@`*og$wDxpqKOE+4J_~XEL zu@uh!dRHo{$0>PPz932y*GroPC9jy{E>6+rSk4y7DUf(&HF6EVhOSVuRZ^jPofOP2 zZerg%w1s$Vw)F8*Mw-jN^)u4Plo0J9&IHLXgXGpgY$Niwq|V)QwX45~B4kH5+jKHFWh!#VDqSC8kz>oK@dhKe9GcP1iickFPHXGh%bPn)V1n zzCWvi5L;+B9gE>G{xc1-*Uu;F32gN{rcz;n{_k(9VKf+gC!qz8TVR??bE~VlKV^ay zOun%1Q(0ww7MZ@JxsS(#Up6{byLU}%X=GChk@Q_+N)~GNXBUOz!G=T=I@=`OU^AAP zE)w*fQbCuYfX>m#!MEygl5!Opg z%&J4x3|jl%Gu(EptV6h}65P74IPHc|dZeo-D|=cctF8C#mzuVDduT>Zj4_1|f?8e+OJVpf+HS1JpQy zI3WBIZ5}g)0rO5MMh*Yo;2nqtFf>^0L7)xNVaj4mQ6G<0J=ruHN}LC&fM)RCX71HV zY5;6bQGM7y4mC$a@PNT%1(WRUhN=(Yn7mAot6^|aJ>>6HytX*5^0L-UsS0MEk%(y%Ew*mLI67-EN z>PNJP2ckG(9hRxX#qvPqJ6etfNC?*OsNc;_BM@2w+Gog0wHrZsFqq%f9L*v?9Uu?| zhEn~Au5YmQi`5wf7yUmTl&#FtQEg9ft-!tplRTpDLIY33?V%JHJlJn9s~5$-0(*W% zY+$^=@H9e=VBS4c^7O#IdwG1evcA34G$K>5Q7DM*>aDI4hor#yab&waid1j5uu!Ff zFL1>ILR;emi{cC~Hm$$fmJqG$$>#&%^@SMN{;CCKNN;H8GhT(=RFYwSqVzp^^ zMT1-MhQ>ME#yHffs6Y=atK6|oL5))`=(fsu;O zvC0{0qQDtsUn<<4Lf`o&7_O#{RIdwOf||Wg^lBWRyCQ5JjYc)~iWVS(9{pT4Qk~8E zj#m59!q(sLg@KT~j;o=KVXz6`svBwUg|^K8y?T^>v=0^(P(B`P*C%QN;;C>Bx6UTa zm#O|VGB}!?eyMKqVcmDS;&#x)ygE)_9%|MgxrJe2%XX=L!eN5IpFIEES86D`u}{58 z=+->VFve;0V`IR-b_vyAs`XgHmuh_i_~eC}ECQRx;^sZG44uix)N0zq?v6Dw_7*P3 zY{%6ITKoBMAqj@6c5UUzC?Y2mJoyMFkV%J7BfAc(UbLig14YD;N2aAj;M@hSBP$I4 z$Xt(Ie{5<-fLBfkzF2#cIal~%&>d*A-W){Mzib_r`{!hH7m;3qgDAaRKZeHt+ydQ~ z6c2(b|AY5t60;@>BjzrEZriHGZmtz?ARk6E+jVNw##*Ne5FM8Vbh1n0V2wTv=LQ6Ae8TtJ=orn@+0A=AuoX6eoUoUYM={$u6wY1 zqht!zA?+Wqi(};bVpAcVAJkZf7gUdvJz4#6@^Zq_ji;<2_-Tyd1M4Tq2K#-y{1q*G z^*yokngoT_s_f0GC(7^Ae9k1WKf?NA<7D|U?S2^eWm#Ogec3duYO3Cl$;U#*v?4Lq zL^Sqby6i7}I%HMnS`jl8ai$NiB}4vsn+_gdPc=6bXT{JiJ!u3F0NLWi7JB$kh8ox> zydd<)fr24eSB~~GaG5zsNH6rFgV19<^MGUP%>MAxO0yUHa;5p4=&aTEn)4(;6uY|C zOoyiWfpFW5{RUeV#ubhi%GaX_%vf(8EojzH#9YcNf%Q9dA2#+``I?YTeWy`Jo0T{R zs7+tC^?CVY0?14wnmlo^-Wl>Qo_x>sS3Sjd*pNp(e<)3r6_%YMXA29dzv-+97u=>a z@J&Z_QkqOB;QF74lGY0AI%0{~cavU^VXORVJzkZBbp$C)5l1IwQA0U|*|wO!6&S$%Ol_rGjzZ9&<2Tx7!S2U3i!)?blYNd-fy1oPB0Ps3p8r zF_oUXzA_&WrV;);R^Z zH`5hO_)ygK`Jw(w~po#UnNXj4{UZrc^(ZrT<04+7a1(8k$j7W zTOJ@~<|N9&Y*>PvNyE>$vaLXZM~q%H+_pj_%tiH)wH%wgmqxp8cB$ZoX0T;Ho8J-A zkNEa)GWXseW7}`YujXfk8ALqVN&)@!O?1fLZU4;ZB${`n70mn zBGK_@Mwr)#;1{_QE;hhOe9H@qxApJpo-8NIOgCncdwSL!VPvR$7X$b!(dK1@_j6aL zMcCnkShPcI>|_eli#*IxirOh)Q7)o=n2zD1qM`X~;op&0#VI-vY@cC%n%&MEz_vTg zj|lBeYH%?O34aJ_N8WR7fEOn0_jL0VA?+yjPf^vv#~o!~Skc1l%PN|iTZV`!fAIjAm2vt_>A%?$X zwhE`Q+W484AEi7XX}KQEUhiV|69}zoxeQB~x%8ve0>VCixgN%HyPNUMgzC2TkcG{N z;%9lbnIe`o`xM_q3be{Kd$W)nb1TA8p!0s2m5t9cM~fI_T|hl%K^>Rtki0_oW@iVP zi-p}-5ByJ@L0NToR}!{<$CGdn__o5n>*kJbH{IA%wg4(I5H|Hhf6VSB&mofMsdk}) z`JNR!iwoOgiWR*7HiEWf?W1_X_4b(merP8j6RNiU3Hu#tFo>#=7Y6X41E$u?9pv+( zwvTStMW})$t(H#RN!%8 zF!MqALqc}`ESE!L0zUhNJfDUyAEs>4{1A$N#aC|V8{No*Icg~W5#z;#uif&y=Q^1n z>%Oeb5qXs$8zb>Eo+zk7q4X#U)Ot*&mSBuWDoGrb>A_BZEuW3$axGqpq?RC*&10+;lL>IbT=aqLCJ;r^Rw(7Ve=G)5z1} z&=v@S{^Ll6I*u`2Ty-~^)Hk$;S0UF2Lm_GyZvnQrbQLpTdaat7cZEETuoefC=r(!BY~irJ8?cGNAR(s5YOOS~_9f z$_tru)JXDV)z+X0sVTOjPiJ%a3SCqi4(|XxcI9Sa6owQO! z{N|hF0JdnOJVwmLO4y#jzTNhda+Fvd8%QC=_c%5+_ME~}PC2SQ2j$n~a2R@0ehPd( z$1Z4Mgz8PRl_ycaEl$gHrxTmt+9|osIr*$$GB)Khg%9rw@(xk7#%ARZ+ba}hFTu3E zPk#F9BiR6(1;fC6O<7NK9ne`(E$l}hC7Sqt6)&Bz3B|ApMfZNO1tND*USlU>6uSM0 z9kPKF!iy>1PQBSs31HTS%5Gt(v1qvtOr0z4$=K7!JP|vgypD}xc% z(`$^_*|!AN+UQYo3j?!fwLF?I&*M@IB3D`USl&VC-^bIXE7DomY)J{Hy=?f5^uvQP zJ84!n5cF0-BaorhY^RZ3V+pX}N5`VqDAV-LS4T!^6yZ6&UbQ*b#4 zXog!nmGOl251kJHGtSptx43|6SK6MN?Y zEfvkxBVVE$l!Pi2jbiWjq&aSf%=(PtE4JUjTNEUuA(r!;Lam7g0o^%t5G#K{$s)k8 zg<^zvg#wswJ0*pNW4vhR171?-TB1SXa}14ofN;JBErFS#b-46BEJBF;2?5nJ`xR)v2oY7Be9qUI8&m-`V*cmN83eI9Bw``b{T zr6r?Akv+Y+U7$h=tA1f_-8Nu2EJxQI6H=1IyA!XDznwu>_v z`*^xij{sxIv#5~8dk+tGYo;5qjh%260Tb05sPs0y3e~OlObC=>Hx_5Dt#hndw{1}sc(mJU= zi;Q>0>9`7k(#r7MZ6m%v9Z{#|0n{#$&auyoQ0j317N(%051duW|Kv38v} z74EfQcX{N;u3Q-Jw9pnr2zh>k%WmRZm|Pp?y@1J^lyky}<6DD$DIRi~R^e$eK{pz( z)mxPMB9g^FL%|7ei|F1Z{-uFpH|+5;g_2r)&r%oCn(IH_?pmX)RD{0bb41H3kXheT z4iNW+uDB%HpkIH0<{R;Wa+i1+4ALyD1caSF{s9ZhIo^gJ%h=~K$oNhEH7#u)sM?RY zVEX3@-G#>QaAg%9U;vx03VV1^`IYeQY`i z^NJ_jyoA9K0aSMDXIGKXD7unihp&W|ID{Ke-h-905x{P~tI&zHQD!f(O@{6x6Lc$a z`5w3i<1r2N_n=5DZq%bnF%H@qamWm6i0g&dCgQNl1!u7m$;Cv(6dwzWY=$+ z4B?KAmS8RB_AM5E$5cwgn@VbjVeSJwo2)Fw)8wT;Ow(1a@<#jU$R#2K&KHn;4$Pr? zv&S5~h0wk+4I^&v?54_QMWrcKMC8Wd*XY>6hb00dGT45EVhX+ z_1!SZYAlLb=s9eY9xaF)6pO~%9=6acxF*Fp+`l5A`)VT?l0Gmz*as6VJu~?MCSg}U zek_V$=XYDiiN;x?B3_el%z&8v*qj5FC88;on0i3K0>T#)a1HvMvjnoWXDxOip2Sm2xGzSqhvzM^LLrF{;i8VO`S6}w zgXe#>B(ahz%U=RG$$LHTC`Yi_mn@lrVp8M_+$O`>ufJNTC!f@DDfg)exN_SP3M+3| zRJe81qOzUWEx!v9Cv`h1#KW*_Ob3Ldz9J(=0PvY$W zN=yvdD%PWD3~0Jn)1cKTiyxGiAd#G*7OJt5M$ZR)oEOa|msqG>l{E2r&S@0eGu%S2 z1(Rm{{sbalD1FUhVTVUr=xRD?&K*84@~FXl23fpl%kTY7!|1dI%pPs=XD3Hl&ePsL zews_u2J=d=tzJFG@;wc2`G@Nz3TCg;0@%GG%U$88Nk>J#V;5exOctU~I>X!BL4X5( zP<=>~p%35-pyyw;929{y=_)<6v?>FJ)WCinx^gf8qs7V4bByyWwW`zhe1Z zu#oKWHGg21!S;8zbQ1eW4x@ZoD@Qj)FDB<%R3Yr-xY0t6fO7O@#7b!+@S+FlLWAsZnM~ z9*{=MuwL+h$r>6@Nh(@-^(jO???`*lwC-Cvr`S@SR2a5RGzj(>a@K$+7dr+CP3g)!B3kE7+jIELe?U z4b9C5e4n@I5cwRcXvEVNx~;SYzr)LpXjpy+PyW{N_>#cqIm@?#L0fctej#mTw#%AM zBTes%m$$6%70m^cdV_Bw8WI$XFLeA}s|O`FxB*_%KBOg?+l9Otz6?B1BdtWm#=FX{ zm?C`P_*4yR7wl0o>`_uVX6w4Y)*+z!2=~!x1oaej%EcX(XIVU9*;J%DVXD>=s%5Qy zEgZwfCO&WF^2kph>3up=3u4%%0Xs>0wrOa)RhbwNbKa+RCiZ=2X{Ut;*v7ju zV~u-pX@)}6PjH`|H)wP{VOxy{?760BhydiK!xnr5ivSv&iNT9Q@pI4y?S0t%t`HkY>!~rS2FhT+F5=V7dCdM2TyHQ*fbC=^&6W7i|Pgzy11}+ zvewLLtX-Uij&k;%>lii)J{MH&Lu|qp0Bu2I=$Cthq1xZFlc(m4Li=6%HGUhzHDF(U zo%ScLFV7#*==q#|>l9vnMX`^MYxjhz?4J!0Mh9qg8kEcE?&n6~m1^(>xjE_l;c=}q z);(VozvHhL;v;fo#-5WQjY89iL|NZxkjBM~S1>8nItM zyH9)j&DCwh7OlZd%d|+b!r@8fnFyxMf-u^2TcI5h*ISNfI*W`4nDI1Luv??63P%V2 z&V^se84S}WB`!xd(zOUdVV`Ruc&}|ywtKl^on!Do{va(HUOj-1u=&&?FLc>WJ{E6L zh&txX;)Q4wJKkTTTTsX1O+sA^RY|8J$J&o62?ou^kl)X4p_u5{E6(CUyvVB!`9bW{ z6w5-famR7I4B@n2x~;`g->alrqfp_v8cd%2+Z~NKN%3~Q$f!kEH3!4fJLwi`jHE=I zBSoO|`!70(fgYVKP}oUI=1N!O;;FZ|(h>mHgXmD*_iN*X#iaE3u});lnuZT8ay~}@ zgvu0hNO@B<>ZoJ@EEzQRT764vT3m6Jc*UGKN+>ARV|uNEAZLuBu$uvvPlU~-M!X=P z-42AsNigQ~svrxsM^l@3Wf;`o5vWtUO|RiA1TGZtxSET6v3%{W*jefuu6)f+9njSA zc2m+6meE$DenRRMaX1bFy!iKEliF(wyt#`w+k8%3@XU1fIl}|~&cSTk{Z*~4Anfe* zE$OCt753v=Wo!QIMz(f=<_5V=*E|O<>Vi$6G+(W|Fk0tKdhN>V7@n29*&%-|NJ!AR zGnebY#x_-}g@osakebcK({t+nch!T!Hk`jxBnR$Q49g5UDW$3XY671RZ2n1Apm$@e zynLEy&4fJCf@)gAu6Vz%ndZm-$<*ipW*TNIUOtMlhY$>X6?ZVCg|X?$QRsu-Q^D!;cc8#GcX?pQsZ*kdn%lL}^3C?$UOys|i`YE=mirHBcOb z>ggP#og#iuT_oQ*^Bi)KeNPRc#g9gkE!P^mEgO{|c^}UsJMOC#2h!7AB@e1x$Gc&b zJ{C&vjF&U~hQ)0Y^`P=aL*ITw9V;?_dIA4#A_z)P;h7KGwz_E$eIX z%oL^-3NF)^KKwU3+{z#%8&4zsv$RQq>GT6W1jQW?eDC8s?#O3Q_$g0o-wSc2-w}O) z+GNZS3w0(lwDxuM!r6uPvSwi^vi7!MIwMNR9`F^N2YxxHbrU2ro<90-A#c8qMlr;O z0`akH8!bHeW{jf;TUbLNbGt~{?kLs(Xe=5sVdV}B^}RmRx~d@F%$fLGVb`i|fF_QB5xcA4M;%Gx(oB zSBLq!?tl_iA1%d0X_g)g6MglfS_-{d{kLz%Vg4gaBPj9EJz$%k-c@oCk!o*!LM@S= zaMVX%A~h<@eJ2zu>(!;-6BY*OZ%YY$s?2M$KOFVYn?PTG-BxG$fBrn2q>xij?*?8G z`V5Y`ccVABy2_UQoCS_Zy$f<~>w@B0tl-y^52N+GIza#V%W$G^i`8>ru37hos0fr- zj#VE~he+9lzq4R?wBAFq5hu$c^)Yqk|MO?x#Kh$&y^oX%m(tuP=s}Kz(lAL7yPK3_ncc%VBJoKBUgvfBvw$MoT_rn}6_z?y-8N z)XdGP0xLuGFbLl1W_MnQo>hlBB!}uN;eBMU&R|*8nk+aGjA}=**YzuyAnWgNXe`^z zsEeDDKB~^T|NO}|-%6YLVSZv05N^~65jGq814uTI=6K7KH2>?D*_`HVvaj{%k7Yf3 z2EdzMdfz(xg6F*5+eVNnb!PtaH`Zdu;N_*i2vH67IizpQDZ3SJ3%uP2zX6%?iw;=j0HE67Vv$;)&)(^Cp;DTSGZjx@W|;Vj53$V^Lf z+8r5oM`2+R{@WJ0j-nzb{xcS7g^v8pbk0mesD1_;wONUJh$Jn5o=JLB-zoq444S=} zq;KRA-evT?*dm+$hY6Z?(f!L3hx@{rr!g9x&C=s)VS2KhHu}*zi+Zxz&*%XPUo^bV z4!6IoC*c>xZJ%&rHtI!vrv|fA+=ll{+!G37@5k#eoB90sx)h62^>ki0x_y&9Xs(yZ zQX_b;ryc^&b=Pxnvg_3O)lizR&tlFV`XC9@jF|l~Tf|%U>|5-cK6+!GkK7}(U`CF< z7Rr0-!|IN*@?LtB8NYyUGe~a?)s>P3ULT4txsue1$nRc^&A5jJdcP+Y-7VC6N>Wn-u`ZO< zh0{@8+4*{s3yh&Sk|pUGf+&AY_kz6}^h`K5T7T*ZOe@BqOr+;);CRfdVGeeW(#xez zHItq&Z-lH>itM;js&A~9;t1klFgBZtvJ9*{;_#faBoKdo6l4U}#R;8)jqUi6 zt3Y|$hPRa7mvN^@BaDP6z}|{9Ho7TS`5@(WVJ^xp=3rsCaSao&KvcC1&rTiQR(1Ge ziID(_$wtd3usujN4sieC`#@NKsCF7W<<@K!s?&_!u(zqP^oh|MHscf)G_~t4tVSAD z=?1U-Y8JE88Af}l4lfbl(FCQCkZf4tRti?wotpeh3U^bD@8O{RU*zsMjBnlKN;|4y z&?mN*lKpLcF6+?%r6)BYjyjFS0(|2v{8s2MCz2bKXb69Gsc$YMCK=^!-3Zv?IKzPZ zp`@Uub+-V~@y304zXi9WvG}zR^3M}V?H2!PVlb(Vo%iGww`FdLsBy0R{N16UB zh7Yl3Uw?d2IeY+?`%#}^dJ#WA+oMMa6fV1GgZAnPgu*@2c)$LbM-PF+Hqz_^gI4Id zPb})Y(v>kv+>65A)1Rv0gzt{seqSHX!?i$TeGVUFCNYr@ySf(5g_Iro23WLMj{=+;+ z#f7N!(+i&5Hk?_ge*$?+_4nM!1kpvy^ff$jBGCr$;jVwJS+!eV!`DQ?$fh`wnM}_FO{j4vQ@Ftuu@jhHjMu_9VVSNespGFRRnuz z80sTI;@kzmhAl{{;kSC{I#k{U{X3n3?G9CC?yLl{clFh#)A;EwXMe@}ay{66gfcnb zwlMy6NA;Vq>6{)2eJ;yh(D6;>G;2-{A{JZ zAN)>J)lst`?2LXLzx5D|Km}o5lbgD#K%dC z|IqumA%wc$`V%)Vgi~;d;#Upomw(YW!`x~V85R;vpyRi?1}|6X)+g4h7xj#NbJ-kU!{E-}T|C|20m-OFfzpAn5k)q1xl7vDxFh=VHGz{VOrm4(@VlX`iy7Flr2 zKl+xMsL2ts-4FFiyi(zd7Tv;b+bLh8E60j!7(zsw-56Ku#sJp@xz$p`SmU0|c@xRG z>q2*O*w)e5X@WK$#yIynp}|g`#vy3c5(RsHvi^#DN^sNRFFnYFSz2tNY7IWXxuzQ3 z-5?@zoY0IaLihr@~NEb(*F{WbPf3U`=4=*wce!=^JAqyjCb3QOKBsOBT z@g@(r0^-&Iyn+?4K)!g-m?yEHJ~S3c?4LEpb;Wc#4Wx1-8ec9M1!m0b{0A&qjAiMf zVMY@+d$ExsVS`8vBa8;cqw$`QSKVyo3Ih*J4nEhA?Ezzyw7uL|EMed8_A5p`)_Q^Q zuKNez4^Ou89b=A!H25?h@rIiP77uX7840ZEB4YqQLSCF}ghAq3&6h16V$7G|gIPu> zdpybj3Er8ArOZ*q;sgDnIBS!Q|8e}dBA9I)W9*g~LVP4iO=u|VZLI3p@cy`C!2gD@ zp9+vXtD0+EkfdY|V`Xz*H!LPv5DF`%YJNOKHevgUjI9z#1C4O#`zc;S_ANF7_^C-S zx4tdjeEnXEB81;w#OtN91aHLT8Eqgn#|hg^WjEfn0+>j3$wXc$~KQTewMII#|5Eq zGu?txnS}z`G}{;}0qzgE_Of`>eNoF1cs?Kof|=(GW3q%Xi&J7H(~N1j$+kuue3pxs zwwQ660CX{Yf#qt!?CV^k53jFKS+{B5_%b(BCep0G4!=8lyPG(_J zUS@7yQej$AUS= 0.9 then '90-100%'\n when scaled_progress >= 0.8 and scaled_progress < 0.9 then '80-89%'\n when scaled_progress >= 0.7 and scaled_progress < 0.8 then '70-79%'\n when scaled_progress >= 0.6 and scaled_progress < 0.7 then '60-69%'\n when scaled_progress >= 0.5 and scaled_progress < 0.6 then '50-59%'\n when scaled_progress >= 0.4 and scaled_progress < 0.5 then '40-49%'\n when scaled_progress >= 0.3 and scaled_progress < 0.4 then '30-39%'\n when scaled_progress >= 0.2 and scaled_progress < 0.3 then '20-29%'\n when scaled_progress >= 0.1 and scaled_progress < 0.2 then '10-19%'\n else '0-9%'\n end as completion_bucket\nfrom\n completions\n join `event_sink`.`course_names` courses\n on completions.course_key = courses.course_key\n left join `event_sink`.`course_block_names` blocks\n on completions.entity_id = blocks.location", "relation_name": "`xapi`.`fact_completions`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.508814Z", "completed_at": "2024-01-12T21:21:42.512875Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.514438Z", "completed_at": "2024-01-12T21:21:42.514447Z"}], "thread_id": "Thread-1", "execution_time": 0.008341550827026367, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_enrollments", "compiled": true, "compiled_code": "with enrollments as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n enrollment_mode,\n splitByString('/', verb_id)[-1] as enrollment_status\n from\n `xapi`.`enrollment_events`\n)\n\nselect\n enrollments.emission_time as emission_time,\n enrollments.org as org,\n enrollments.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n enrollments.actor_id as actor_id,\n enrollments.enrollment_mode as enrollment_mode,\n enrollments.enrollment_status as enrollment_status\nfrom\n enrollments\n join `event_sink`.`course_names` courses\n on enrollments.course_key = courses.course_key", "relation_name": "`xapi`.`fact_enrollments`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.518946Z", "completed_at": "2024-01-12T21:21:42.523000Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.524469Z", "completed_at": "2024-01-12T21:21:42.524477Z"}], "thread_id": "Thread-1", "execution_time": 0.008247852325439453, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_forum_interactions", "compiled": true, "compiled_code": "select\n forum.event_id as event_id,\n forum.emission_time as emission_time,\n forum.org as org,\n forum.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n forum.object_id as object_id,\n forum.actor_id as actor_id,\n forum.verb_id as verb_id\nfrom\n `xapi`.`forum_events` forum\n join `event_sink`.`course_names` courses\n on (forum.course_key = courses.course_key)", "relation_name": "`xapi`.`fact_forum_interactions`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.530109Z", "completed_at": "2024-01-12T21:21:42.534560Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.536042Z", "completed_at": "2024-01-12T21:21:42.536050Z"}], "thread_id": "Thread-1", "execution_time": 0.008646249771118164, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_grades", "compiled": true, "compiled_code": "with grades as (\n select\n emission_time,\n org,\n course_key,\n case\n when object_id like '%/course/%' then 'course'\n when object_id like '%@sequential+block@%' then 'subsection'\n when object_id like '%@problem+block@%' then 'problem'\n end as grade_type,\n if(\n grade_type = 'course',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n actor_id,\n scaled_score\n from\n `xapi`.`grading_events`\n)\n\nselect\n grades.emission_time as emission_time,\n grades.org as org,\n grades.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n grades.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n grades.grade_type as grade_type,\n grades.actor_id as actor_id,\n grades.scaled_score as scaled_score,\n case\n when scaled_score >= 0.9 then '90-100%'\n when scaled_score >= 0.8 and scaled_score < 0.9 then '80-89%'\n when scaled_score >= 0.7 and scaled_score < 0.8 then '70-79%'\n when scaled_score >= 0.6 and scaled_score < 0.7 then '60-69%'\n when scaled_score >= 0.5 and scaled_score < 0.6 then '50-59%'\n when scaled_score >= 0.4 and scaled_score < 0.5 then '40-49%'\n when scaled_score >= 0.3 and scaled_score < 0.4 then '30-39%'\n when scaled_score >= 0.2 and scaled_score < 0.3 then '20-29%'\n when scaled_score >= 0.1 and scaled_score < 0.2 then '10-19%'\n else '0-9%'\n end as grade_bucket\nfrom\n grades\n join `event_sink`.`course_names` courses\n on grades.course_key = courses.course_key\n left join `event_sink`.`course_block_names` blocks\n on grades.entity_id = blocks.location", "relation_name": "`xapi`.`fact_grades`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.540760Z", "completed_at": "2024-01-12T21:21:42.544646Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.546188Z", "completed_at": "2024-01-12T21:21:42.546196Z"}], "thread_id": "Thread-1", "execution_time": 0.00843048095703125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_navigation", "compiled": true, "compiled_code": "select\n navigation.emission_time as emission_time,\n navigation.org as org,\n navigation.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n navigation.actor_id as actor_id,\n navigation.block_id as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as block_name_with_location,\n navigation.object_type as object_type,\n navigation.starting_position as starting_position,\n navigation.ending_point as ending_point\nfrom\n `xapi`.`navigation_events` navigation\n join `xapi`.`dim_course_blocks` blocks\n on (navigation.course_key = blocks.course_key\n and navigation.block_id = blocks.block_id)", "relation_name": "`xapi`.`fact_navigation`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.550525Z", "completed_at": "2024-01-12T21:21:42.555005Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.556504Z", "completed_at": "2024-01-12T21:21:42.556512Z"}], "thread_id": "Thread-1", "execution_time": 0.008646965026855469, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_problem_responses", "compiled": true, "compiled_code": "with responses as (\n select\n emission_time,\n org,\n course_key,\n \n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n as problem_id,\n actor_id,\n responses,\n success,\n attempts\n from\n `xapi`.`problem_events`\n where\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated'\n)\n\nselect\n responses.emission_time as emission_time,\n responses.org as org,\n responses.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n responses.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n responses.actor_id as actor_id,\n responses.responses as responses,\n responses.success as success,\n responses.attempts as attempts\nfrom\n responses\n join `xapi`.`dim_course_blocks` blocks\n on (responses.course_key = blocks.course_key\n and responses.problem_id = blocks.block_id)\ngroup by\n -- multi-part questions include an extra record for the response to the first\n -- part of the question. this group by clause eliminates the duplicate record\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts", "relation_name": "`xapi`.`fact_problem_responses`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.560985Z", "completed_at": "2024-01-12T21:21:42.565325Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.566801Z", "completed_at": "2024-01-12T21:21:42.566809Z"}], "thread_id": "Thread-1", "execution_time": 0.008457183837890625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.int_problem_hints", "compiled": true, "compiled_code": "with hints as (\n select\n emission_time,\n org,\n course_key,\n \n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n as problem_id,\n actor_id,\n case\n when object_id like '%/hint%' then 'hint'\n when object_id like '%/answer%' then 'answer'\n else 'N/A'\n end as help_type\n from\n `xapi`.`problem_events`\n where\n verb_id = 'http://adlnet.gov/expapi/verbs/asked'\n)\n\nselect\n hints.emission_time as emission_time,\n hints.org as org,\n hints.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n hints.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n hints.actor_id as actor_id,\n hints.help_type as help_type\nfrom\n hints\n join `xapi`.`dim_course_blocks` blocks\n on (hints.course_key = blocks.course_key\n and hints.problem_id = blocks.block_id)", "relation_name": "`xapi`.`int_problem_hints`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.571101Z", "completed_at": "2024-01-12T21:21:42.575149Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.576623Z", "completed_at": "2024-01-12T21:21:42.576631Z"}], "thread_id": "Thread-1", "execution_time": 0.008136510848999023, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_video_plays", "compiled": true, "compiled_code": "-- model to support number of watches per video\n-- ref: https://edx.readthedocs.io/projects/edx-insights/en/latest/Reference.html#engagement-computations\nwith plays as (\n select\n emission_time,\n org,\n course_key,\n splitByString('/xblock/', object_id)[-1] as video_id,\n actor_id\n from\n `xapi`.`video_playback_events`\n where\n verb_id = 'https://w3id.org/xapi/video/verbs/played'\n)\n\nselect\n plays.emission_time as emission_time,\n plays.org as org,\n plays.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n plays.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n plays.actor_id as actor_id\nfrom\n plays\n join `xapi`.`dim_course_blocks` blocks\n on (plays.course_key = blocks.course_key\n and plays.video_id = blocks.block_id)", "relation_name": "`xapi`.`fact_video_plays`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.581045Z", "completed_at": "2024-01-12T21:21:42.585069Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.586534Z", "completed_at": "2024-01-12T21:21:42.586542Z"}], "thread_id": "Thread-1", "execution_time": 0.008219242095947266, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_transcript_usage", "compiled": true, "compiled_code": "select\n transcripts.emission_time as emission_time,\n transcripts.org as org,\n transcripts.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n transcripts.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n transcripts.actor_id as actor_id\nfrom\n `xapi`.`video_transcript_events` transcripts\n join `xapi`.`dim_course_blocks` blocks\n on (transcripts.course_key = blocks.course_key\n and transcripts.video_id = blocks.block_id)\nwhere\n transcripts.cc_enabled", "relation_name": "`xapi`.`fact_transcript_usage`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.590910Z", "completed_at": "2024-01-12T21:21:42.597419Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.598935Z", "completed_at": "2024-01-12T21:21:42.598944Z"}], "thread_id": "Thread-1", "execution_time": 0.010710477828979492, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n enrollment_status as value_field,\n count(*) as n_records\n\n from `xapi`.`fact_enrollments`\n group by enrollment_status\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'registered','unregistered'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.603352Z", "completed_at": "2024-01-12T21:21:42.608694Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.610230Z", "completed_at": "2024-01-12T21:21:42.610238Z"}], "thread_id": "Thread-1", "execution_time": 0.009526491165161133, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n grade_type as value_field,\n count(*) as n_records\n\n from `xapi`.`fact_grades`\n group by grade_type\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'course','subsection','problem'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.614614Z", "completed_at": "2024-01-12T21:21:42.619025Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.620523Z", "completed_at": "2024-01-12T21:21:42.620530Z"}], "thread_id": "Thread-1", "execution_time": 0.008729219436645508, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.int_problem_results", "compiled": true, "compiled_code": "-- select one record per (learner, problem, course, org) tuple\n-- contains either the first successful attempt\n-- or the most recent unsuccessful attempt\n\n\n-- find the timestamp of the earliest successful response\n-- this will be used to pick the xAPI event corresponding to that submission\nwith successful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n min(emission_time) as first_success_at\n from\n `xapi`.`fact_problem_responses`\n where\n -- clickhouse throws an error when shortening this to `where success`\n success = true\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- for all learners who did not submit a successful response,\n-- find the timestamp of the most recent unsuccessful response\nunsuccessful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n max(emission_time) as last_response_at\n from\n `xapi`.`fact_problem_responses`\n where\n actor_id not in (select distinct actor_id from successful_responses)\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- combine result sets for successful and unsuccessful problem submissions\nresponses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n first_success_at as emission_time\n from\n successful_responses\n union all\n select\n org,\n course_key,\n problem_id,\n actor_id,\n last_response_at as emission_time\n from\n unsuccessful_responses\n)\n\nselect\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts\nfrom\n `xapi`.`fact_problem_responses` problem_responses\n join responses\n using (org, course_key, problem_id, actor_id, emission_time)", "relation_name": "`xapi`.`int_problem_results`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.625435Z", "completed_at": "2024-01-12T21:21:42.629678Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.631152Z", "completed_at": "2024-01-12T21:21:42.631161Z"}], "thread_id": "Thread-1", "execution_time": 0.008394002914428711, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_learner_problem_summary", "compiled": true, "compiled_code": "-- summary table for a learner's performance on and interactions with a\n-- particular problem\nwith results_with_hints as (\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n success,\n attempts,\n 0 as num_hints_displayed,\n 0 as num_answers_displayed\n from `xapi`.`int_problem_results`\n union all\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n null as success,\n null as attempts,\n case help_type\n when 'hint' then 1\n else 0\n end as num_hints_displayed,\n case help_type\n when 'answer' then 1\n else 0\n end as num_answers_displayed\n from `xapi`.`int_problem_hints`\n)\n\n-- n.b.: there should only be one row per org, course, problem, and actor\n-- in problem_results, so any(success) and any(attempts) should return the\n-- values from that part of the union and not the null values used as\n-- placeholders in the problem_hints part of the union\nselect\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n coalesce(any(success), false) as success,\n coalesce(any(attempts), 0) as attempts,\n sum(num_hints_displayed) as num_hints_displayed,\n sum(num_answers_displayed) as num_answers_displayed\nfrom\n results_with_hints\ngroup by\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id", "relation_name": "`xapi`.`fact_learner_problem_summary`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.635682Z", "completed_at": "2024-01-12T21:21:42.639627Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.641148Z", "completed_at": "2024-01-12T21:21:42.641156Z"}], "thread_id": "Thread-1", "execution_time": 0.008233070373535156, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.problem_results_uniqueness", "compiled": true, "compiled_code": "-- problem_results should only have one record for the following\n-- combination of values:\n-- actor_id, problem_id, course_id, org\n\nselect\n org,\n course_key,\n problem_id,\n actor_id,\n responses,\n count(*) as num_rows\nfrom\n `xapi`.`int_problem_results`\ngroup by\n org,\n course_key,\n problem_id,\n actor_id,\n responses\nhaving num_rows > 1", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.645571Z", "completed_at": "2024-01-12T21:21:42.649205Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.650688Z", "completed_at": "2024-01-12T21:21:42.650697Z"}], "thread_id": "Thread-1", "execution_time": 0.007828474044799805, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.learner_problem_summary_uniqueness", "compiled": true, "compiled_code": "select\n org,\n course_key,\n problem_id,\n actor_id,\n count(*) as num_rows\nfrom\n `xapi`.`fact_learner_problem_summary`\ngroup by\n org,\n course_key,\n problem_id,\n actor_id\nhaving num_rows > 1", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.655228Z", "completed_at": "2024-01-12T21:21:42.666337Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.667868Z", "completed_at": "2024-01-12T21:21:42.667877Z"}], "thread_id": "Thread-1", "execution_time": 0.01549839973449707, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect attempts\nfrom `xapi`.`fact_learner_problem_summary`\nwhere attempts is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-12T21:21:42.672287Z", "completed_at": "2024-01-12T21:21:42.677517Z"}, {"name": "execute", "started_at": "2024-01-12T21:21:42.679025Z", "completed_at": "2024-01-12T21:21:42.679034Z"}], "thread_id": "Thread-1", "execution_time": 0.009421825408935547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect success\nfrom `xapi`.`fact_learner_problem_summary`\nwhere success is null\n\n\n", "relation_name": null}], "elapsed_time": 0.4605426788330078, "args": {"print": true, "cache_selected_only": false, "indirect_selection": "eager", "log_path": "/home/runner/work/aspects-dbt/aspects-dbt/logs", "invocation_command": "dbt docs generate", "use_colors_file": true, "use_colors": true, "partial_parse": true, "version_check": true, "vars": {}, "static": false, "strict_mode": false, "populate_cache": true, "write_json": true, "compile": true, "log_level_file": "debug", "log_format_file": "debug", "warn_error_options": {"include": [], "exclude": []}, "macro_debugging": false, "exclude": [], "project_dir": "/home/runner/work/aspects-dbt/aspects-dbt", "defer": false, "send_anonymous_usage_stats": true, "empty_catalog": false, "printer_width": 80, "partial_parse_file_diff": true, "select": [], "log_level": "info", "quiet": false, "show_resource_report": false, "log_format": "default", "log_file_max_bytes": 10485760, "static_parser": true, "which": "generate", "enable_legacy_logger": false, "favor_state": false, "profiles_dir": "./.github/", "introspect": true}} \ No newline at end of file +{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/run-results/v5.json", "dbt_version": "1.7.0", "generated_at": "2024-01-29T17:33:05.504916Z", "invocation_id": "23109c69-1db3-40c3-b53f-036608b155d3", "env": {}}, "results": [{"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.212998Z", "completed_at": "2024-01-29T17:33:05.222616Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.224123Z", "completed_at": "2024-01-29T17:33:05.224134Z"}], "thread_id": "Thread-1", "execution_time": 0.013916015625, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.dim_course_blocks", "compiled": true, "compiled_code": "select\n courses.org as org,\n courses.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n blocks.location as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as display_name_with_location\nfrom\n `event_sink`.`course_block_names` blocks\n join `event_sink`.`course_names` courses\n on blocks.course_key = courses.course_key\nsettings join_algorithm='direct'", "relation_name": "`xapi`.`dim_course_blocks`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.228659Z", "completed_at": "2024-01-29T17:33:05.233364Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.234855Z", "completed_at": "2024-01-29T17:33:05.234862Z"}], "thread_id": "Thread-1", "execution_time": 0.008793115615844727, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.xapi_events_all_parsed", "compiled": true, "compiled_code": "\n\nSELECT\n event_id as event_id,\n JSON_VALUE(event::String, '$.verb.id') as verb_id,\n COALESCE(\n NULLIF(JSON_VALUE(event::String, '$.actor.account.name'), ''),\n NULLIF(JSON_VALUE(event::String, '$.actor.mbox'), ''),\n JSON_VALUE(event::String, '$.actor.mbox_sha1sum')\n ) as actor_id,\n JSON_VALUE(event::String, '$.object.id') as object_id,\n -- If the contextActivities parent is a course, use that. It can be a \"course\"\n -- type, or a \"cmi.interaction\" type for multiple question problem submissions.\n -- Otherwise use the object id for the course id.\n multiIf(\n -- If the contextActivities parent is a course, use that\n JSON_VALUE(\n event::String,\n '$.context.contextActivities.parent[0].definition.type'\n ) = 'http://adlnet.gov/expapi/activities/course',\n JSON_VALUE(event::String, '$.context.contextActivities.parent[0].id'),\n -- Else if the contextActivities parent is a GroupActivity, it's a multi\n -- question problem and we use the grouping id\n JSON_VALUE(\n event::String,\n '$.context.contextActivities.parent[0].objectType'\n ) in ('Activity', 'GroupActivity'),\n JSON_VALUE(event::String, '$.context.contextActivities.grouping[0].id'),\n -- Otherwise use the object id\n JSON_VALUE(event::String, '$.object.id')\n ) as course_id,\n coalesce(get_org_from_course_url(course_id), '') as org,\n emission_time as emission_time,\n event::String as event\nFROM `xapi`.`xapi_events_all`", "relation_name": "`xapi`.`xapi_events_all_parsed`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.239755Z", "completed_at": "2024-01-29T17:33:05.244300Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.245823Z", "completed_at": "2024-01-29T17:33:05.245830Z"}], "thread_id": "Thread-1", "execution_time": 0.008730173110961914, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.completion_events", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/cmi5/result/extensions/progress\"') AS progress_percent\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id = 'http://adlnet.gov/expapi/verbs/progressed'", "relation_name": "`xapi`.`completion_events`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.250269Z", "completed_at": "2024-01-29T17:33:05.254855Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.256389Z", "completed_at": "2024-01-29T17:33:05.256395Z"}], "thread_id": "Thread-1", "execution_time": 0.008931875228881836, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.enrollment_events", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.object.definition.extensions.\"https://w3id.org/xapi/acrossx/extensions/type\"') AS enrollment_mode\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN (\n 'http://adlnet.gov/expapi/verbs/registered',\n 'http://id.tincanapi.com/verb/unregistered'\n)", "relation_name": "`xapi`.`enrollment_events`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.261683Z", "completed_at": "2024-01-29T17:33:05.266222Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.267709Z", "completed_at": "2024-01-29T17:33:05.267716Z"}], "thread_id": "Thread-1", "execution_time": 0.009392023086547852, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.forum_events", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n object_id,\n actor_id,\n verb_id\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE JSON_VALUE(event, '$.object.definition.type') = 'http://id.tincanapi.com/activitytype/discussion'", "relation_name": "`xapi`.`forum_events`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.272193Z", "completed_at": "2024-01-29T17:33:05.277480Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.278970Z", "completed_at": "2024-01-29T17:33:05.278976Z"}], "thread_id": "Thread-1", "execution_time": 0.009511232376098633, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.grading_events", "compiled": true, "compiled_code": "\n\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractFloat(event, 'result', 'score', 'scaled') AS scaled_score\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN ('http://id.tincanapi.com/verb/earned', 'https://w3id.org/xapi/acrossx/verbs/evaluated')", "relation_name": "`xapi`.`grading_events`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.283325Z", "completed_at": "2024-01-29T17:33:05.288103Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.289645Z", "completed_at": "2024-01-29T17:33:05.289652Z"}], "thread_id": "Thread-1", "execution_time": 0.008993148803710938, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.navigation_events", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n splitByString('/xblock/', object_id)[-1] as block_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSONExtractString(event, 'object', 'definition', 'type') AS object_type,\n -- clicking a link and selecting a module outline have no starting-position field\n if (\n object_type in (\n 'http://adlnet.gov/expapi/activities/link',\n 'http://adlnet.gov/expapi/activities/module'\n ),\n 0,\n JSONExtractInt(\n event,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/starting-position'\n )\n ) AS starting_position,\n JSONExtractString(\n event,\n 'context', 'extensions', 'http://id.tincanapi.com/extension/ending-point'\n ) AS ending_point\nFROM\n `xapi`.`xapi_events_all_parsed`\nWHERE verb_id IN (\n 'https://w3id.org/xapi/dod-isd/verbs/navigated'\n)", "relation_name": "`xapi`.`navigation_events`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.294086Z", "completed_at": "2024-01-29T17:33:05.298635Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.300130Z", "completed_at": "2024-01-29T17:33:05.300137Z"}], "thread_id": "Thread-1", "execution_time": 0.008758783340454102, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.problem_events", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n cast(emission_time as DateTime) as emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n JSON_VALUE(event, '$.result.response') as responses,\n JSON_VALUE(event, '$.result.score.scaled') as scaled_score,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event, '$.result.success') as Bool),\n false\n ) as success,\n JSON_VALUE(event, '$.object.definition.interactionType') as interaction_type,\n if(\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n cast(JSON_VALUE(event, '$.object.definition.extensions.\"http://id.tincanapi.com/extension/attempt-id\"') as Int16),\n 0\n ) as attempts\nFROM\n `xapi`.`xapi_events_all_parsed`\nWHERE\n verb_id in (\n 'https://w3id.org/xapi/acrossx/verbs/evaluated',\n 'http://adlnet.gov/expapi/verbs/passed',\n 'http://adlnet.gov/expapi/verbs/asked'\n )", "relation_name": "`xapi`.`problem_events`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.304468Z", "completed_at": "2024-01-29T17:33:05.309086Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.310605Z", "completed_at": "2024-01-29T17:33:05.310612Z"}], "thread_id": "Thread-1", "execution_time": 0.008808135986328125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.video_playback_events", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n actor_id,\n object_id,\n splitByString('/', course_id)[-1] AS course_key,\n org,\n verb_id,\n ceil(CAST(coalesce(nullIf(JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time\"'), ''), nullIf(JSON_VALUE(event, '$.result.extensions.\"https://w3id.org/xapi/video/extensions/time-from\"'), ''), '0.0'), 'Decimal32(2)')) AS video_position\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE (verb_id IN ('http://adlnet.gov/expapi/verbs/completed', 'http://adlnet.gov/expapi/verbs/initialized', 'http://adlnet.gov/expapi/verbs/terminated', 'https://w3id.org/xapi/video/verbs/paused', 'https://w3id.org/xapi/video/verbs/played', 'https://w3id.org/xapi/video/verbs/seeked')) AND (object_id LIKE '%video+block%')", "relation_name": "`xapi`.`video_playback_events`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.314991Z", "completed_at": "2024-01-29T17:33:05.319450Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.320929Z", "completed_at": "2024-01-29T17:33:05.320936Z"}], "thread_id": "Thread-1", "execution_time": 0.008656501770019531, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.video_transcript_events", "compiled": true, "compiled_code": "\n\nSELECT\n event_id,\n CAST(emission_time, 'DateTime') AS emission_time,\n org,\n splitByString('/', course_id)[-1] AS course_key,\n splitByString('/xblock/', object_id)[2] as video_id,\n actor_id,\n JSONExtractBool(event, 'result','extensions','https://w3id.org/xapi/video/extensions/cc-enabled') as cc_enabled\nFROM `xapi`.`xapi_events_all_parsed`\nWHERE\n verb_id IN ('http://adlnet.gov/expapi/verbs/interacted')\n AND JSONHas(event, 'result', 'extensions', 'https://w3id.org/xapi/video/extensions/cc-enabled')", "relation_name": "`xapi`.`video_transcript_events`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.325377Z", "completed_at": "2024-01-29T17:33:05.329865Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.331361Z", "completed_at": "2024-01-29T17:33:05.331368Z"}], "thread_id": "Thread-1", "execution_time": 0.008726358413696289, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_completions", "compiled": true, "compiled_code": "with completions as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n progress_percent,\n if(\n object_id like '%/course/%',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n cast(progress_percent as Float)/100 as scaled_progress\n from\n `xapi`.`completion_events`\n)\n\nselect\n completions.emission_time as emission_time,\n completions.org as org,\n completions.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n completions.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n completions.actor_id as actor_id,\n cast(completions.scaled_progress as Float) as scaled_progress,\n case\n when scaled_progress >= 0.9 then '90-100%'\n when scaled_progress >= 0.8 and scaled_progress < 0.9 then '80-89%'\n when scaled_progress >= 0.7 and scaled_progress < 0.8 then '70-79%'\n when scaled_progress >= 0.6 and scaled_progress < 0.7 then '60-69%'\n when scaled_progress >= 0.5 and scaled_progress < 0.6 then '50-59%'\n when scaled_progress >= 0.4 and scaled_progress < 0.5 then '40-49%'\n when scaled_progress >= 0.3 and scaled_progress < 0.4 then '30-39%'\n when scaled_progress >= 0.2 and scaled_progress < 0.3 then '20-29%'\n when scaled_progress >= 0.1 and scaled_progress < 0.2 then '10-19%'\n else '0-9%'\n end as completion_bucket\nfrom\n completions\n join `event_sink`.`course_names` courses\n on completions.course_key = courses.course_key\n left join `event_sink`.`course_block_names` blocks\n on completions.entity_id = blocks.location", "relation_name": "`xapi`.`fact_completions`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.335731Z", "completed_at": "2024-01-29T17:33:05.340403Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.341925Z", "completed_at": "2024-01-29T17:33:05.341931Z"}], "thread_id": "Thread-1", "execution_time": 0.0088348388671875, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_enrollments", "compiled": true, "compiled_code": "with enrollments as (\n select\n emission_time,\n org,\n course_key,\n actor_id,\n enrollment_mode,\n splitByString('/', verb_id)[-1] as enrollment_status\n from\n `xapi`.`enrollment_events`\n)\n\nselect\n enrollments.emission_time as emission_time,\n enrollments.org as org,\n enrollments.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n enrollments.actor_id as actor_id,\n enrollments.enrollment_mode as enrollment_mode,\n enrollments.enrollment_status as enrollment_status\nfrom\n enrollments\n join `event_sink`.`course_names` courses\n on enrollments.course_key = courses.course_key", "relation_name": "`xapi`.`fact_enrollments`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.346484Z", "completed_at": "2024-01-29T17:33:05.350287Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.351778Z", "completed_at": "2024-01-29T17:33:05.351785Z"}], "thread_id": "Thread-1", "execution_time": 0.008170604705810547, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_forum_interactions", "compiled": true, "compiled_code": "select\n forum.event_id as event_id,\n forum.emission_time as emission_time,\n forum.org as org,\n forum.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n forum.object_id as object_id,\n forum.actor_id as actor_id,\n forum.verb_id as verb_id\nfrom\n `xapi`.`forum_events` forum\n join `event_sink`.`course_names` courses\n on (forum.course_key = courses.course_key)", "relation_name": "`xapi`.`fact_forum_interactions`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.356060Z", "completed_at": "2024-01-29T17:33:05.360383Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.361910Z", "completed_at": "2024-01-29T17:33:05.361917Z"}], "thread_id": "Thread-1", "execution_time": 0.008464574813842773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_grades", "compiled": true, "compiled_code": "with grades as (\n select\n emission_time,\n org,\n course_key,\n case\n when object_id like '%/course/%' then 'course'\n when object_id like '%@sequential+block@%' then 'subsection'\n when object_id like '%@problem+block@%' then 'problem'\n end as grade_type,\n if(\n grade_type = 'course',\n splitByString('/course/', object_id)[-1],\n splitByString('/xblock/', object_id)[-1]\n ) as entity_id,\n actor_id,\n scaled_score\n from\n `xapi`.`grading_events`\n)\n\nselect\n grades.emission_time as emission_time,\n grades.org as org,\n grades.course_key as course_key,\n courses.course_name as course_name,\n courses.course_run as course_run,\n grades.entity_id as entity_id,\n if(blocks.block_name != '', blocks.block_name, courses.course_name) as entity_name,\n if(blocks.block_name != '', blocks.display_name_with_location, null) as entity_name_with_location,\n grades.grade_type as grade_type,\n grades.actor_id as actor_id,\n grades.scaled_score as scaled_score,\n case\n when scaled_score >= 0.9 then '90-100%'\n when scaled_score >= 0.8 and scaled_score < 0.9 then '80-89%'\n when scaled_score >= 0.7 and scaled_score < 0.8 then '70-79%'\n when scaled_score >= 0.6 and scaled_score < 0.7 then '60-69%'\n when scaled_score >= 0.5 and scaled_score < 0.6 then '50-59%'\n when scaled_score >= 0.4 and scaled_score < 0.5 then '40-49%'\n when scaled_score >= 0.3 and scaled_score < 0.4 then '30-39%'\n when scaled_score >= 0.2 and scaled_score < 0.3 then '20-29%'\n when scaled_score >= 0.1 and scaled_score < 0.2 then '10-19%'\n else '0-9%'\n end as grade_bucket\nfrom\n grades\n join `event_sink`.`course_names` courses\n on grades.course_key = courses.course_key\n left join `event_sink`.`course_block_names` blocks\n on grades.entity_id = blocks.location", "relation_name": "`xapi`.`fact_grades`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.366380Z", "completed_at": "2024-01-29T17:33:05.370177Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.371675Z", "completed_at": "2024-01-29T17:33:05.371682Z"}], "thread_id": "Thread-1", "execution_time": 0.008043527603149414, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_navigation", "compiled": true, "compiled_code": "select\n navigation.emission_time as emission_time,\n navigation.org as org,\n navigation.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n navigation.actor_id as actor_id,\n navigation.block_id as block_id,\n blocks.block_name as block_name,\n blocks.display_name_with_location as block_name_with_location,\n navigation.object_type as object_type,\n navigation.starting_position as starting_position,\n navigation.ending_point as ending_point\nfrom\n `xapi`.`navigation_events` navigation\n join `xapi`.`dim_course_blocks` blocks\n on (navigation.course_key = blocks.course_key\n and navigation.block_id = blocks.block_id)", "relation_name": "`xapi`.`fact_navigation`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.375999Z", "completed_at": "2024-01-29T17:33:05.380227Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.381745Z", "completed_at": "2024-01-29T17:33:05.381752Z"}], "thread_id": "Thread-1", "execution_time": 0.008380413055419922, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_problem_responses", "compiled": true, "compiled_code": "with responses as (\n select\n emission_time,\n org,\n course_key,\n \n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n as problem_id,\n actor_id,\n responses,\n success,\n attempts\n from\n `xapi`.`problem_events`\n where\n verb_id = 'https://w3id.org/xapi/acrossx/verbs/evaluated'\n)\n\nselect\n responses.emission_time as emission_time,\n responses.org as org,\n responses.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n responses.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n responses.actor_id as actor_id,\n responses.responses as responses,\n responses.success as success,\n responses.attempts as attempts\nfrom\n responses\n join `xapi`.`dim_course_blocks` blocks\n on (responses.course_key = blocks.course_key\n and responses.problem_id = blocks.block_id)\ngroup by\n -- multi-part questions include an extra record for the response to the first\n -- part of the question. this group by clause eliminates the duplicate record\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts", "relation_name": "`xapi`.`fact_problem_responses`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.386247Z", "completed_at": "2024-01-29T17:33:05.390368Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.391867Z", "completed_at": "2024-01-29T17:33:05.391873Z"}], "thread_id": "Thread-1", "execution_time": 0.008414983749389648, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.int_problem_hints", "compiled": true, "compiled_code": "with hints as (\n select\n emission_time,\n org,\n course_key,\n \n regexpExtract(object_id, 'xblock/([\\w\\d-\\+:]*@problem\\+block@[\\w\\d][^_]*)(_\\d_\\d)?', 1)\n as problem_id,\n actor_id,\n case\n when object_id like '%/hint%' then 'hint'\n when object_id like '%/answer%' then 'answer'\n else 'N/A'\n end as help_type\n from\n `xapi`.`problem_events`\n where\n verb_id = 'http://adlnet.gov/expapi/verbs/asked'\n)\n\nselect\n hints.emission_time as emission_time,\n hints.org as org,\n hints.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n hints.problem_id as problem_id,\n blocks.block_name as problem_name,\n blocks.display_name_with_location as problem_name_with_location,\n hints.actor_id as actor_id,\n hints.help_type as help_type\nfrom\n hints\n join `xapi`.`dim_course_blocks` blocks\n on (hints.course_key = blocks.course_key\n and hints.problem_id = blocks.block_id)", "relation_name": "`xapi`.`int_problem_hints`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.396201Z", "completed_at": "2024-01-29T17:33:05.401020Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.402515Z", "completed_at": "2024-01-29T17:33:05.402522Z"}], "thread_id": "Thread-1", "execution_time": 0.008926153182983398, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_video_plays", "compiled": true, "compiled_code": "-- model to support number of watches per video\n-- ref: https://edx.readthedocs.io/projects/edx-insights/en/latest/Reference.html#engagement-computations\nwith plays as (\n select\n emission_time,\n org,\n course_key,\n splitByString('/xblock/', object_id)[-1] as video_id,\n actor_id\n from\n `xapi`.`video_playback_events`\n where\n verb_id = 'https://w3id.org/xapi/video/verbs/played'\n)\n\nselect\n plays.emission_time as emission_time,\n plays.org as org,\n plays.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n plays.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n plays.actor_id as actor_id\nfrom\n plays\n join `xapi`.`dim_course_blocks` blocks\n on (plays.course_key = blocks.course_key\n and plays.video_id = blocks.block_id)", "relation_name": "`xapi`.`fact_video_plays`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.406797Z", "completed_at": "2024-01-29T17:33:05.410634Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.412136Z", "completed_at": "2024-01-29T17:33:05.412142Z"}], "thread_id": "Thread-1", "execution_time": 0.008002996444702148, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_transcript_usage", "compiled": true, "compiled_code": "select\n transcripts.emission_time as emission_time,\n transcripts.org as org,\n transcripts.course_key as course_key,\n blocks.course_name as course_name,\n blocks.course_run as course_run,\n transcripts.video_id as video_id,\n blocks.block_name as video_name,\n blocks.display_name_with_location as video_name_with_location,\n transcripts.actor_id as actor_id\nfrom\n `xapi`.`video_transcript_events` transcripts\n join `xapi`.`dim_course_blocks` blocks\n on (transcripts.course_key = blocks.course_key\n and transcripts.video_id = blocks.block_id)\nwhere\n transcripts.cc_enabled", "relation_name": "`xapi`.`fact_transcript_usage`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.416557Z", "completed_at": "2024-01-29T17:33:05.421601Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.423103Z", "completed_at": "2024-01-29T17:33:05.423110Z"}], "thread_id": "Thread-1", "execution_time": 0.009166479110717773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.accepted_values_fact_enrollments_enrollment_status__registered__unregistered.f8d10203f4", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n enrollment_status as value_field,\n count(*) as n_records\n\n from `xapi`.`fact_enrollments`\n group by enrollment_status\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'registered','unregistered'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.427456Z", "completed_at": "2024-01-29T17:33:05.432586Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.434156Z", "completed_at": "2024-01-29T17:33:05.434162Z"}], "thread_id": "Thread-1", "execution_time": 0.009319067001342773, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.accepted_values_fact_grades_grade_type__course__subsection__problem.712bd50c2f", "compiled": true, "compiled_code": "\n \n \n\nwith all_values as (\n\n select\n grade_type as value_field,\n count(*) as n_records\n\n from `xapi`.`fact_grades`\n group by grade_type\n\n)\n\nselect *\nfrom all_values\nwhere value_field not in (\n 'course','subsection','problem'\n)\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.438509Z", "completed_at": "2024-01-29T17:33:05.442642Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.444128Z", "completed_at": "2024-01-29T17:33:05.444134Z"}], "thread_id": "Thread-1", "execution_time": 0.008344173431396484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.int_problem_results", "compiled": true, "compiled_code": "-- select one record per (learner, problem, course, org) tuple\n-- contains either the first successful attempt\n-- or the most recent unsuccessful attempt\n\n\n-- find the timestamp of the earliest successful response\n-- this will be used to pick the xAPI event corresponding to that submission\nwith successful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n min(emission_time) as first_success_at\n from\n `xapi`.`fact_problem_responses`\n where\n -- clickhouse throws an error when shortening this to `where success`\n success = true\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- for all learners who did not submit a successful response,\n-- find the timestamp of the most recent unsuccessful response\nunsuccessful_responses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n max(emission_time) as last_response_at\n from\n `xapi`.`fact_problem_responses`\n where\n actor_id not in (select distinct actor_id from successful_responses)\n group by\n org,\n course_key,\n problem_id,\n actor_id\n),\n-- combine result sets for successful and unsuccessful problem submissions\nresponses as (\n select\n org,\n course_key,\n problem_id,\n actor_id,\n first_success_at as emission_time\n from\n successful_responses\n union all\n select\n org,\n course_key,\n problem_id,\n actor_id,\n last_response_at as emission_time\n from\n unsuccessful_responses\n)\n\nselect\n emission_time,\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n responses,\n success,\n attempts\nfrom\n `xapi`.`fact_problem_responses` problem_responses\n join responses\n using (org, course_key, problem_id, actor_id, emission_time)", "relation_name": "`xapi`.`int_problem_results`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.448791Z", "completed_at": "2024-01-29T17:33:05.452731Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.454244Z", "completed_at": "2024-01-29T17:33:05.454250Z"}], "thread_id": "Thread-1", "execution_time": 0.008047819137573242, "adapter_response": {}, "message": null, "failures": null, "unique_id": "model.aspects.fact_learner_problem_summary", "compiled": true, "compiled_code": "-- summary table for a learner's performance on and interactions with a\n-- particular problem\nwith results_with_hints as (\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n success,\n attempts,\n 0 as num_hints_displayed,\n 0 as num_answers_displayed\n from `xapi`.`int_problem_results`\n union all\n select\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n null as success,\n null as attempts,\n case help_type\n when 'hint' then 1\n else 0\n end as num_hints_displayed,\n case help_type\n when 'answer' then 1\n else 0\n end as num_answers_displayed\n from `xapi`.`int_problem_hints`\n)\n\n-- n.b.: there should only be one row per org, course, problem, and actor\n-- in problem_results, so any(success) and any(attempts) should return the\n-- values from that part of the union and not the null values used as\n-- placeholders in the problem_hints part of the union\nselect\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id,\n coalesce(any(success), false) as success,\n coalesce(any(attempts), 0) as attempts,\n sum(num_hints_displayed) as num_hints_displayed,\n sum(num_answers_displayed) as num_answers_displayed\nfrom\n results_with_hints\ngroup by\n org,\n course_key,\n course_name,\n course_run,\n problem_id,\n problem_name,\n problem_name_with_location,\n actor_id", "relation_name": "`xapi`.`fact_learner_problem_summary`"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.458687Z", "completed_at": "2024-01-29T17:33:05.462366Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.463869Z", "completed_at": "2024-01-29T17:33:05.463875Z"}], "thread_id": "Thread-1", "execution_time": 0.00909113883972168, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.problem_results_uniqueness", "compiled": true, "compiled_code": "-- problem_results should only have one record for the following\n-- combination of values:\n-- actor_id, problem_id, course_id, org\n\nselect\n org,\n course_key,\n problem_id,\n actor_id,\n responses,\n count(*) as num_rows\nfrom\n `xapi`.`int_problem_results`\ngroup by\n org,\n course_key,\n problem_id,\n actor_id,\n responses\nhaving num_rows > 1", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.469303Z", "completed_at": "2024-01-29T17:33:05.472596Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.474088Z", "completed_at": "2024-01-29T17:33:05.474094Z"}], "thread_id": "Thread-1", "execution_time": 0.007398128509521484, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.learner_problem_summary_uniqueness", "compiled": true, "compiled_code": "select\n org,\n course_key,\n problem_id,\n actor_id,\n count(*) as num_rows\nfrom\n `xapi`.`fact_learner_problem_summary`\ngroup by\n org,\n course_key,\n problem_id,\n actor_id\nhaving num_rows > 1", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.478468Z", "completed_at": "2024-01-29T17:33:05.488051Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.489601Z", "completed_at": "2024-01-29T17:33:05.489607Z"}], "thread_id": "Thread-1", "execution_time": 0.013904571533203125, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.not_null_fact_learner_problem_summary_attempts.817beed32b", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect attempts\nfrom `xapi`.`fact_learner_problem_summary`\nwhere attempts is null\n\n\n", "relation_name": null}, {"status": "success", "timing": [{"name": "compile", "started_at": "2024-01-29T17:33:05.493994Z", "completed_at": "2024-01-29T17:33:05.498739Z"}, {"name": "execute", "started_at": "2024-01-29T17:33:05.500218Z", "completed_at": "2024-01-29T17:33:05.500224Z"}], "thread_id": "Thread-1", "execution_time": 0.008895158767700195, "adapter_response": {}, "message": null, "failures": null, "unique_id": "test.aspects.not_null_fact_learner_problem_summary_success.76b52cb2da", "compiled": true, "compiled_code": "\n \n \n\n\n\nselect success\nfrom `xapi`.`fact_learner_problem_summary`\nwhere success is null\n\n\n", "relation_name": null}], "elapsed_time": 0.44260549545288086, "args": {"print": true, "profiles_dir": "./.github/", "introspect": true, "quiet": false, "partial_parse_file_diff": true, "which": "generate", "log_level": "info", "favor_state": false, "enable_legacy_logger": false, "log_path": "/home/runner/work/aspects-dbt/aspects-dbt/logs", "defer": false, "printer_width": 80, "show_resource_report": false, "static": false, "select": [], "version_check": true, "partial_parse": true, "use_colors": true, "static_parser": true, "exclude": [], "macro_debugging": false, "vars": {}, "compile": true, "invocation_command": "dbt docs generate", "indirect_selection": "eager", "cache_selected_only": false, "project_dir": "/home/runner/work/aspects-dbt/aspects-dbt", "warn_error_options": {"include": [], "exclude": []}, "log_format": "default", "log_level_file": "debug", "log_file_max_bytes": 10485760, "send_anonymous_usage_stats": true, "strict_mode": false, "empty_catalog": false, "use_colors_file": true, "log_format_file": "debug", "write_json": true, "populate_cache": true}} \ No newline at end of file