diff options
Diffstat (limited to 'docs/sqlglot/lineage.html')
-rw-r--r-- | docs/sqlglot/lineage.html | 716 |
1 files changed, 357 insertions, 359 deletions
diff --git a/docs/sqlglot/lineage.html b/docs/sqlglot/lineage.html index 2479325..b50ec52 100644 --- a/docs/sqlglot/lineage.html +++ b/docs/sqlglot/lineage.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> - <meta name="generator" content="pdoc 14.2.0"/> + <meta name="generator" content="pdoc 14.3.0"/> <title>sqlglot.lineage API documentation</title> <style>/*! * Bootstrap Reboot v5.0.0 (https://getbootstrap.com/) * Copyright 2011-2021 The Bootstrap Authors * Copyright 2011-2021 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) */*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;background-color:#fff;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){h1{font-size:2.5rem}}h2{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){h2{font-size:2rem}}h3{font-size:calc(1.3rem + .6vw)}@media (min-width:1200px){h3{font-size:1.75rem}}h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){h4{font-size:1.5rem}}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-bs-original-title],abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:.875em}mark{padding:.2em;background-color:#fcf8e3}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#0d6efd;text-decoration:underline}a:hover{color:#0a58ca}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em;direction:ltr;unicode-bidi:bidi-override}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:#d63384;word-wrap:break-word}a>code{color:inherit}kbd{padding:.2rem .4rem;font-size:.875em;color:#fff;background-color:#212529;border-radius:.2rem}kbd kbd{padding:0;font-size:1em;font-weight:700}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#6c757d;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]::-webkit-calendar-picker-indicator{display:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::file-selector-button{font:inherit}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}</style> @@ -238,177 +238,176 @@ </span><span id="L-129"><a href="#L-129"><span class="linenos">129</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> </span><span id="L-130"><a href="#L-130"><span class="linenos">130</span></a> <span class="k">else</span> <span class="nb">next</span><span class="p">(</span> </span><span id="L-131"><a href="#L-131"><span class="linenos">131</span></a> <span class="p">(</span><span class="n">select</span> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">selects</span> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">column</span><span class="p">),</span> -</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">()</span> <span class="k">if</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-132"><a href="#L-132"><span class="linenos">132</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">()</span> <span class="k">if</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> <span class="k">else</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> </span><span id="L-133"><a href="#L-133"><span class="linenos">133</span></a> <span class="p">)</span> </span><span id="L-134"><a href="#L-134"><span class="linenos">134</span></a> <span class="p">)</span> </span><span id="L-135"><a href="#L-135"><span class="linenos">135</span></a> -</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">select</span><span class="p">:</span> -</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not find </span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2"> in </span><span class="si">{</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-136"><a href="#L-136"><span class="linenos">136</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">):</span> +</span><span id="L-137"><a href="#L-137"><span class="linenos">137</span></a> <span class="n">upstream</span> <span class="o">=</span> <span class="n">upstream</span> <span class="ow">or</span> <span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"UNION"</span><span class="p">,</span> <span class="n">source</span><span class="o">=</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">select</span><span class="p">)</span> </span><span id="L-138"><a href="#L-138"><span class="linenos">138</span></a> -</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">):</span> -</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">upstream</span> <span class="o">=</span> <span class="n">upstream</span> <span class="ow">or</span> <span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"UNION"</span><span class="p">,</span> <span class="n">source</span><span class="o">=</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">select</span><span class="p">)</span> -</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> -</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="n">index</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="n">column</span> -</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> -</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">else</span> <span class="nb">next</span><span class="p">(</span> -</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="p">(</span> -</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="n">i</span> -</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">select</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">selects</span><span class="p">)</span> -</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">column</span> <span class="ow">or</span> <span class="n">select</span><span class="o">.</span><span class="n">is_star</span> -</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="p">),</span> -</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># mypy will not allow a None here, but a negative index should never be returned</span> -</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="p">)</span> -</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="p">)</span> +</span><span id="L-139"><a href="#L-139"><span class="linenos">139</span></a> <span class="n">index</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-140"><a href="#L-140"><span class="linenos">140</span></a> <span class="n">column</span> +</span><span id="L-141"><a href="#L-141"><span class="linenos">141</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> +</span><span id="L-142"><a href="#L-142"><span class="linenos">142</span></a> <span class="k">else</span> <span class="nb">next</span><span class="p">(</span> +</span><span id="L-143"><a href="#L-143"><span class="linenos">143</span></a> <span class="p">(</span> +</span><span id="L-144"><a href="#L-144"><span class="linenos">144</span></a> <span class="n">i</span> +</span><span id="L-145"><a href="#L-145"><span class="linenos">145</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">select</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">selects</span><span class="p">)</span> +</span><span id="L-146"><a href="#L-146"><span class="linenos">146</span></a> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">column</span> <span class="ow">or</span> <span class="n">select</span><span class="o">.</span><span class="n">is_star</span> +</span><span id="L-147"><a href="#L-147"><span class="linenos">147</span></a> <span class="p">),</span> +</span><span id="L-148"><a href="#L-148"><span class="linenos">148</span></a> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># mypy will not allow a None here, but a negative index should never be returned</span> +</span><span id="L-149"><a href="#L-149"><span class="linenos">149</span></a> <span class="p">)</span> +</span><span id="L-150"><a href="#L-150"><span class="linenos">150</span></a> <span class="p">)</span> +</span><span id="L-151"><a href="#L-151"><span class="linenos">151</span></a> +</span><span id="L-152"><a href="#L-152"><span class="linenos">152</span></a> <span class="k">if</span> <span class="n">index</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span> +</span><span id="L-153"><a href="#L-153"><span class="linenos">153</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not find </span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2"> in </span><span class="si">{</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-154"><a href="#L-154"><span class="linenos">154</span></a> -</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="k">if</span> <span class="n">index</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span> -</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not find </span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2"> in </span><span class="si">{</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-155"><a href="#L-155"><span class="linenos">155</span></a> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">union_scopes</span><span class="p">:</span> +</span><span id="L-156"><a href="#L-156"><span class="linenos">156</span></a> <span class="n">to_node</span><span class="p">(</span><span class="n">index</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">s</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">upstream</span><span class="p">)</span> </span><span id="L-157"><a href="#L-157"><span class="linenos">157</span></a> -</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">union_scopes</span><span class="p">:</span> -</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> <span class="n">to_node</span><span class="p">(</span><span class="n">index</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">s</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">upstream</span><span class="p">)</span> -</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> -</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="k">return</span> <span class="n">upstream</span> -</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> -</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="c1"># For better ergonomics in our node labels, replace the full select with</span> -</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="c1"># a version that has only the column we care about.</span> -</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="c1"># "x", SELECT x, y FROM foo</span> -</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="c1"># => "x", SELECT x FROM foo</span> -</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span> -</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> -</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="c1"># Create the node for this step in the lineage chain, and attach it to the previous one.</span> -</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">Node</span><span class="p">(</span> -</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">name</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">scope_name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">scope_name</span> <span class="k">else</span> <span class="nb">str</span><span class="p">(</span><span class="n">column</span><span class="p">),</span> -</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> -</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">select</span><span class="p">,</span> -</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> <span class="ow">or</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="p">)</span> +</span><span id="L-158"><a href="#L-158"><span class="linenos">158</span></a> <span class="k">return</span> <span class="n">upstream</span> +</span><span id="L-159"><a href="#L-159"><span class="linenos">159</span></a> +</span><span id="L-160"><a href="#L-160"><span class="linenos">160</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="L-161"><a href="#L-161"><span class="linenos">161</span></a> <span class="c1"># For better ergonomics in our node labels, replace the full select with</span> +</span><span id="L-162"><a href="#L-162"><span class="linenos">162</span></a> <span class="c1"># a version that has only the column we care about.</span> +</span><span id="L-163"><a href="#L-163"><span class="linenos">163</span></a> <span class="c1"># "x", SELECT x, y FROM foo</span> +</span><span id="L-164"><a href="#L-164"><span class="linenos">164</span></a> <span class="c1"># => "x", SELECT x FROM foo</span> +</span><span id="L-165"><a href="#L-165"><span class="linenos">165</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="L-166"><a href="#L-166"><span class="linenos">166</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-167"><a href="#L-167"><span class="linenos">167</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-168"><a href="#L-168"><span class="linenos">168</span></a> +</span><span id="L-169"><a href="#L-169"><span class="linenos">169</span></a> <span class="c1"># Create the node for this step in the lineage chain, and attach it to the previous one.</span> +</span><span id="L-170"><a href="#L-170"><span class="linenos">170</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">Node</span><span class="p">(</span> +</span><span id="L-171"><a href="#L-171"><span class="linenos">171</span></a> <span class="n">name</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">scope_name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">scope_name</span> <span class="k">else</span> <span class="nb">str</span><span class="p">(</span><span class="n">column</span><span class="p">),</span> +</span><span id="L-172"><a href="#L-172"><span class="linenos">172</span></a> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> +</span><span id="L-173"><a href="#L-173"><span class="linenos">173</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">select</span><span class="p">,</span> +</span><span id="L-174"><a href="#L-174"><span class="linenos">174</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> <span class="ow">or</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-175"><a href="#L-175"><span class="linenos">175</span></a> <span class="p">)</span> +</span><span id="L-176"><a href="#L-176"><span class="linenos">176</span></a> +</span><span id="L-177"><a href="#L-177"><span class="linenos">177</span></a> <span class="k">if</span> <span class="n">upstream</span><span class="p">:</span> +</span><span id="L-178"><a href="#L-178"><span class="linenos">178</span></a> <span class="n">upstream</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> </span><span id="L-179"><a href="#L-179"><span class="linenos">179</span></a> -</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="k">if</span> <span class="n">upstream</span><span class="p">:</span> -</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="n">upstream</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> -</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="n">subquery_scopes</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> <span class="nb">id</span><span class="p">(</span><span class="n">subquery_scope</span><span class="o">.</span><span class="n">expression</span><span class="p">):</span> <span class="n">subquery_scope</span> -</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="k">for</span> <span class="n">subquery_scope</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">subquery_scopes</span> -</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="p">}</span> +</span><span id="L-180"><a href="#L-180"><span class="linenos">180</span></a> <span class="n">subquery_scopes</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-181"><a href="#L-181"><span class="linenos">181</span></a> <span class="nb">id</span><span class="p">(</span><span class="n">subquery_scope</span><span class="o">.</span><span class="n">expression</span><span class="p">):</span> <span class="n">subquery_scope</span> +</span><span id="L-182"><a href="#L-182"><span class="linenos">182</span></a> <span class="k">for</span> <span class="n">subquery_scope</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">subquery_scopes</span> +</span><span id="L-183"><a href="#L-183"><span class="linenos">183</span></a> <span class="p">}</span> +</span><span id="L-184"><a href="#L-184"><span class="linenos">184</span></a> +</span><span id="L-185"><a href="#L-185"><span class="linenos">185</span></a> <span class="k">for</span> <span class="n">subquery</span> <span class="ow">in</span> <span class="n">find_all_in_scope</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="L-186"><a href="#L-186"><span class="linenos">186</span></a> <span class="n">subquery_scope</span> <span class="o">=</span> <span class="n">subquery_scopes</span><span class="p">[</span><span class="nb">id</span><span class="p">(</span><span class="n">subquery</span><span class="p">)]</span> </span><span id="L-187"><a href="#L-187"><span class="linenos">187</span></a> -</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="k">for</span> <span class="n">subquery</span> <span class="ow">in</span> <span class="n">find_all_in_scope</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">subquery_scope</span> <span class="o">=</span> <span class="n">subquery_scopes</span><span class="p">[</span><span class="nb">id</span><span class="p">(</span><span class="n">subquery</span><span class="p">)]</span> +</span><span id="L-188"><a href="#L-188"><span class="linenos">188</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">subquery</span><span class="o">.</span><span class="n">named_selects</span><span class="p">:</span> +</span><span id="L-189"><a href="#L-189"><span class="linenos">189</span></a> <span class="n">to_node</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">subquery_scope</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">node</span><span class="p">)</span> </span><span id="L-190"><a href="#L-190"><span class="linenos">190</span></a> -</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">subquery</span><span class="o">.</span><span class="n">named_selects</span><span class="p">:</span> -</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="n">to_node</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">subquery_scope</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">node</span><span class="p">)</span> -</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> -</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="c1"># if the select is a star add all scope sources as downstreams</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">is_star</span><span class="p">:</span> -</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="k">for</span> <span class="n">source</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> -</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">node</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">select</span><span class="o">.</span><span class="n">sql</span><span class="p">(),</span> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">source</span><span class="p">))</span> -</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> -</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="c1"># Find all columns that went into creating this one to list their lineage nodes.</span> -</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> <span class="n">source_columns</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">find_all_in_scope</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">))</span> -</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> -</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="c1"># If the source is a UDTF find columns used in the UTDF to generate the table</span> -</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UDTF</span><span class="p">):</span> -</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="n">source_columns</span> <span class="o">|=</span> <span class="nb">set</span><span class="p">(</span><span class="n">source</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">))</span> -</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> -</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">source_columns</span><span class="p">:</span> -</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">table</span> -</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> -</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">):</span> -</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="c1"># The table itself came from a more specific scope. Recurse into that one using the unaliased column name.</span> -</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="n">to_node</span><span class="p">(</span> -</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">scope_name</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">node</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">aliases</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="p">)</span> -</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="c1"># The source is not a scope - we've reached the end of the line. At this point, if a source is not found</span> -</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="c1"># it means this column's lineage is unknown. This can happen if the definition of a source used in a query</span> -</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="c1"># is not passed into the `sources` map.</span> -</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">source</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">()</span> -</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> <span class="n">node</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">sql</span><span class="p">(),</span> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">source</span><span class="p">))</span> -</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> -</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> <span class="k">return</span> <span class="n">node</span> -</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> -</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> <span class="k">return</span> <span class="n">to_node</span><span class="p">(</span><span class="n">column</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="p">)</span> +</span><span id="L-191"><a href="#L-191"><span class="linenos">191</span></a> <span class="c1"># if the select is a star add all scope sources as downstreams</span> +</span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">is_star</span><span class="p">:</span> +</span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="k">for</span> <span class="n">source</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> +</span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">):</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span> +</span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="n">node</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">select</span><span class="o">.</span><span class="n">sql</span><span class="p">(),</span> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">source</span><span class="p">))</span> +</span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> +</span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="c1"># Find all columns that went into creating this one to list their lineage nodes.</span> +</span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="n">source_columns</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">find_all_in_scope</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">))</span> +</span><span id="L-200"><a href="#L-200"><span class="linenos">200</span></a> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="c1"># If the source is a UDTF find columns used in the UTDF to generate the table</span> +</span><span id="L-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UDTF</span><span class="p">):</span> +</span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> <span class="n">source_columns</span> <span class="o">|=</span> <span class="nb">set</span><span class="p">(</span><span class="n">source</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">))</span> +</span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> +</span><span id="L-205"><a href="#L-205"><span class="linenos">205</span></a> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">source_columns</span><span class="p">:</span> +</span><span id="L-206"><a href="#L-206"><span class="linenos">206</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">table</span> +</span><span id="L-207"><a href="#L-207"><span class="linenos">207</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="L-208"><a href="#L-208"><span class="linenos">208</span></a> +</span><span id="L-209"><a href="#L-209"><span class="linenos">209</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">):</span> +</span><span id="L-210"><a href="#L-210"><span class="linenos">210</span></a> <span class="c1"># The table itself came from a more specific scope. Recurse into that one using the unaliased column name.</span> +</span><span id="L-211"><a href="#L-211"><span class="linenos">211</span></a> <span class="n">to_node</span><span class="p">(</span> +</span><span id="L-212"><a href="#L-212"><span class="linenos">212</span></a> <span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">scope_name</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">node</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">aliases</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="L-213"><a href="#L-213"><span class="linenos">213</span></a> <span class="p">)</span> +</span><span id="L-214"><a href="#L-214"><span class="linenos">214</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-215"><a href="#L-215"><span class="linenos">215</span></a> <span class="c1"># The source is not a scope - we've reached the end of the line. At this point, if a source is not found</span> +</span><span id="L-216"><a href="#L-216"><span class="linenos">216</span></a> <span class="c1"># it means this column's lineage is unknown. This can happen if the definition of a source used in a query</span> +</span><span id="L-217"><a href="#L-217"><span class="linenos">217</span></a> <span class="c1"># is not passed into the `sources` map.</span> +</span><span id="L-218"><a href="#L-218"><span class="linenos">218</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">source</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">()</span> +</span><span id="L-219"><a href="#L-219"><span class="linenos">219</span></a> <span class="n">node</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">sql</span><span class="p">(),</span> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">source</span><span class="p">))</span> +</span><span id="L-220"><a href="#L-220"><span class="linenos">220</span></a> +</span><span id="L-221"><a href="#L-221"><span class="linenos">221</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="L-222"><a href="#L-222"><span class="linenos">222</span></a> +</span><span id="L-223"><a href="#L-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="n">to_node</span><span class="p">(</span><span class="n">column</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="p">)</span> +</span><span id="L-224"><a href="#L-224"><span class="linenos">224</span></a> </span><span id="L-225"><a href="#L-225"><span class="linenos">225</span></a> -</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a> -</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a><span class="k">class</span> <span class="nc">GraphHTML</span><span class="p">:</span> -</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a><span class="w"> </span><span class="sd">"""Node to HTML generator using vis.js.</span> -</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a> -</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a><span class="sd"> https://visjs.github.io/vis-network/docs/network/</span> -</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a><span class="sd"> """</span> -</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> -</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nodes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">edges</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">,</span> <span class="n">imports</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="p">):</span> -</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> <span class="o">=</span> <span class="n">imports</span> -</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> -</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="s2">"height"</span><span class="p">:</span> <span class="s2">"500px"</span><span class="p">,</span> -</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="s2">"width"</span><span class="p">:</span> <span class="s2">"100%"</span><span class="p">,</span> -</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="s2">"layout"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="s2">"hierarchical"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="s2">"nodeSpacing"</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span> -</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="s2">"sortMethod"</span><span class="p">:</span> <span class="s2">"directed"</span><span class="p">,</span> -</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="p">},</span> -</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="p">},</span> -</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"interaction"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"dragNodes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="s2">"selectable"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="p">},</span> -</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="s2">"physics"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="p">},</span> -</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"edges"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="s2">"arrows"</span><span class="p">:</span> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="p">},</span> -</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="s2">"nodes"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="s2">"font"</span><span class="p">:</span> <span class="s2">"20px monaco"</span><span class="p">,</span> -</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="s2">"shape"</span><span class="p">:</span> <span class="s2">"box"</span><span class="p">,</span> -</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="s2">"widthConstraint"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> -</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="p">},</span> -</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="p">},</span> -</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="o">**</span><span class="p">(</span><span class="n">options</span> <span class="ow">or</span> <span class="p">{}),</span> -</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> <span class="p">}</span> -</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> -</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="n">nodes</span> -</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">edges</span> <span class="o">=</span> <span class="n">edges</span> -</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> -</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">nodes</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nodes</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">edges</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">edges</span><span class="p">)</span> -</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="p">)</span> -</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="n">imports</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a><span class="w"> </span><span class="sd">"""<script type="text/javascript" src="https://unpkg.com/vis-data@latest/peer/umd/vis-data.min.js"></script></span> -</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a><span class="sd"> <script type="text/javascript" src="https://unpkg.com/vis-network@latest/peer/umd/vis-network.min.js"></script></span> -</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a><span class="sd"> <link rel="stylesheet" type="text/css" href="https://unpkg.com/vis-network/styles/vis-network.min.css" />"""</span> -</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> -</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> <span class="p">)</span> -</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> -</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"""<div></span> -</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a><span class="s2"> <div id="sqlglot-lineage"></div></span> -</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a><span class="s2"> </span><span class="si">{</span><span class="n">imports</span><span class="si">}</span> -</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a><span class="s2"> <script type="text/javascript"></span> -</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a><span class="s2"> var nodes = new vis.DataSet(</span><span class="si">{</span><span class="n">nodes</span><span class="si">}</span><span class="s2">)</span> -</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a><span class="s2"> nodes.forEach(row => row["title"] = new DOMParser().parseFromString(row["title"], "text/html").body.childNodes[0])</span> -</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a> -</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a><span class="s2"> new vis.Network(</span> -</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a><span class="s2"> document.getElementById("sqlglot-lineage"),</span> -</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a><span class="s2"> </span><span class="se">{{</span> -</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a><span class="s2"> nodes: nodes,</span> -</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a><span class="s2"> edges: new vis.DataSet(</span><span class="si">{</span><span class="n">edges</span><span class="si">}</span><span class="s2">)</span> -</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a><span class="s2"> </span><span class="se">}}</span><span class="s2">,</span> -</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a><span class="s2"> </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">,</span> -</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a><span class="s2"> )</span> -</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a><span class="s2"> </script></span> -</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a><span class="s2"></div>"""</span> -</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> -</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="k">def</span> <span class="nf">_repr_html_</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-302"><a href="#L-302"><span class="linenos">302</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__str__</span><span class="p">()</span> +</span><span id="L-226"><a href="#L-226"><span class="linenos">226</span></a><span class="k">class</span> <span class="nc">GraphHTML</span><span class="p">:</span> +</span><span id="L-227"><a href="#L-227"><span class="linenos">227</span></a><span class="w"> </span><span class="sd">"""Node to HTML generator using vis.js.</span> +</span><span id="L-228"><a href="#L-228"><span class="linenos">228</span></a> +</span><span id="L-229"><a href="#L-229"><span class="linenos">229</span></a><span class="sd"> https://visjs.github.io/vis-network/docs/network/</span> +</span><span id="L-230"><a href="#L-230"><span class="linenos">230</span></a><span class="sd"> """</span> +</span><span id="L-231"><a href="#L-231"><span class="linenos">231</span></a> +</span><span id="L-232"><a href="#L-232"><span class="linenos">232</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="L-233"><a href="#L-233"><span class="linenos">233</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nodes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">edges</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">,</span> <span class="n">imports</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-234"><a href="#L-234"><span class="linenos">234</span></a> <span class="p">):</span> +</span><span id="L-235"><a href="#L-235"><span class="linenos">235</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> <span class="o">=</span> <span class="n">imports</span> +</span><span id="L-236"><a href="#L-236"><span class="linenos">236</span></a> +</span><span id="L-237"><a href="#L-237"><span class="linenos">237</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="L-238"><a href="#L-238"><span class="linenos">238</span></a> <span class="s2">"height"</span><span class="p">:</span> <span class="s2">"500px"</span><span class="p">,</span> +</span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="s2">"width"</span><span class="p">:</span> <span class="s2">"100%"</span><span class="p">,</span> +</span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> <span class="s2">"layout"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <span class="s2">"hierarchical"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> <span class="s2">"nodeSpacing"</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span> +</span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="s2">"sortMethod"</span><span class="p">:</span> <span class="s2">"directed"</span><span class="p">,</span> +</span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="p">},</span> +</span><span id="L-246"><a href="#L-246"><span class="linenos">246</span></a> <span class="p">},</span> +</span><span id="L-247"><a href="#L-247"><span class="linenos">247</span></a> <span class="s2">"interaction"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="L-248"><a href="#L-248"><span class="linenos">248</span></a> <span class="s2">"dragNodes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-249"><a href="#L-249"><span class="linenos">249</span></a> <span class="s2">"selectable"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-250"><a href="#L-250"><span class="linenos">250</span></a> <span class="p">},</span> +</span><span id="L-251"><a href="#L-251"><span class="linenos">251</span></a> <span class="s2">"physics"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="L-252"><a href="#L-252"><span class="linenos">252</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-253"><a href="#L-253"><span class="linenos">253</span></a> <span class="p">},</span> +</span><span id="L-254"><a href="#L-254"><span class="linenos">254</span></a> <span class="s2">"edges"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="L-255"><a href="#L-255"><span class="linenos">255</span></a> <span class="s2">"arrows"</span><span class="p">:</span> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="L-256"><a href="#L-256"><span class="linenos">256</span></a> <span class="p">},</span> +</span><span id="L-257"><a href="#L-257"><span class="linenos">257</span></a> <span class="s2">"nodes"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="L-258"><a href="#L-258"><span class="linenos">258</span></a> <span class="s2">"font"</span><span class="p">:</span> <span class="s2">"20px monaco"</span><span class="p">,</span> +</span><span id="L-259"><a href="#L-259"><span class="linenos">259</span></a> <span class="s2">"shape"</span><span class="p">:</span> <span class="s2">"box"</span><span class="p">,</span> +</span><span id="L-260"><a href="#L-260"><span class="linenos">260</span></a> <span class="s2">"widthConstraint"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="L-261"><a href="#L-261"><span class="linenos">261</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> +</span><span id="L-262"><a href="#L-262"><span class="linenos">262</span></a> <span class="p">},</span> +</span><span id="L-263"><a href="#L-263"><span class="linenos">263</span></a> <span class="p">},</span> +</span><span id="L-264"><a href="#L-264"><span class="linenos">264</span></a> <span class="o">**</span><span class="p">(</span><span class="n">options</span> <span class="ow">or</span> <span class="p">{}),</span> +</span><span id="L-265"><a href="#L-265"><span class="linenos">265</span></a> <span class="p">}</span> +</span><span id="L-266"><a href="#L-266"><span class="linenos">266</span></a> +</span><span id="L-267"><a href="#L-267"><span class="linenos">267</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="n">nodes</span> +</span><span id="L-268"><a href="#L-268"><span class="linenos">268</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">edges</span> <span class="o">=</span> <span class="n">edges</span> +</span><span id="L-269"><a href="#L-269"><span class="linenos">269</span></a> +</span><span id="L-270"><a href="#L-270"><span class="linenos">270</span></a> <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="L-271"><a href="#L-271"><span class="linenos">271</span></a> <span class="n">nodes</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nodes</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> +</span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="n">edges</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">edges</span><span class="p">)</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="p">)</span> +</span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="n">imports</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a><span class="w"> </span><span class="sd">"""<script type="text/javascript" src="https://unpkg.com/vis-data@latest/peer/umd/vis-data.min.js"></script></span> +</span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a><span class="sd"> <script type="text/javascript" src="https://unpkg.com/vis-network@latest/peer/umd/vis-network.min.js"></script></span> +</span><span id="L-277"><a href="#L-277"><span class="linenos">277</span></a><span class="sd"> <link rel="stylesheet" type="text/css" href="https://unpkg.com/vis-network/styles/vis-network.min.css" />"""</span> +</span><span id="L-278"><a href="#L-278"><span class="linenos">278</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> +</span><span id="L-279"><a href="#L-279"><span class="linenos">279</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-280"><a href="#L-280"><span class="linenos">280</span></a> <span class="p">)</span> +</span><span id="L-281"><a href="#L-281"><span class="linenos">281</span></a> +</span><span id="L-282"><a href="#L-282"><span class="linenos">282</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"""<div></span> +</span><span id="L-283"><a href="#L-283"><span class="linenos">283</span></a><span class="s2"> <div id="sqlglot-lineage"></div></span> +</span><span id="L-284"><a href="#L-284"><span class="linenos">284</span></a><span class="s2"> </span><span class="si">{</span><span class="n">imports</span><span class="si">}</span> +</span><span id="L-285"><a href="#L-285"><span class="linenos">285</span></a><span class="s2"> <script type="text/javascript"></span> +</span><span id="L-286"><a href="#L-286"><span class="linenos">286</span></a><span class="s2"> var nodes = new vis.DataSet(</span><span class="si">{</span><span class="n">nodes</span><span class="si">}</span><span class="s2">)</span> +</span><span id="L-287"><a href="#L-287"><span class="linenos">287</span></a><span class="s2"> nodes.forEach(row => row["title"] = new DOMParser().parseFromString(row["title"], "text/html").body.childNodes[0])</span> +</span><span id="L-288"><a href="#L-288"><span class="linenos">288</span></a> +</span><span id="L-289"><a href="#L-289"><span class="linenos">289</span></a><span class="s2"> new vis.Network(</span> +</span><span id="L-290"><a href="#L-290"><span class="linenos">290</span></a><span class="s2"> document.getElementById("sqlglot-lineage"),</span> +</span><span id="L-291"><a href="#L-291"><span class="linenos">291</span></a><span class="s2"> </span><span class="se">{{</span> +</span><span id="L-292"><a href="#L-292"><span class="linenos">292</span></a><span class="s2"> nodes: nodes,</span> +</span><span id="L-293"><a href="#L-293"><span class="linenos">293</span></a><span class="s2"> edges: new vis.DataSet(</span><span class="si">{</span><span class="n">edges</span><span class="si">}</span><span class="s2">)</span> +</span><span id="L-294"><a href="#L-294"><span class="linenos">294</span></a><span class="s2"> </span><span class="se">}}</span><span class="s2">,</span> +</span><span id="L-295"><a href="#L-295"><span class="linenos">295</span></a><span class="s2"> </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">,</span> +</span><span id="L-296"><a href="#L-296"><span class="linenos">296</span></a><span class="s2"> )</span> +</span><span id="L-297"><a href="#L-297"><span class="linenos">297</span></a><span class="s2"> </script></span> +</span><span id="L-298"><a href="#L-298"><span class="linenos">298</span></a><span class="s2"></div>"""</span> +</span><span id="L-299"><a href="#L-299"><span class="linenos">299</span></a> +</span><span id="L-300"><a href="#L-300"><span class="linenos">300</span></a> <span class="k">def</span> <span class="nf">_repr_html_</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-301"><a href="#L-301"><span class="linenos">301</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__str__</span><span class="p">()</span> </span></pre></div> @@ -699,99 +698,98 @@ </span><span id="lineage-130"><a href="#lineage-130"><span class="linenos">130</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> </span><span id="lineage-131"><a href="#lineage-131"><span class="linenos">131</span></a> <span class="k">else</span> <span class="nb">next</span><span class="p">(</span> </span><span id="lineage-132"><a href="#lineage-132"><span class="linenos">132</span></a> <span class="p">(</span><span class="n">select</span> <span class="k">for</span> <span class="n">select</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">selects</span> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">column</span><span class="p">),</span> -</span><span id="lineage-133"><a href="#lineage-133"><span class="linenos">133</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">()</span> <span class="k">if</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> <span class="k">else</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="lineage-133"><a href="#lineage-133"><span class="linenos">133</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">()</span> <span class="k">if</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">is_star</span> <span class="k">else</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> </span><span id="lineage-134"><a href="#lineage-134"><span class="linenos">134</span></a> <span class="p">)</span> </span><span id="lineage-135"><a href="#lineage-135"><span class="linenos">135</span></a> <span class="p">)</span> </span><span id="lineage-136"><a href="#lineage-136"><span class="linenos">136</span></a> -</span><span id="lineage-137"><a href="#lineage-137"><span class="linenos">137</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">select</span><span class="p">:</span> -</span><span id="lineage-138"><a href="#lineage-138"><span class="linenos">138</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not find </span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2"> in </span><span class="si">{</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="lineage-137"><a href="#lineage-137"><span class="linenos">137</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">):</span> +</span><span id="lineage-138"><a href="#lineage-138"><span class="linenos">138</span></a> <span class="n">upstream</span> <span class="o">=</span> <span class="n">upstream</span> <span class="ow">or</span> <span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"UNION"</span><span class="p">,</span> <span class="n">source</span><span class="o">=</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">select</span><span class="p">)</span> </span><span id="lineage-139"><a href="#lineage-139"><span class="linenos">139</span></a> -</span><span id="lineage-140"><a href="#lineage-140"><span class="linenos">140</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Union</span><span class="p">):</span> -</span><span id="lineage-141"><a href="#lineage-141"><span class="linenos">141</span></a> <span class="n">upstream</span> <span class="o">=</span> <span class="n">upstream</span> <span class="ow">or</span> <span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"UNION"</span><span class="p">,</span> <span class="n">source</span><span class="o">=</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">select</span><span class="p">)</span> -</span><span id="lineage-142"><a href="#lineage-142"><span class="linenos">142</span></a> -</span><span id="lineage-143"><a href="#lineage-143"><span class="linenos">143</span></a> <span class="n">index</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="lineage-144"><a href="#lineage-144"><span class="linenos">144</span></a> <span class="n">column</span> -</span><span id="lineage-145"><a href="#lineage-145"><span class="linenos">145</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> -</span><span id="lineage-146"><a href="#lineage-146"><span class="linenos">146</span></a> <span class="k">else</span> <span class="nb">next</span><span class="p">(</span> -</span><span id="lineage-147"><a href="#lineage-147"><span class="linenos">147</span></a> <span class="p">(</span> -</span><span id="lineage-148"><a href="#lineage-148"><span class="linenos">148</span></a> <span class="n">i</span> -</span><span id="lineage-149"><a href="#lineage-149"><span class="linenos">149</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">select</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">selects</span><span class="p">)</span> -</span><span id="lineage-150"><a href="#lineage-150"><span class="linenos">150</span></a> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">column</span> <span class="ow">or</span> <span class="n">select</span><span class="o">.</span><span class="n">is_star</span> -</span><span id="lineage-151"><a href="#lineage-151"><span class="linenos">151</span></a> <span class="p">),</span> -</span><span id="lineage-152"><a href="#lineage-152"><span class="linenos">152</span></a> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># mypy will not allow a None here, but a negative index should never be returned</span> -</span><span id="lineage-153"><a href="#lineage-153"><span class="linenos">153</span></a> <span class="p">)</span> -</span><span id="lineage-154"><a href="#lineage-154"><span class="linenos">154</span></a> <span class="p">)</span> +</span><span id="lineage-140"><a href="#lineage-140"><span class="linenos">140</span></a> <span class="n">index</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="lineage-141"><a href="#lineage-141"><span class="linenos">141</span></a> <span class="n">column</span> +</span><span id="lineage-142"><a href="#lineage-142"><span class="linenos">142</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> +</span><span id="lineage-143"><a href="#lineage-143"><span class="linenos">143</span></a> <span class="k">else</span> <span class="nb">next</span><span class="p">(</span> +</span><span id="lineage-144"><a href="#lineage-144"><span class="linenos">144</span></a> <span class="p">(</span> +</span><span id="lineage-145"><a href="#lineage-145"><span class="linenos">145</span></a> <span class="n">i</span> +</span><span id="lineage-146"><a href="#lineage-146"><span class="linenos">146</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">select</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">selects</span><span class="p">)</span> +</span><span id="lineage-147"><a href="#lineage-147"><span class="linenos">147</span></a> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="o">==</span> <span class="n">column</span> <span class="ow">or</span> <span class="n">select</span><span class="o">.</span><span class="n">is_star</span> +</span><span id="lineage-148"><a href="#lineage-148"><span class="linenos">148</span></a> <span class="p">),</span> +</span><span id="lineage-149"><a href="#lineage-149"><span class="linenos">149</span></a> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="c1"># mypy will not allow a None here, but a negative index should never be returned</span> +</span><span id="lineage-150"><a href="#lineage-150"><span class="linenos">150</span></a> <span class="p">)</span> +</span><span id="lineage-151"><a href="#lineage-151"><span class="linenos">151</span></a> <span class="p">)</span> +</span><span id="lineage-152"><a href="#lineage-152"><span class="linenos">152</span></a> +</span><span id="lineage-153"><a href="#lineage-153"><span class="linenos">153</span></a> <span class="k">if</span> <span class="n">index</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span> +</span><span id="lineage-154"><a href="#lineage-154"><span class="linenos">154</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not find </span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2"> in </span><span class="si">{</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="lineage-155"><a href="#lineage-155"><span class="linenos">155</span></a> -</span><span id="lineage-156"><a href="#lineage-156"><span class="linenos">156</span></a> <span class="k">if</span> <span class="n">index</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span> -</span><span id="lineage-157"><a href="#lineage-157"><span class="linenos">157</span></a> <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Could not find </span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2"> in </span><span class="si">{</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="lineage-156"><a href="#lineage-156"><span class="linenos">156</span></a> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">union_scopes</span><span class="p">:</span> +</span><span id="lineage-157"><a href="#lineage-157"><span class="linenos">157</span></a> <span class="n">to_node</span><span class="p">(</span><span class="n">index</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">s</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">upstream</span><span class="p">)</span> </span><span id="lineage-158"><a href="#lineage-158"><span class="linenos">158</span></a> -</span><span id="lineage-159"><a href="#lineage-159"><span class="linenos">159</span></a> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">union_scopes</span><span class="p">:</span> -</span><span id="lineage-160"><a href="#lineage-160"><span class="linenos">160</span></a> <span class="n">to_node</span><span class="p">(</span><span class="n">index</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">s</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">upstream</span><span class="p">)</span> -</span><span id="lineage-161"><a href="#lineage-161"><span class="linenos">161</span></a> -</span><span id="lineage-162"><a href="#lineage-162"><span class="linenos">162</span></a> <span class="k">return</span> <span class="n">upstream</span> -</span><span id="lineage-163"><a href="#lineage-163"><span class="linenos">163</span></a> -</span><span id="lineage-164"><a href="#lineage-164"><span class="linenos">164</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> -</span><span id="lineage-165"><a href="#lineage-165"><span class="linenos">165</span></a> <span class="c1"># For better ergonomics in our node labels, replace the full select with</span> -</span><span id="lineage-166"><a href="#lineage-166"><span class="linenos">166</span></a> <span class="c1"># a version that has only the column we care about.</span> -</span><span id="lineage-167"><a href="#lineage-167"><span class="linenos">167</span></a> <span class="c1"># "x", SELECT x, y FROM foo</span> -</span><span id="lineage-168"><a href="#lineage-168"><span class="linenos">168</span></a> <span class="c1"># => "x", SELECT x FROM foo</span> -</span><span id="lineage-169"><a href="#lineage-169"><span class="linenos">169</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="lineage-170"><a href="#lineage-170"><span class="linenos">170</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="lineage-171"><a href="#lineage-171"><span class="linenos">171</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span> -</span><span id="lineage-172"><a href="#lineage-172"><span class="linenos">172</span></a> -</span><span id="lineage-173"><a href="#lineage-173"><span class="linenos">173</span></a> <span class="c1"># Create the node for this step in the lineage chain, and attach it to the previous one.</span> -</span><span id="lineage-174"><a href="#lineage-174"><span class="linenos">174</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">Node</span><span class="p">(</span> -</span><span id="lineage-175"><a href="#lineage-175"><span class="linenos">175</span></a> <span class="n">name</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">scope_name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">scope_name</span> <span class="k">else</span> <span class="nb">str</span><span class="p">(</span><span class="n">column</span><span class="p">),</span> -</span><span id="lineage-176"><a href="#lineage-176"><span class="linenos">176</span></a> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> -</span><span id="lineage-177"><a href="#lineage-177"><span class="linenos">177</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">select</span><span class="p">,</span> -</span><span id="lineage-178"><a href="#lineage-178"><span class="linenos">178</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> <span class="ow">or</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="lineage-179"><a href="#lineage-179"><span class="linenos">179</span></a> <span class="p">)</span> +</span><span id="lineage-159"><a href="#lineage-159"><span class="linenos">159</span></a> <span class="k">return</span> <span class="n">upstream</span> +</span><span id="lineage-160"><a href="#lineage-160"><span class="linenos">160</span></a> +</span><span id="lineage-161"><a href="#lineage-161"><span class="linenos">161</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Select</span><span class="p">):</span> +</span><span id="lineage-162"><a href="#lineage-162"><span class="linenos">162</span></a> <span class="c1"># For better ergonomics in our node labels, replace the full select with</span> +</span><span id="lineage-163"><a href="#lineage-163"><span class="linenos">163</span></a> <span class="c1"># a version that has only the column we care about.</span> +</span><span id="lineage-164"><a href="#lineage-164"><span class="linenos">164</span></a> <span class="c1"># "x", SELECT x, y FROM foo</span> +</span><span id="lineage-165"><a href="#lineage-165"><span class="linenos">165</span></a> <span class="c1"># => "x", SELECT x FROM foo</span> +</span><span id="lineage-166"><a href="#lineage-166"><span class="linenos">166</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">,</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">append</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="lineage-167"><a href="#lineage-167"><span class="linenos">167</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="lineage-168"><a href="#lineage-168"><span class="linenos">168</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">scope</span><span class="o">.</span><span class="n">expression</span> +</span><span id="lineage-169"><a href="#lineage-169"><span class="linenos">169</span></a> +</span><span id="lineage-170"><a href="#lineage-170"><span class="linenos">170</span></a> <span class="c1"># Create the node for this step in the lineage chain, and attach it to the previous one.</span> +</span><span id="lineage-171"><a href="#lineage-171"><span class="linenos">171</span></a> <span class="n">node</span> <span class="o">=</span> <span class="n">Node</span><span class="p">(</span> +</span><span id="lineage-172"><a href="#lineage-172"><span class="linenos">172</span></a> <span class="n">name</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">scope_name</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="n">column</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">scope_name</span> <span class="k">else</span> <span class="nb">str</span><span class="p">(</span><span class="n">column</span><span class="p">),</span> +</span><span id="lineage-173"><a href="#lineage-173"><span class="linenos">173</span></a> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> +</span><span id="lineage-174"><a href="#lineage-174"><span class="linenos">174</span></a> <span class="n">expression</span><span class="o">=</span><span class="n">select</span><span class="p">,</span> +</span><span id="lineage-175"><a href="#lineage-175"><span class="linenos">175</span></a> <span class="n">alias</span><span class="o">=</span><span class="n">alias</span> <span class="ow">or</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="lineage-176"><a href="#lineage-176"><span class="linenos">176</span></a> <span class="p">)</span> +</span><span id="lineage-177"><a href="#lineage-177"><span class="linenos">177</span></a> +</span><span id="lineage-178"><a href="#lineage-178"><span class="linenos">178</span></a> <span class="k">if</span> <span class="n">upstream</span><span class="p">:</span> +</span><span id="lineage-179"><a href="#lineage-179"><span class="linenos">179</span></a> <span class="n">upstream</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> </span><span id="lineage-180"><a href="#lineage-180"><span class="linenos">180</span></a> -</span><span id="lineage-181"><a href="#lineage-181"><span class="linenos">181</span></a> <span class="k">if</span> <span class="n">upstream</span><span class="p">:</span> -</span><span id="lineage-182"><a href="#lineage-182"><span class="linenos">182</span></a> <span class="n">upstream</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">node</span><span class="p">)</span> -</span><span id="lineage-183"><a href="#lineage-183"><span class="linenos">183</span></a> -</span><span id="lineage-184"><a href="#lineage-184"><span class="linenos">184</span></a> <span class="n">subquery_scopes</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="lineage-185"><a href="#lineage-185"><span class="linenos">185</span></a> <span class="nb">id</span><span class="p">(</span><span class="n">subquery_scope</span><span class="o">.</span><span class="n">expression</span><span class="p">):</span> <span class="n">subquery_scope</span> -</span><span id="lineage-186"><a href="#lineage-186"><span class="linenos">186</span></a> <span class="k">for</span> <span class="n">subquery_scope</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">subquery_scopes</span> -</span><span id="lineage-187"><a href="#lineage-187"><span class="linenos">187</span></a> <span class="p">}</span> +</span><span id="lineage-181"><a href="#lineage-181"><span class="linenos">181</span></a> <span class="n">subquery_scopes</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="lineage-182"><a href="#lineage-182"><span class="linenos">182</span></a> <span class="nb">id</span><span class="p">(</span><span class="n">subquery_scope</span><span class="o">.</span><span class="n">expression</span><span class="p">):</span> <span class="n">subquery_scope</span> +</span><span id="lineage-183"><a href="#lineage-183"><span class="linenos">183</span></a> <span class="k">for</span> <span class="n">subquery_scope</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">subquery_scopes</span> +</span><span id="lineage-184"><a href="#lineage-184"><span class="linenos">184</span></a> <span class="p">}</span> +</span><span id="lineage-185"><a href="#lineage-185"><span class="linenos">185</span></a> +</span><span id="lineage-186"><a href="#lineage-186"><span class="linenos">186</span></a> <span class="k">for</span> <span class="n">subquery</span> <span class="ow">in</span> <span class="n">find_all_in_scope</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> +</span><span id="lineage-187"><a href="#lineage-187"><span class="linenos">187</span></a> <span class="n">subquery_scope</span> <span class="o">=</span> <span class="n">subquery_scopes</span><span class="p">[</span><span class="nb">id</span><span class="p">(</span><span class="n">subquery</span><span class="p">)]</span> </span><span id="lineage-188"><a href="#lineage-188"><span class="linenos">188</span></a> -</span><span id="lineage-189"><a href="#lineage-189"><span class="linenos">189</span></a> <span class="k">for</span> <span class="n">subquery</span> <span class="ow">in</span> <span class="n">find_all_in_scope</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subqueryable</span><span class="p">):</span> -</span><span id="lineage-190"><a href="#lineage-190"><span class="linenos">190</span></a> <span class="n">subquery_scope</span> <span class="o">=</span> <span class="n">subquery_scopes</span><span class="p">[</span><span class="nb">id</span><span class="p">(</span><span class="n">subquery</span><span class="p">)]</span> +</span><span id="lineage-189"><a href="#lineage-189"><span class="linenos">189</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">subquery</span><span class="o">.</span><span class="n">named_selects</span><span class="p">:</span> +</span><span id="lineage-190"><a href="#lineage-190"><span class="linenos">190</span></a> <span class="n">to_node</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">subquery_scope</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">node</span><span class="p">)</span> </span><span id="lineage-191"><a href="#lineage-191"><span class="linenos">191</span></a> -</span><span id="lineage-192"><a href="#lineage-192"><span class="linenos">192</span></a> <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">subquery</span><span class="o">.</span><span class="n">named_selects</span><span class="p">:</span> -</span><span id="lineage-193"><a href="#lineage-193"><span class="linenos">193</span></a> <span class="n">to_node</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">subquery_scope</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">node</span><span class="p">)</span> -</span><span id="lineage-194"><a href="#lineage-194"><span class="linenos">194</span></a> -</span><span id="lineage-195"><a href="#lineage-195"><span class="linenos">195</span></a> <span class="c1"># if the select is a star add all scope sources as downstreams</span> -</span><span id="lineage-196"><a href="#lineage-196"><span class="linenos">196</span></a> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">is_star</span><span class="p">:</span> -</span><span id="lineage-197"><a href="#lineage-197"><span class="linenos">197</span></a> <span class="k">for</span> <span class="n">source</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> -</span><span id="lineage-198"><a href="#lineage-198"><span class="linenos">198</span></a> <span class="n">node</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">select</span><span class="o">.</span><span class="n">sql</span><span class="p">(),</span> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">source</span><span class="p">))</span> -</span><span id="lineage-199"><a href="#lineage-199"><span class="linenos">199</span></a> -</span><span id="lineage-200"><a href="#lineage-200"><span class="linenos">200</span></a> <span class="c1"># Find all columns that went into creating this one to list their lineage nodes.</span> -</span><span id="lineage-201"><a href="#lineage-201"><span class="linenos">201</span></a> <span class="n">source_columns</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">find_all_in_scope</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">))</span> -</span><span id="lineage-202"><a href="#lineage-202"><span class="linenos">202</span></a> -</span><span id="lineage-203"><a href="#lineage-203"><span class="linenos">203</span></a> <span class="c1"># If the source is a UDTF find columns used in the UTDF to generate the table</span> -</span><span id="lineage-204"><a href="#lineage-204"><span class="linenos">204</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UDTF</span><span class="p">):</span> -</span><span id="lineage-205"><a href="#lineage-205"><span class="linenos">205</span></a> <span class="n">source_columns</span> <span class="o">|=</span> <span class="nb">set</span><span class="p">(</span><span class="n">source</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">))</span> -</span><span id="lineage-206"><a href="#lineage-206"><span class="linenos">206</span></a> -</span><span id="lineage-207"><a href="#lineage-207"><span class="linenos">207</span></a> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">source_columns</span><span class="p">:</span> -</span><span id="lineage-208"><a href="#lineage-208"><span class="linenos">208</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">table</span> -</span><span id="lineage-209"><a href="#lineage-209"><span class="linenos">209</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="lineage-210"><a href="#lineage-210"><span class="linenos">210</span></a> -</span><span id="lineage-211"><a href="#lineage-211"><span class="linenos">211</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">):</span> -</span><span id="lineage-212"><a href="#lineage-212"><span class="linenos">212</span></a> <span class="c1"># The table itself came from a more specific scope. Recurse into that one using the unaliased column name.</span> -</span><span id="lineage-213"><a href="#lineage-213"><span class="linenos">213</span></a> <span class="n">to_node</span><span class="p">(</span> -</span><span id="lineage-214"><a href="#lineage-214"><span class="linenos">214</span></a> <span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">scope_name</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">node</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">aliases</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="lineage-215"><a href="#lineage-215"><span class="linenos">215</span></a> <span class="p">)</span> -</span><span id="lineage-216"><a href="#lineage-216"><span class="linenos">216</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="lineage-217"><a href="#lineage-217"><span class="linenos">217</span></a> <span class="c1"># The source is not a scope - we've reached the end of the line. At this point, if a source is not found</span> -</span><span id="lineage-218"><a href="#lineage-218"><span class="linenos">218</span></a> <span class="c1"># it means this column's lineage is unknown. This can happen if the definition of a source used in a query</span> -</span><span id="lineage-219"><a href="#lineage-219"><span class="linenos">219</span></a> <span class="c1"># is not passed into the `sources` map.</span> -</span><span id="lineage-220"><a href="#lineage-220"><span class="linenos">220</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">source</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">()</span> -</span><span id="lineage-221"><a href="#lineage-221"><span class="linenos">221</span></a> <span class="n">node</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">sql</span><span class="p">(),</span> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">source</span><span class="p">))</span> -</span><span id="lineage-222"><a href="#lineage-222"><span class="linenos">222</span></a> -</span><span id="lineage-223"><a href="#lineage-223"><span class="linenos">223</span></a> <span class="k">return</span> <span class="n">node</span> -</span><span id="lineage-224"><a href="#lineage-224"><span class="linenos">224</span></a> -</span><span id="lineage-225"><a href="#lineage-225"><span class="linenos">225</span></a> <span class="k">return</span> <span class="n">to_node</span><span class="p">(</span><span class="n">column</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="p">)</span> +</span><span id="lineage-192"><a href="#lineage-192"><span class="linenos">192</span></a> <span class="c1"># if the select is a star add all scope sources as downstreams</span> +</span><span id="lineage-193"><a href="#lineage-193"><span class="linenos">193</span></a> <span class="k">if</span> <span class="n">select</span><span class="o">.</span><span class="n">is_star</span><span class="p">:</span> +</span><span id="lineage-194"><a href="#lineage-194"><span class="linenos">194</span></a> <span class="k">for</span> <span class="n">source</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">values</span><span class="p">():</span> +</span><span id="lineage-195"><a href="#lineage-195"><span class="linenos">195</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">):</span> +</span><span id="lineage-196"><a href="#lineage-196"><span class="linenos">196</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">expression</span> +</span><span id="lineage-197"><a href="#lineage-197"><span class="linenos">197</span></a> <span class="n">node</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">select</span><span class="o">.</span><span class="n">sql</span><span class="p">(),</span> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">source</span><span class="p">))</span> +</span><span id="lineage-198"><a href="#lineage-198"><span class="linenos">198</span></a> +</span><span id="lineage-199"><a href="#lineage-199"><span class="linenos">199</span></a> <span class="c1"># Find all columns that went into creating this one to list their lineage nodes.</span> +</span><span id="lineage-200"><a href="#lineage-200"><span class="linenos">200</span></a> <span class="n">source_columns</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">find_all_in_scope</span><span class="p">(</span><span class="n">select</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">))</span> +</span><span id="lineage-201"><a href="#lineage-201"><span class="linenos">201</span></a> +</span><span id="lineage-202"><a href="#lineage-202"><span class="linenos">202</span></a> <span class="c1"># If the source is a UDTF find columns used in the UTDF to generate the table</span> +</span><span id="lineage-203"><a href="#lineage-203"><span class="linenos">203</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">UDTF</span><span class="p">):</span> +</span><span id="lineage-204"><a href="#lineage-204"><span class="linenos">204</span></a> <span class="n">source_columns</span> <span class="o">|=</span> <span class="nb">set</span><span class="p">(</span><span class="n">source</span><span class="o">.</span><span class="n">find_all</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Column</span><span class="p">))</span> +</span><span id="lineage-205"><a href="#lineage-205"><span class="linenos">205</span></a> +</span><span id="lineage-206"><a href="#lineage-206"><span class="linenos">206</span></a> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">source_columns</span><span class="p">:</span> +</span><span id="lineage-207"><a href="#lineage-207"><span class="linenos">207</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">table</span> +</span><span id="lineage-208"><a href="#lineage-208"><span class="linenos">208</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">scope</span><span class="o">.</span><span class="n">sources</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="lineage-209"><a href="#lineage-209"><span class="linenos">209</span></a> +</span><span id="lineage-210"><a href="#lineage-210"><span class="linenos">210</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="n">Scope</span><span class="p">):</span> +</span><span id="lineage-211"><a href="#lineage-211"><span class="linenos">211</span></a> <span class="c1"># The table itself came from a more specific scope. Recurse into that one using the unaliased column name.</span> +</span><span id="lineage-212"><a href="#lineage-212"><span class="linenos">212</span></a> <span class="n">to_node</span><span class="p">(</span> +</span><span id="lineage-213"><a href="#lineage-213"><span class="linenos">213</span></a> <span class="n">c</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">scope_name</span><span class="o">=</span><span class="n">table</span><span class="p">,</span> <span class="n">upstream</span><span class="o">=</span><span class="n">node</span><span class="p">,</span> <span class="n">alias</span><span class="o">=</span><span class="n">aliases</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="lineage-214"><a href="#lineage-214"><span class="linenos">214</span></a> <span class="p">)</span> +</span><span id="lineage-215"><a href="#lineage-215"><span class="linenos">215</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="lineage-216"><a href="#lineage-216"><span class="linenos">216</span></a> <span class="c1"># The source is not a scope - we've reached the end of the line. At this point, if a source is not found</span> +</span><span id="lineage-217"><a href="#lineage-217"><span class="linenos">217</span></a> <span class="c1"># it means this column's lineage is unknown. This can happen if the definition of a source used in a query</span> +</span><span id="lineage-218"><a href="#lineage-218"><span class="linenos">218</span></a> <span class="c1"># is not passed into the `sources` map.</span> +</span><span id="lineage-219"><a href="#lineage-219"><span class="linenos">219</span></a> <span class="n">source</span> <span class="o">=</span> <span class="n">source</span> <span class="ow">or</span> <span class="n">exp</span><span class="o">.</span><span class="n">Placeholder</span><span class="p">()</span> +</span><span id="lineage-220"><a href="#lineage-220"><span class="linenos">220</span></a> <span class="n">node</span><span class="o">.</span><span class="n">downstream</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Node</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">c</span><span class="o">.</span><span class="n">sql</span><span class="p">(),</span> <span class="n">source</span><span class="o">=</span><span class="n">source</span><span class="p">,</span> <span class="n">expression</span><span class="o">=</span><span class="n">source</span><span class="p">))</span> +</span><span id="lineage-221"><a href="#lineage-221"><span class="linenos">221</span></a> +</span><span id="lineage-222"><a href="#lineage-222"><span class="linenos">222</span></a> <span class="k">return</span> <span class="n">node</span> +</span><span id="lineage-223"><a href="#lineage-223"><span class="linenos">223</span></a> +</span><span id="lineage-224"><a href="#lineage-224"><span class="linenos">224</span></a> <span class="k">return</span> <span class="n">to_node</span><span class="p">(</span><span class="n">column</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">column</span><span class="p">,</span> <span class="nb">str</span><span class="p">)</span> <span class="k">else</span> <span class="n">column</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">scope</span><span class="p">)</span> </span></pre></div> @@ -828,82 +826,82 @@ </div> <a class="headerlink" href="#GraphHTML"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="GraphHTML-228"><a href="#GraphHTML-228"><span class="linenos">228</span></a><span class="k">class</span> <span class="nc">GraphHTML</span><span class="p">:</span> -</span><span id="GraphHTML-229"><a href="#GraphHTML-229"><span class="linenos">229</span></a><span class="w"> </span><span class="sd">"""Node to HTML generator using vis.js.</span> -</span><span id="GraphHTML-230"><a href="#GraphHTML-230"><span class="linenos">230</span></a> -</span><span id="GraphHTML-231"><a href="#GraphHTML-231"><span class="linenos">231</span></a><span class="sd"> https://visjs.github.io/vis-network/docs/network/</span> -</span><span id="GraphHTML-232"><a href="#GraphHTML-232"><span class="linenos">232</span></a><span class="sd"> """</span> -</span><span id="GraphHTML-233"><a href="#GraphHTML-233"><span class="linenos">233</span></a> -</span><span id="GraphHTML-234"><a href="#GraphHTML-234"><span class="linenos">234</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="GraphHTML-235"><a href="#GraphHTML-235"><span class="linenos">235</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nodes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">edges</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">,</span> <span class="n">imports</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="GraphHTML-236"><a href="#GraphHTML-236"><span class="linenos">236</span></a> <span class="p">):</span> -</span><span id="GraphHTML-237"><a href="#GraphHTML-237"><span class="linenos">237</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> <span class="o">=</span> <span class="n">imports</span> -</span><span id="GraphHTML-238"><a href="#GraphHTML-238"><span class="linenos">238</span></a> -</span><span id="GraphHTML-239"><a href="#GraphHTML-239"><span class="linenos">239</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="GraphHTML-240"><a href="#GraphHTML-240"><span class="linenos">240</span></a> <span class="s2">"height"</span><span class="p">:</span> <span class="s2">"500px"</span><span class="p">,</span> -</span><span id="GraphHTML-241"><a href="#GraphHTML-241"><span class="linenos">241</span></a> <span class="s2">"width"</span><span class="p">:</span> <span class="s2">"100%"</span><span class="p">,</span> -</span><span id="GraphHTML-242"><a href="#GraphHTML-242"><span class="linenos">242</span></a> <span class="s2">"layout"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML-243"><a href="#GraphHTML-243"><span class="linenos">243</span></a> <span class="s2">"hierarchical"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML-244"><a href="#GraphHTML-244"><span class="linenos">244</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="GraphHTML-245"><a href="#GraphHTML-245"><span class="linenos">245</span></a> <span class="s2">"nodeSpacing"</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span> -</span><span id="GraphHTML-246"><a href="#GraphHTML-246"><span class="linenos">246</span></a> <span class="s2">"sortMethod"</span><span class="p">:</span> <span class="s2">"directed"</span><span class="p">,</span> -</span><span id="GraphHTML-247"><a href="#GraphHTML-247"><span class="linenos">247</span></a> <span class="p">},</span> -</span><span id="GraphHTML-248"><a href="#GraphHTML-248"><span class="linenos">248</span></a> <span class="p">},</span> -</span><span id="GraphHTML-249"><a href="#GraphHTML-249"><span class="linenos">249</span></a> <span class="s2">"interaction"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML-250"><a href="#GraphHTML-250"><span class="linenos">250</span></a> <span class="s2">"dragNodes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="GraphHTML-251"><a href="#GraphHTML-251"><span class="linenos">251</span></a> <span class="s2">"selectable"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="GraphHTML-252"><a href="#GraphHTML-252"><span class="linenos">252</span></a> <span class="p">},</span> -</span><span id="GraphHTML-253"><a href="#GraphHTML-253"><span class="linenos">253</span></a> <span class="s2">"physics"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML-254"><a href="#GraphHTML-254"><span class="linenos">254</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="GraphHTML-255"><a href="#GraphHTML-255"><span class="linenos">255</span></a> <span class="p">},</span> -</span><span id="GraphHTML-256"><a href="#GraphHTML-256"><span class="linenos">256</span></a> <span class="s2">"edges"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML-257"><a href="#GraphHTML-257"><span class="linenos">257</span></a> <span class="s2">"arrows"</span><span class="p">:</span> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="GraphHTML-258"><a href="#GraphHTML-258"><span class="linenos">258</span></a> <span class="p">},</span> -</span><span id="GraphHTML-259"><a href="#GraphHTML-259"><span class="linenos">259</span></a> <span class="s2">"nodes"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML-260"><a href="#GraphHTML-260"><span class="linenos">260</span></a> <span class="s2">"font"</span><span class="p">:</span> <span class="s2">"20px monaco"</span><span class="p">,</span> -</span><span id="GraphHTML-261"><a href="#GraphHTML-261"><span class="linenos">261</span></a> <span class="s2">"shape"</span><span class="p">:</span> <span class="s2">"box"</span><span class="p">,</span> -</span><span id="GraphHTML-262"><a href="#GraphHTML-262"><span class="linenos">262</span></a> <span class="s2">"widthConstraint"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML-263"><a href="#GraphHTML-263"><span class="linenos">263</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> -</span><span id="GraphHTML-264"><a href="#GraphHTML-264"><span class="linenos">264</span></a> <span class="p">},</span> -</span><span id="GraphHTML-265"><a href="#GraphHTML-265"><span class="linenos">265</span></a> <span class="p">},</span> -</span><span id="GraphHTML-266"><a href="#GraphHTML-266"><span class="linenos">266</span></a> <span class="o">**</span><span class="p">(</span><span class="n">options</span> <span class="ow">or</span> <span class="p">{}),</span> -</span><span id="GraphHTML-267"><a href="#GraphHTML-267"><span class="linenos">267</span></a> <span class="p">}</span> -</span><span id="GraphHTML-268"><a href="#GraphHTML-268"><span class="linenos">268</span></a> -</span><span id="GraphHTML-269"><a href="#GraphHTML-269"><span class="linenos">269</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="n">nodes</span> -</span><span id="GraphHTML-270"><a href="#GraphHTML-270"><span class="linenos">270</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">edges</span> <span class="o">=</span> <span class="n">edges</span> -</span><span id="GraphHTML-271"><a href="#GraphHTML-271"><span class="linenos">271</span></a> -</span><span id="GraphHTML-272"><a href="#GraphHTML-272"><span class="linenos">272</span></a> <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> -</span><span id="GraphHTML-273"><a href="#GraphHTML-273"><span class="linenos">273</span></a> <span class="n">nodes</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nodes</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> -</span><span id="GraphHTML-274"><a href="#GraphHTML-274"><span class="linenos">274</span></a> <span class="n">edges</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">edges</span><span class="p">)</span> -</span><span id="GraphHTML-275"><a href="#GraphHTML-275"><span class="linenos">275</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="p">)</span> -</span><span id="GraphHTML-276"><a href="#GraphHTML-276"><span class="linenos">276</span></a> <span class="n">imports</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="GraphHTML-277"><a href="#GraphHTML-277"><span class="linenos">277</span></a><span class="w"> </span><span class="sd">"""<script type="text/javascript" src="https://unpkg.com/vis-data@latest/peer/umd/vis-data.min.js"></script></span> -</span><span id="GraphHTML-278"><a href="#GraphHTML-278"><span class="linenos">278</span></a><span class="sd"> <script type="text/javascript" src="https://unpkg.com/vis-network@latest/peer/umd/vis-network.min.js"></script></span> -</span><span id="GraphHTML-279"><a href="#GraphHTML-279"><span class="linenos">279</span></a><span class="sd"> <link rel="stylesheet" type="text/css" href="https://unpkg.com/vis-network/styles/vis-network.min.css" />"""</span> -</span><span id="GraphHTML-280"><a href="#GraphHTML-280"><span class="linenos">280</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> -</span><span id="GraphHTML-281"><a href="#GraphHTML-281"><span class="linenos">281</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="GraphHTML-282"><a href="#GraphHTML-282"><span class="linenos">282</span></a> <span class="p">)</span> -</span><span id="GraphHTML-283"><a href="#GraphHTML-283"><span class="linenos">283</span></a> -</span><span id="GraphHTML-284"><a href="#GraphHTML-284"><span class="linenos">284</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"""<div></span> -</span><span id="GraphHTML-285"><a href="#GraphHTML-285"><span class="linenos">285</span></a><span class="s2"> <div id="sqlglot-lineage"></div></span> -</span><span id="GraphHTML-286"><a href="#GraphHTML-286"><span class="linenos">286</span></a><span class="s2"> </span><span class="si">{</span><span class="n">imports</span><span class="si">}</span> -</span><span id="GraphHTML-287"><a href="#GraphHTML-287"><span class="linenos">287</span></a><span class="s2"> <script type="text/javascript"></span> -</span><span id="GraphHTML-288"><a href="#GraphHTML-288"><span class="linenos">288</span></a><span class="s2"> var nodes = new vis.DataSet(</span><span class="si">{</span><span class="n">nodes</span><span class="si">}</span><span class="s2">)</span> -</span><span id="GraphHTML-289"><a href="#GraphHTML-289"><span class="linenos">289</span></a><span class="s2"> nodes.forEach(row => row["title"] = new DOMParser().parseFromString(row["title"], "text/html").body.childNodes[0])</span> -</span><span id="GraphHTML-290"><a href="#GraphHTML-290"><span class="linenos">290</span></a> -</span><span id="GraphHTML-291"><a href="#GraphHTML-291"><span class="linenos">291</span></a><span class="s2"> new vis.Network(</span> -</span><span id="GraphHTML-292"><a href="#GraphHTML-292"><span class="linenos">292</span></a><span class="s2"> document.getElementById("sqlglot-lineage"),</span> -</span><span id="GraphHTML-293"><a href="#GraphHTML-293"><span class="linenos">293</span></a><span class="s2"> </span><span class="se">{{</span> -</span><span id="GraphHTML-294"><a href="#GraphHTML-294"><span class="linenos">294</span></a><span class="s2"> nodes: nodes,</span> -</span><span id="GraphHTML-295"><a href="#GraphHTML-295"><span class="linenos">295</span></a><span class="s2"> edges: new vis.DataSet(</span><span class="si">{</span><span class="n">edges</span><span class="si">}</span><span class="s2">)</span> -</span><span id="GraphHTML-296"><a href="#GraphHTML-296"><span class="linenos">296</span></a><span class="s2"> </span><span class="se">}}</span><span class="s2">,</span> -</span><span id="GraphHTML-297"><a href="#GraphHTML-297"><span class="linenos">297</span></a><span class="s2"> </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">,</span> -</span><span id="GraphHTML-298"><a href="#GraphHTML-298"><span class="linenos">298</span></a><span class="s2"> )</span> -</span><span id="GraphHTML-299"><a href="#GraphHTML-299"><span class="linenos">299</span></a><span class="s2"> </script></span> -</span><span id="GraphHTML-300"><a href="#GraphHTML-300"><span class="linenos">300</span></a><span class="s2"></div>"""</span> -</span><span id="GraphHTML-301"><a href="#GraphHTML-301"><span class="linenos">301</span></a> -</span><span id="GraphHTML-302"><a href="#GraphHTML-302"><span class="linenos">302</span></a> <span class="k">def</span> <span class="nf">_repr_html_</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="GraphHTML-303"><a href="#GraphHTML-303"><span class="linenos">303</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__str__</span><span class="p">()</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="GraphHTML-227"><a href="#GraphHTML-227"><span class="linenos">227</span></a><span class="k">class</span> <span class="nc">GraphHTML</span><span class="p">:</span> +</span><span id="GraphHTML-228"><a href="#GraphHTML-228"><span class="linenos">228</span></a><span class="w"> </span><span class="sd">"""Node to HTML generator using vis.js.</span> +</span><span id="GraphHTML-229"><a href="#GraphHTML-229"><span class="linenos">229</span></a> +</span><span id="GraphHTML-230"><a href="#GraphHTML-230"><span class="linenos">230</span></a><span class="sd"> https://visjs.github.io/vis-network/docs/network/</span> +</span><span id="GraphHTML-231"><a href="#GraphHTML-231"><span class="linenos">231</span></a><span class="sd"> """</span> +</span><span id="GraphHTML-232"><a href="#GraphHTML-232"><span class="linenos">232</span></a> +</span><span id="GraphHTML-233"><a href="#GraphHTML-233"><span class="linenos">233</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="GraphHTML-234"><a href="#GraphHTML-234"><span class="linenos">234</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nodes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">edges</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">,</span> <span class="n">imports</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="GraphHTML-235"><a href="#GraphHTML-235"><span class="linenos">235</span></a> <span class="p">):</span> +</span><span id="GraphHTML-236"><a href="#GraphHTML-236"><span class="linenos">236</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> <span class="o">=</span> <span class="n">imports</span> +</span><span id="GraphHTML-237"><a href="#GraphHTML-237"><span class="linenos">237</span></a> +</span><span id="GraphHTML-238"><a href="#GraphHTML-238"><span class="linenos">238</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="GraphHTML-239"><a href="#GraphHTML-239"><span class="linenos">239</span></a> <span class="s2">"height"</span><span class="p">:</span> <span class="s2">"500px"</span><span class="p">,</span> +</span><span id="GraphHTML-240"><a href="#GraphHTML-240"><span class="linenos">240</span></a> <span class="s2">"width"</span><span class="p">:</span> <span class="s2">"100%"</span><span class="p">,</span> +</span><span id="GraphHTML-241"><a href="#GraphHTML-241"><span class="linenos">241</span></a> <span class="s2">"layout"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML-242"><a href="#GraphHTML-242"><span class="linenos">242</span></a> <span class="s2">"hierarchical"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML-243"><a href="#GraphHTML-243"><span class="linenos">243</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="GraphHTML-244"><a href="#GraphHTML-244"><span class="linenos">244</span></a> <span class="s2">"nodeSpacing"</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span> +</span><span id="GraphHTML-245"><a href="#GraphHTML-245"><span class="linenos">245</span></a> <span class="s2">"sortMethod"</span><span class="p">:</span> <span class="s2">"directed"</span><span class="p">,</span> +</span><span id="GraphHTML-246"><a href="#GraphHTML-246"><span class="linenos">246</span></a> <span class="p">},</span> +</span><span id="GraphHTML-247"><a href="#GraphHTML-247"><span class="linenos">247</span></a> <span class="p">},</span> +</span><span id="GraphHTML-248"><a href="#GraphHTML-248"><span class="linenos">248</span></a> <span class="s2">"interaction"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML-249"><a href="#GraphHTML-249"><span class="linenos">249</span></a> <span class="s2">"dragNodes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="GraphHTML-250"><a href="#GraphHTML-250"><span class="linenos">250</span></a> <span class="s2">"selectable"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="GraphHTML-251"><a href="#GraphHTML-251"><span class="linenos">251</span></a> <span class="p">},</span> +</span><span id="GraphHTML-252"><a href="#GraphHTML-252"><span class="linenos">252</span></a> <span class="s2">"physics"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML-253"><a href="#GraphHTML-253"><span class="linenos">253</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="GraphHTML-254"><a href="#GraphHTML-254"><span class="linenos">254</span></a> <span class="p">},</span> +</span><span id="GraphHTML-255"><a href="#GraphHTML-255"><span class="linenos">255</span></a> <span class="s2">"edges"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML-256"><a href="#GraphHTML-256"><span class="linenos">256</span></a> <span class="s2">"arrows"</span><span class="p">:</span> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="GraphHTML-257"><a href="#GraphHTML-257"><span class="linenos">257</span></a> <span class="p">},</span> +</span><span id="GraphHTML-258"><a href="#GraphHTML-258"><span class="linenos">258</span></a> <span class="s2">"nodes"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML-259"><a href="#GraphHTML-259"><span class="linenos">259</span></a> <span class="s2">"font"</span><span class="p">:</span> <span class="s2">"20px monaco"</span><span class="p">,</span> +</span><span id="GraphHTML-260"><a href="#GraphHTML-260"><span class="linenos">260</span></a> <span class="s2">"shape"</span><span class="p">:</span> <span class="s2">"box"</span><span class="p">,</span> +</span><span id="GraphHTML-261"><a href="#GraphHTML-261"><span class="linenos">261</span></a> <span class="s2">"widthConstraint"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML-262"><a href="#GraphHTML-262"><span class="linenos">262</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> +</span><span id="GraphHTML-263"><a href="#GraphHTML-263"><span class="linenos">263</span></a> <span class="p">},</span> +</span><span id="GraphHTML-264"><a href="#GraphHTML-264"><span class="linenos">264</span></a> <span class="p">},</span> +</span><span id="GraphHTML-265"><a href="#GraphHTML-265"><span class="linenos">265</span></a> <span class="o">**</span><span class="p">(</span><span class="n">options</span> <span class="ow">or</span> <span class="p">{}),</span> +</span><span id="GraphHTML-266"><a href="#GraphHTML-266"><span class="linenos">266</span></a> <span class="p">}</span> +</span><span id="GraphHTML-267"><a href="#GraphHTML-267"><span class="linenos">267</span></a> +</span><span id="GraphHTML-268"><a href="#GraphHTML-268"><span class="linenos">268</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="n">nodes</span> +</span><span id="GraphHTML-269"><a href="#GraphHTML-269"><span class="linenos">269</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">edges</span> <span class="o">=</span> <span class="n">edges</span> +</span><span id="GraphHTML-270"><a href="#GraphHTML-270"><span class="linenos">270</span></a> +</span><span id="GraphHTML-271"><a href="#GraphHTML-271"><span class="linenos">271</span></a> <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> +</span><span id="GraphHTML-272"><a href="#GraphHTML-272"><span class="linenos">272</span></a> <span class="n">nodes</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nodes</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span> +</span><span id="GraphHTML-273"><a href="#GraphHTML-273"><span class="linenos">273</span></a> <span class="n">edges</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">edges</span><span class="p">)</span> +</span><span id="GraphHTML-274"><a href="#GraphHTML-274"><span class="linenos">274</span></a> <span class="n">options</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="p">)</span> +</span><span id="GraphHTML-275"><a href="#GraphHTML-275"><span class="linenos">275</span></a> <span class="n">imports</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="GraphHTML-276"><a href="#GraphHTML-276"><span class="linenos">276</span></a><span class="w"> </span><span class="sd">"""<script type="text/javascript" src="https://unpkg.com/vis-data@latest/peer/umd/vis-data.min.js"></script></span> +</span><span id="GraphHTML-277"><a href="#GraphHTML-277"><span class="linenos">277</span></a><span class="sd"> <script type="text/javascript" src="https://unpkg.com/vis-network@latest/peer/umd/vis-network.min.js"></script></span> +</span><span id="GraphHTML-278"><a href="#GraphHTML-278"><span class="linenos">278</span></a><span class="sd"> <link rel="stylesheet" type="text/css" href="https://unpkg.com/vis-network/styles/vis-network.min.css" />"""</span> +</span><span id="GraphHTML-279"><a href="#GraphHTML-279"><span class="linenos">279</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> +</span><span id="GraphHTML-280"><a href="#GraphHTML-280"><span class="linenos">280</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="GraphHTML-281"><a href="#GraphHTML-281"><span class="linenos">281</span></a> <span class="p">)</span> +</span><span id="GraphHTML-282"><a href="#GraphHTML-282"><span class="linenos">282</span></a> +</span><span id="GraphHTML-283"><a href="#GraphHTML-283"><span class="linenos">283</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"""<div></span> +</span><span id="GraphHTML-284"><a href="#GraphHTML-284"><span class="linenos">284</span></a><span class="s2"> <div id="sqlglot-lineage"></div></span> +</span><span id="GraphHTML-285"><a href="#GraphHTML-285"><span class="linenos">285</span></a><span class="s2"> </span><span class="si">{</span><span class="n">imports</span><span class="si">}</span> +</span><span id="GraphHTML-286"><a href="#GraphHTML-286"><span class="linenos">286</span></a><span class="s2"> <script type="text/javascript"></span> +</span><span id="GraphHTML-287"><a href="#GraphHTML-287"><span class="linenos">287</span></a><span class="s2"> var nodes = new vis.DataSet(</span><span class="si">{</span><span class="n">nodes</span><span class="si">}</span><span class="s2">)</span> +</span><span id="GraphHTML-288"><a href="#GraphHTML-288"><span class="linenos">288</span></a><span class="s2"> nodes.forEach(row => row["title"] = new DOMParser().parseFromString(row["title"], "text/html").body.childNodes[0])</span> +</span><span id="GraphHTML-289"><a href="#GraphHTML-289"><span class="linenos">289</span></a> +</span><span id="GraphHTML-290"><a href="#GraphHTML-290"><span class="linenos">290</span></a><span class="s2"> new vis.Network(</span> +</span><span id="GraphHTML-291"><a href="#GraphHTML-291"><span class="linenos">291</span></a><span class="s2"> document.getElementById("sqlglot-lineage"),</span> +</span><span id="GraphHTML-292"><a href="#GraphHTML-292"><span class="linenos">292</span></a><span class="s2"> </span><span class="se">{{</span> +</span><span id="GraphHTML-293"><a href="#GraphHTML-293"><span class="linenos">293</span></a><span class="s2"> nodes: nodes,</span> +</span><span id="GraphHTML-294"><a href="#GraphHTML-294"><span class="linenos">294</span></a><span class="s2"> edges: new vis.DataSet(</span><span class="si">{</span><span class="n">edges</span><span class="si">}</span><span class="s2">)</span> +</span><span id="GraphHTML-295"><a href="#GraphHTML-295"><span class="linenos">295</span></a><span class="s2"> </span><span class="se">}}</span><span class="s2">,</span> +</span><span id="GraphHTML-296"><a href="#GraphHTML-296"><span class="linenos">296</span></a><span class="s2"> </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">,</span> +</span><span id="GraphHTML-297"><a href="#GraphHTML-297"><span class="linenos">297</span></a><span class="s2"> )</span> +</span><span id="GraphHTML-298"><a href="#GraphHTML-298"><span class="linenos">298</span></a><span class="s2"> </script></span> +</span><span id="GraphHTML-299"><a href="#GraphHTML-299"><span class="linenos">299</span></a><span class="s2"></div>"""</span> +</span><span id="GraphHTML-300"><a href="#GraphHTML-300"><span class="linenos">300</span></a> +</span><span id="GraphHTML-301"><a href="#GraphHTML-301"><span class="linenos">301</span></a> <span class="k">def</span> <span class="nf">_repr_html_</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="GraphHTML-302"><a href="#GraphHTML-302"><span class="linenos">302</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__str__</span><span class="p">()</span> </span></pre></div> @@ -923,43 +921,43 @@ </div> <a class="headerlink" href="#GraphHTML.__init__"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="GraphHTML.__init__-234"><a href="#GraphHTML.__init__-234"><span class="linenos">234</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> -</span><span id="GraphHTML.__init__-235"><a href="#GraphHTML.__init__-235"><span class="linenos">235</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nodes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">edges</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">,</span> <span class="n">imports</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="GraphHTML.__init__-236"><a href="#GraphHTML.__init__-236"><span class="linenos">236</span></a> <span class="p">):</span> -</span><span id="GraphHTML.__init__-237"><a href="#GraphHTML.__init__-237"><span class="linenos">237</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> <span class="o">=</span> <span class="n">imports</span> -</span><span id="GraphHTML.__init__-238"><a href="#GraphHTML.__init__-238"><span class="linenos">238</span></a> -</span><span id="GraphHTML.__init__-239"><a href="#GraphHTML.__init__-239"><span class="linenos">239</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="o">=</span> <span class="p">{</span> -</span><span id="GraphHTML.__init__-240"><a href="#GraphHTML.__init__-240"><span class="linenos">240</span></a> <span class="s2">"height"</span><span class="p">:</span> <span class="s2">"500px"</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-241"><a href="#GraphHTML.__init__-241"><span class="linenos">241</span></a> <span class="s2">"width"</span><span class="p">:</span> <span class="s2">"100%"</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-242"><a href="#GraphHTML.__init__-242"><span class="linenos">242</span></a> <span class="s2">"layout"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML.__init__-243"><a href="#GraphHTML.__init__-243"><span class="linenos">243</span></a> <span class="s2">"hierarchical"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML.__init__-244"><a href="#GraphHTML.__init__-244"><span class="linenos">244</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-245"><a href="#GraphHTML.__init__-245"><span class="linenos">245</span></a> <span class="s2">"nodeSpacing"</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-246"><a href="#GraphHTML.__init__-246"><span class="linenos">246</span></a> <span class="s2">"sortMethod"</span><span class="p">:</span> <span class="s2">"directed"</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-247"><a href="#GraphHTML.__init__-247"><span class="linenos">247</span></a> <span class="p">},</span> -</span><span id="GraphHTML.__init__-248"><a href="#GraphHTML.__init__-248"><span class="linenos">248</span></a> <span class="p">},</span> -</span><span id="GraphHTML.__init__-249"><a href="#GraphHTML.__init__-249"><span class="linenos">249</span></a> <span class="s2">"interaction"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML.__init__-250"><a href="#GraphHTML.__init__-250"><span class="linenos">250</span></a> <span class="s2">"dragNodes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-251"><a href="#GraphHTML.__init__-251"><span class="linenos">251</span></a> <span class="s2">"selectable"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-252"><a href="#GraphHTML.__init__-252"><span class="linenos">252</span></a> <span class="p">},</span> -</span><span id="GraphHTML.__init__-253"><a href="#GraphHTML.__init__-253"><span class="linenos">253</span></a> <span class="s2">"physics"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML.__init__-254"><a href="#GraphHTML.__init__-254"><span class="linenos">254</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-255"><a href="#GraphHTML.__init__-255"><span class="linenos">255</span></a> <span class="p">},</span> -</span><span id="GraphHTML.__init__-256"><a href="#GraphHTML.__init__-256"><span class="linenos">256</span></a> <span class="s2">"edges"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML.__init__-257"><a href="#GraphHTML.__init__-257"><span class="linenos">257</span></a> <span class="s2">"arrows"</span><span class="p">:</span> <span class="s2">"to"</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-258"><a href="#GraphHTML.__init__-258"><span class="linenos">258</span></a> <span class="p">},</span> -</span><span id="GraphHTML.__init__-259"><a href="#GraphHTML.__init__-259"><span class="linenos">259</span></a> <span class="s2">"nodes"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML.__init__-260"><a href="#GraphHTML.__init__-260"><span class="linenos">260</span></a> <span class="s2">"font"</span><span class="p">:</span> <span class="s2">"20px monaco"</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-261"><a href="#GraphHTML.__init__-261"><span class="linenos">261</span></a> <span class="s2">"shape"</span><span class="p">:</span> <span class="s2">"box"</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-262"><a href="#GraphHTML.__init__-262"><span class="linenos">262</span></a> <span class="s2">"widthConstraint"</span><span class="p">:</span> <span class="p">{</span> -</span><span id="GraphHTML.__init__-263"><a href="#GraphHTML.__init__-263"><span class="linenos">263</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> -</span><span id="GraphHTML.__init__-264"><a href="#GraphHTML.__init__-264"><span class="linenos">264</span></a> <span class="p">},</span> -</span><span id="GraphHTML.__init__-265"><a href="#GraphHTML.__init__-265"><span class="linenos">265</span></a> <span class="p">},</span> -</span><span id="GraphHTML.__init__-266"><a href="#GraphHTML.__init__-266"><span class="linenos">266</span></a> <span class="o">**</span><span class="p">(</span><span class="n">options</span> <span class="ow">or</span> <span class="p">{}),</span> -</span><span id="GraphHTML.__init__-267"><a href="#GraphHTML.__init__-267"><span class="linenos">267</span></a> <span class="p">}</span> -</span><span id="GraphHTML.__init__-268"><a href="#GraphHTML.__init__-268"><span class="linenos">268</span></a> -</span><span id="GraphHTML.__init__-269"><a href="#GraphHTML.__init__-269"><span class="linenos">269</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="n">nodes</span> -</span><span id="GraphHTML.__init__-270"><a href="#GraphHTML.__init__-270"><span class="linenos">270</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">edges</span> <span class="o">=</span> <span class="n">edges</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="GraphHTML.__init__-233"><a href="#GraphHTML.__init__-233"><span class="linenos">233</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span> +</span><span id="GraphHTML.__init__-234"><a href="#GraphHTML.__init__-234"><span class="linenos">234</span></a> <span class="bp">self</span><span class="p">,</span> <span class="n">nodes</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">,</span> <span class="n">edges</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">List</span><span class="p">,</span> <span class="n">imports</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> <span class="n">options</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">Dict</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="GraphHTML.__init__-235"><a href="#GraphHTML.__init__-235"><span class="linenos">235</span></a> <span class="p">):</span> +</span><span id="GraphHTML.__init__-236"><a href="#GraphHTML.__init__-236"><span class="linenos">236</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">imports</span> <span class="o">=</span> <span class="n">imports</span> +</span><span id="GraphHTML.__init__-237"><a href="#GraphHTML.__init__-237"><span class="linenos">237</span></a> +</span><span id="GraphHTML.__init__-238"><a href="#GraphHTML.__init__-238"><span class="linenos">238</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="o">=</span> <span class="p">{</span> +</span><span id="GraphHTML.__init__-239"><a href="#GraphHTML.__init__-239"><span class="linenos">239</span></a> <span class="s2">"height"</span><span class="p">:</span> <span class="s2">"500px"</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-240"><a href="#GraphHTML.__init__-240"><span class="linenos">240</span></a> <span class="s2">"width"</span><span class="p">:</span> <span class="s2">"100%"</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-241"><a href="#GraphHTML.__init__-241"><span class="linenos">241</span></a> <span class="s2">"layout"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML.__init__-242"><a href="#GraphHTML.__init__-242"><span class="linenos">242</span></a> <span class="s2">"hierarchical"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML.__init__-243"><a href="#GraphHTML.__init__-243"><span class="linenos">243</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-244"><a href="#GraphHTML.__init__-244"><span class="linenos">244</span></a> <span class="s2">"nodeSpacing"</span><span class="p">:</span> <span class="mi">200</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-245"><a href="#GraphHTML.__init__-245"><span class="linenos">245</span></a> <span class="s2">"sortMethod"</span><span class="p">:</span> <span class="s2">"directed"</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-246"><a href="#GraphHTML.__init__-246"><span class="linenos">246</span></a> <span class="p">},</span> +</span><span id="GraphHTML.__init__-247"><a href="#GraphHTML.__init__-247"><span class="linenos">247</span></a> <span class="p">},</span> +</span><span id="GraphHTML.__init__-248"><a href="#GraphHTML.__init__-248"><span class="linenos">248</span></a> <span class="s2">"interaction"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML.__init__-249"><a href="#GraphHTML.__init__-249"><span class="linenos">249</span></a> <span class="s2">"dragNodes"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-250"><a href="#GraphHTML.__init__-250"><span class="linenos">250</span></a> <span class="s2">"selectable"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-251"><a href="#GraphHTML.__init__-251"><span class="linenos">251</span></a> <span class="p">},</span> +</span><span id="GraphHTML.__init__-252"><a href="#GraphHTML.__init__-252"><span class="linenos">252</span></a> <span class="s2">"physics"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML.__init__-253"><a href="#GraphHTML.__init__-253"><span class="linenos">253</span></a> <span class="s2">"enabled"</span><span class="p">:</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-254"><a href="#GraphHTML.__init__-254"><span class="linenos">254</span></a> <span class="p">},</span> +</span><span id="GraphHTML.__init__-255"><a href="#GraphHTML.__init__-255"><span class="linenos">255</span></a> <span class="s2">"edges"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML.__init__-256"><a href="#GraphHTML.__init__-256"><span class="linenos">256</span></a> <span class="s2">"arrows"</span><span class="p">:</span> <span class="s2">"to"</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-257"><a href="#GraphHTML.__init__-257"><span class="linenos">257</span></a> <span class="p">},</span> +</span><span id="GraphHTML.__init__-258"><a href="#GraphHTML.__init__-258"><span class="linenos">258</span></a> <span class="s2">"nodes"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML.__init__-259"><a href="#GraphHTML.__init__-259"><span class="linenos">259</span></a> <span class="s2">"font"</span><span class="p">:</span> <span class="s2">"20px monaco"</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-260"><a href="#GraphHTML.__init__-260"><span class="linenos">260</span></a> <span class="s2">"shape"</span><span class="p">:</span> <span class="s2">"box"</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-261"><a href="#GraphHTML.__init__-261"><span class="linenos">261</span></a> <span class="s2">"widthConstraint"</span><span class="p">:</span> <span class="p">{</span> +</span><span id="GraphHTML.__init__-262"><a href="#GraphHTML.__init__-262"><span class="linenos">262</span></a> <span class="s2">"maximum"</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> +</span><span id="GraphHTML.__init__-263"><a href="#GraphHTML.__init__-263"><span class="linenos">263</span></a> <span class="p">},</span> +</span><span id="GraphHTML.__init__-264"><a href="#GraphHTML.__init__-264"><span class="linenos">264</span></a> <span class="p">},</span> +</span><span id="GraphHTML.__init__-265"><a href="#GraphHTML.__init__-265"><span class="linenos">265</span></a> <span class="o">**</span><span class="p">(</span><span class="n">options</span> <span class="ow">or</span> <span class="p">{}),</span> +</span><span id="GraphHTML.__init__-266"><a href="#GraphHTML.__init__-266"><span class="linenos">266</span></a> <span class="p">}</span> +</span><span id="GraphHTML.__init__-267"><a href="#GraphHTML.__init__-267"><span class="linenos">267</span></a> +</span><span id="GraphHTML.__init__-268"><a href="#GraphHTML.__init__-268"><span class="linenos">268</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">nodes</span> <span class="o">=</span> <span class="n">nodes</span> +</span><span id="GraphHTML.__init__-269"><a href="#GraphHTML.__init__-269"><span class="linenos">269</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">edges</span> <span class="o">=</span> <span class="n">edges</span> </span></pre></div> |