diff options
Diffstat (limited to '')
-rw-r--r-- | docs/sqlglot/optimizer/qualify_columns.html | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/sqlglot/optimizer/qualify_columns.html b/docs/sqlglot/optimizer/qualify_columns.html index 2fc7401..103e1e0 100644 --- a/docs/sqlglot/optimizer/qualify_columns.html +++ b/docs/sqlglot/optimizer/qualify_columns.html @@ -280,13 +280,13 @@ </span><span id="L-192"><a href="#L-192"><span class="linenos">192</span></a> <span class="k">if</span> <span class="n">table</span> <span class="ow">and</span> <span class="p">(</span><span class="ow">not</span> <span class="n">alias_expr</span> <span class="ow">or</span> <span class="n">double_agg</span><span class="p">):</span> </span><span id="L-193"><a href="#L-193"><span class="linenos">193</span></a> <span class="n">column</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"table"</span><span class="p">,</span> <span class="n">table</span><span class="p">)</span> </span><span id="L-194"><a href="#L-194"><span class="linenos">194</span></a> <span class="k">elif</span> <span class="ow">not</span> <span class="n">column</span><span class="o">.</span><span class="n">table</span> <span class="ow">and</span> <span class="n">alias_expr</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">double_agg</span><span class="p">:</span> -</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">alias_expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">):</span> +</span><span id="L-195"><a href="#L-195"><span class="linenos">195</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">alias_expr</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">literal_index</span> <span class="ow">or</span> <span class="n">resolve_table</span><span class="p">):</span> </span><span id="L-196"><a href="#L-196"><span class="linenos">196</span></a> <span class="k">if</span> <span class="n">literal_index</span><span class="p">:</span> </span><span id="L-197"><a href="#L-197"><span class="linenos">197</span></a> <span class="n">column</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="o">.</span><span class="n">number</span><span class="p">(</span><span class="n">i</span><span class="p">))</span> </span><span id="L-198"><a href="#L-198"><span class="linenos">198</span></a> <span class="k">else</span><span class="p">:</span> </span><span id="L-199"><a href="#L-199"><span class="linenos">199</span></a> <span class="n">column</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">alias_expr</span><span class="o">.</span><span class="n">copy</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="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">projection</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">selects</span><span class="p">):</span> +</span><span id="L-201"><a href="#L-201"><span class="linenos">201</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">projection</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-202"><a href="#L-202"><span class="linenos">202</span></a> <span class="n">replace_columns</span><span class="p">(</span><span class="n">projection</span><span class="p">)</span> </span><span id="L-203"><a href="#L-203"><span class="linenos">203</span></a> </span><span id="L-204"><a href="#L-204"><span class="linenos">204</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">projection</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">):</span> @@ -327,7 +327,7 @@ </span><span id="L-239"><a href="#L-239"><span class="linenos">239</span></a> <span class="n">ordered</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"this"</span><span class="p">,</span> <span class="n">new_expression</span><span class="p">)</span> </span><span id="L-240"><a href="#L-240"><span class="linenos">240</span></a> </span><span id="L-241"><a href="#L-241"><span class="linenos">241</span></a> <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">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"group"</span><span class="p">):</span> -</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">{</span><span class="n">s</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> <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">selects</span><span class="p">}</span> +</span><span id="L-242"><a href="#L-242"><span class="linenos">242</span></a> <span class="n">selects</span> <span class="o">=</span> <span class="p">{</span><span class="n">s</span><span class="o">.</span><span class="n">this</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">column</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">alias_or_name</span><span class="p">)</span> <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">expression</span><span class="o">.</span><span class="n">selects</span><span class="p">}</span> </span><span id="L-243"><a href="#L-243"><span class="linenos">243</span></a> </span><span id="L-244"><a href="#L-244"><span class="linenos">244</span></a> <span class="k">for</span> <span class="n">ordered</span> <span class="ow">in</span> <span class="n">ordereds</span><span class="p">:</span> </span><span id="L-245"><a href="#L-245"><span class="linenos">245</span></a> <span class="n">ordered</span> <span class="o">=</span> <span class="n">ordered</span><span class="o">.</span><span class="n">this</span> @@ -358,7 +358,7 @@ </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="nf">_select_by_pos</span><span class="p">(</span><span class="n">scope</span><span class="p">:</span> <span class="n">Scope</span><span class="p">,</span> <span class="n">node</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Literal</span><span class="p">)</span> <span class="o">-></span> <span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">:</span> </span><span id="L-272"><a href="#L-272"><span class="linenos">272</span></a> <span class="k">try</span><span class="p">:</span> -</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="k">return</span> <span class="n">scope</span><span class="o">.</span><span class="n">selects</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">assert_is</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> +</span><span id="L-273"><a href="#L-273"><span class="linenos">273</span></a> <span class="k">return</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 class="nb">int</span><span class="p">(</span><span class="n">node</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">assert_is</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">Alias</span><span class="p">)</span> </span><span id="L-274"><a href="#L-274"><span class="linenos">274</span></a> <span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span> </span><span id="L-275"><a href="#L-275"><span class="linenos">275</span></a> <span class="k">raise</span> <span class="n">OptimizeError</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unknown output column: </span><span class="si">{</span><span class="n">node</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> </span><span id="L-276"><a href="#L-276"><span class="linenos">276</span></a> @@ -435,7 +435,7 @@ </span><span id="L-347"><a href="#L-347"><span class="linenos">347</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">pivot_output_columns</span><span class="p">:</span> </span><span id="L-348"><a href="#L-348"><span class="linenos">348</span></a> <span class="n">pivot_output_columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">col</span><span class="o">.</span><span class="n">alias_or_name</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">pivot</span><span class="o">.</span><span class="n">expressions</span><span class="p">]</span> </span><span id="L-349"><a href="#L-349"><span class="linenos">349</span></a> -</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="k">for</span> <span class="n">expression</span> <span class="ow">in</span> <span class="n">scope</span><span class="o">.</span><span class="n">selects</span><span class="p">:</span> +</span><span id="L-350"><a href="#L-350"><span class="linenos">350</span></a> <span class="k">for</span> <span class="n">expression</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="p">:</span> </span><span id="L-351"><a href="#L-351"><span class="linenos">351</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Star</span><span class="p">):</span> </span><span id="L-352"><a href="#L-352"><span class="linenos">352</span></a> <span class="n">tables</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">selected_sources</span><span class="p">)</span> </span><span id="L-353"><a href="#L-353"><span class="linenos">353</span></a> <span class="n">_add_except_columns</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">tables</span><span class="p">,</span> <span class="n">except_columns</span><span class="p">)</span> @@ -534,7 +534,7 @@ </span><span id="L-446"><a href="#L-446"><span class="linenos">446</span></a> <span class="n">new_selections</span> <span class="o">=</span> <span class="p">[]</span> </span><span id="L-447"><a href="#L-447"><span class="linenos">447</span></a> </span><span id="L-448"><a href="#L-448"><span class="linenos">448</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">selection</span><span class="p">,</span> <span class="n">aliased_column</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span> -</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> <span class="n">itertools</span><span class="o">.</span><span class="n">zip_longest</span><span class="p">(</span><span class="n">scope</span><span class="o">.</span><span class="n">selects</span><span class="p">,</span> <span class="n">scope</span><span class="o">.</span><span class="n">outer_column_list</span><span class="p">)</span> +</span><span id="L-449"><a href="#L-449"><span class="linenos">449</span></a> <span class="n">itertools</span><span class="o">.</span><span class="n">zip_longest</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 class="n">scope</span><span class="o">.</span><span class="n">outer_column_list</span><span class="p">)</span> </span><span id="L-450"><a href="#L-450"><span class="linenos">450</span></a> <span class="p">):</span> </span><span id="L-451"><a href="#L-451"><span class="linenos">451</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">selection</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Subquery</span><span class="p">):</span> </span><span id="L-452"><a href="#L-452"><span class="linenos">452</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">selection</span><span class="o">.</span><span class="n">output_name</span><span class="p">:</span> |