diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-16 11:37:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-16 11:37:35 +0000 |
commit | 45eab59f38aae326a4970767f9bc7119bef339b9 (patch) | |
tree | f5a21c1bba9fd891c923cc14206986691931ca47 /docs/sqlglot/generator.html | |
parent | Adding upstream version 18.11.6. (diff) | |
download | sqlglot-45eab59f38aae326a4970767f9bc7119bef339b9.tar.xz sqlglot-45eab59f38aae326a4970767f9bc7119bef339b9.zip |
Adding upstream version 18.13.0.upstream/18.13.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs/sqlglot/generator.html')
-rw-r--r-- | docs/sqlglot/generator.html | 4051 |
1 files changed, 2047 insertions, 2004 deletions
diff --git a/docs/sqlglot/generator.html b/docs/sqlglot/generator.html index 416b170..c2628c1 100644 --- a/docs/sqlglot/generator.html +++ b/docs/sqlglot/generator.html @@ -772,6 +772,9 @@ <a class="function" href="#Generator.jsoncolumndef_sql">jsoncolumndef_sql</a> </li> <li> + <a class="function" href="#Generator.jsonschema_sql">jsonschema_sql</a> + </li> + <li> <a class="function" href="#Generator.jsontable_sql">jsontable_sql</a> </li> <li> @@ -3299,738 +3302,746 @@ </span><span id="L-2179"><a href="#L-2179"><span class="linenos">2179</span></a> <span class="p">)</span> </span><span id="L-2180"><a href="#L-2180"><span class="linenos">2180</span></a> </span><span id="L-2181"><a href="#L-2181"><span class="linenos">2181</span></a> <span class="k">def</span> <span class="nf">jsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">JSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2183"><a href="#L-2183"><span class="linenos">2183</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PATH </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2187"><a href="#L-2187"><span class="linenos">2187</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2182"><a href="#L-2182"><span class="linenos">2182</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="L-2183"><a href="#L-2183"><span class="linenos">2183</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PATH </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2184"><a href="#L-2184"><span class="linenos">2184</span></a> <span class="n">nested_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"nested_schema"</span><span class="p">)</span> +</span><span id="L-2185"><a href="#L-2185"><span class="linenos">2185</span></a> +</span><span id="L-2186"><a href="#L-2186"><span class="linenos">2186</span></a> <span class="k">if</span> <span class="n">nested_schema</span><span class="p">:</span> +</span><span id="L-2187"><a href="#L-2187"><span class="linenos">2187</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NESTED</span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">nested_schema</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2188"><a href="#L-2188"><span class="linenos">2188</span></a> -</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</span></a> <span class="k">def</span> <span class="nf">jsontable_sql</span><span class="p">(</span><span class="bp">self</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">JSONTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2190"><a href="#L-2190"><span class="linenos">2190</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="L-2192"><a href="#L-2192"><span class="linenos">2192</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2193"><a href="#L-2193"><span class="linenos">2193</span></a> <span class="n">error_handling</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">"error_handling"</span><span class="p">)</span> -</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> <span class="n">error_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">error_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">error_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> <span class="n">empty_handling</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">"empty_handling"</span><span class="p">)</span> -</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> <span class="n">empty_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">empty_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLUMNS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> <span class="s2">"JSON_TABLE"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">path</span><span class="si">}{</span><span class="n">error_handling</span><span class="si">}{</span><span class="n">empty_handling</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> <span class="p">)</span> -</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a> -</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</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">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2189"><a href="#L-2189"><span class="linenos">2189</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2190"><a href="#L-2190"><span class="linenos">2190</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-2191"><a href="#L-2191"><span class="linenos">2191</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2192"><a href="#L-2192"><span class="linenos">2192</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2193"><a href="#L-2193"><span class="linenos">2193</span></a> +</span><span id="L-2194"><a href="#L-2194"><span class="linenos">2194</span></a> <span class="k">def</span> <span class="nf">jsonschema_sql</span><span class="p">(</span><span class="bp">self</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">JSONSchema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2195"><a href="#L-2195"><span class="linenos">2195</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COLUMNS"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2196"><a href="#L-2196"><span class="linenos">2196</span></a> +</span><span id="L-2197"><a href="#L-2197"><span class="linenos">2197</span></a> <span class="k">def</span> <span class="nf">jsontable_sql</span><span class="p">(</span><span class="bp">self</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">JSONTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2198"><a href="#L-2198"><span class="linenos">2198</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2199"><a href="#L-2199"><span class="linenos">2199</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="L-2200"><a href="#L-2200"><span class="linenos">2200</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2201"><a href="#L-2201"><span class="linenos">2201</span></a> <span class="n">error_handling</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">"error_handling"</span><span class="p">)</span> +</span><span id="L-2202"><a href="#L-2202"><span class="linenos">2202</span></a> <span class="n">error_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">error_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">error_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2203"><a href="#L-2203"><span class="linenos">2203</span></a> <span class="n">empty_handling</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">"empty_handling"</span><span class="p">)</span> +</span><span id="L-2204"><a href="#L-2204"><span class="linenos">2204</span></a> <span class="n">empty_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">empty_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2205"><a href="#L-2205"><span class="linenos">2205</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="L-2206"><a href="#L-2206"><span class="linenos">2206</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="L-2207"><a href="#L-2207"><span class="linenos">2207</span></a> <span class="s2">"JSON_TABLE"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">path</span><span class="si">}{</span><span class="n">error_handling</span><span class="si">}{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2208"><a href="#L-2208"><span class="linenos">2208</span></a> <span class="p">)</span> </span><span id="L-2209"><a href="#L-2209"><span class="linenos">2209</span></a> -</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2210"><a href="#L-2210"><span class="linenos">2210</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-2211"><a href="#L-2211"><span class="linenos">2211</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2219"><a href="#L-2219"><span class="linenos">2219</span></a> <span class="p">)</span> -</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a> -</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</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">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a> <span class="n">query</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">"query"</span><span class="p">)</span> -</span><span id="L-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <span class="n">unnest</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">"unnest"</span><span class="p">)</span> -</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> <span class="n">field</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">"field"</span><span class="p">)</span> -</span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</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">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> -</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> -</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> -</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> -</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</span></a> -</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> -</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> -</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> -</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> -</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> -</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> -</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> -</span><span id="L-2255"><a href="#L-2255"><span class="linenos">2255</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> -</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2258"><a href="#L-2258"><span class="linenos">2258</span></a> -</span><span id="L-2259"><a href="#L-2259"><span class="linenos">2259</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</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">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2260"><a href="#L-2260"><span class="linenos">2260</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2261"><a href="#L-2261"><span class="linenos">2261</span></a> -</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</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">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2264"><a href="#L-2264"><span class="linenos">2264</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2265"><a href="#L-2265"><span class="linenos">2265</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2268"><a href="#L-2268"><span class="linenos">2268</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2212"><a href="#L-2212"><span class="linenos">2212</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-2213"><a href="#L-2213"><span class="linenos">2213</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="L-2214"><a href="#L-2214"><span class="linenos">2214</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2215"><a href="#L-2215"><span class="linenos">2215</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</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">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2216"><a href="#L-2216"><span class="linenos">2216</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2217"><a href="#L-2217"><span class="linenos">2217</span></a> +</span><span id="L-2218"><a href="#L-2218"><span class="linenos">2218</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2219"><a href="#L-2219"><span class="linenos">2219</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2220"><a href="#L-2220"><span class="linenos">2220</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="L-2221"><a href="#L-2221"><span class="linenos">2221</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2222"><a href="#L-2222"><span class="linenos">2222</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2223"><a href="#L-2223"><span class="linenos">2223</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2224"><a href="#L-2224"><span class="linenos">2224</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2225"><a href="#L-2225"><span class="linenos">2225</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="L-2226"><a href="#L-2226"><span class="linenos">2226</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2227"><a href="#L-2227"><span class="linenos">2227</span></a> <span class="p">)</span> +</span><span id="L-2228"><a href="#L-2228"><span class="linenos">2228</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2229"><a href="#L-2229"><span class="linenos">2229</span></a> +</span><span id="L-2230"><a href="#L-2230"><span class="linenos">2230</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</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">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2231"><a href="#L-2231"><span class="linenos">2231</span></a> <span class="n">query</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">"query"</span><span class="p">)</span> +</span><span id="L-2232"><a href="#L-2232"><span class="linenos">2232</span></a> <span class="n">unnest</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">"unnest"</span><span class="p">)</span> +</span><span id="L-2233"><a href="#L-2233"><span class="linenos">2233</span></a> <span class="n">field</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">"field"</span><span class="p">)</span> +</span><span id="L-2234"><a href="#L-2234"><span class="linenos">2234</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</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">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2235"><a href="#L-2235"><span class="linenos">2235</span></a> +</span><span id="L-2236"><a href="#L-2236"><span class="linenos">2236</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="L-2237"><a href="#L-2237"><span class="linenos">2237</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> +</span><span id="L-2238"><a href="#L-2238"><span class="linenos">2238</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="L-2239"><a href="#L-2239"><span class="linenos">2239</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> +</span><span id="L-2240"><a href="#L-2240"><span class="linenos">2240</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="L-2241"><a href="#L-2241"><span class="linenos">2241</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> +</span><span id="L-2242"><a href="#L-2242"><span class="linenos">2242</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2243"><a href="#L-2243"><span class="linenos">2243</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2244"><a href="#L-2244"><span class="linenos">2244</span></a> +</span><span id="L-2245"><a href="#L-2245"><span class="linenos">2245</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2246"><a href="#L-2246"><span class="linenos">2246</span></a> +</span><span id="L-2247"><a href="#L-2247"><span class="linenos">2247</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2248"><a href="#L-2248"><span class="linenos">2248</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2249"><a href="#L-2249"><span class="linenos">2249</span></a> +</span><span id="L-2250"><a href="#L-2250"><span class="linenos">2250</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2251"><a href="#L-2251"><span class="linenos">2251</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="L-2252"><a href="#L-2252"><span class="linenos">2252</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> +</span><span id="L-2253"><a href="#L-2253"><span class="linenos">2253</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> +</span><span id="L-2254"><a href="#L-2254"><span class="linenos">2254</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2255"><a href="#L-2255"><span class="linenos">2255</span></a> +</span><span id="L-2256"><a href="#L-2256"><span class="linenos">2256</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> +</span><span id="L-2257"><a href="#L-2257"><span class="linenos">2257</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2258"><a href="#L-2258"><span class="linenos">2258</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2259"><a href="#L-2259"><span class="linenos">2259</span></a> +</span><span id="L-2260"><a href="#L-2260"><span class="linenos">2260</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2261"><a href="#L-2261"><span class="linenos">2261</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="L-2262"><a href="#L-2262"><span class="linenos">2262</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> +</span><span id="L-2263"><a href="#L-2263"><span class="linenos">2263</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2264"><a href="#L-2264"><span class="linenos">2264</span></a> +</span><span id="L-2265"><a href="#L-2265"><span class="linenos">2265</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2266"><a href="#L-2266"><span class="linenos">2266</span></a> +</span><span id="L-2267"><a href="#L-2267"><span class="linenos">2267</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</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">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2268"><a href="#L-2268"><span class="linenos">2268</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2269"><a href="#L-2269"><span class="linenos">2269</span></a> -</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</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">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2271"><a href="#L-2271"><span class="linenos">2271</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2272"><a href="#L-2272"><span class="linenos">2272</span></a> -</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</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">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</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-2275"><a href="#L-2275"><span class="linenos">2275</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2276"><a href="#L-2276"><span class="linenos">2276</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="L-2278"><a href="#L-2278"><span class="linenos">2278</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2279"><a href="#L-2279"><span class="linenos">2279</span></a> -</span><span id="L-2280"><a href="#L-2280"><span class="linenos">2280</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-2281"><a href="#L-2281"><span class="linenos">2281</span></a> -</span><span id="L-2282"><a href="#L-2282"><span class="linenos">2282</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</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">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2283"><a href="#L-2283"><span class="linenos">2283</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> -</span><span id="L-2284"><a href="#L-2284"><span class="linenos">2284</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2286"><a href="#L-2286"><span class="linenos">2286</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2270"><a href="#L-2270"><span class="linenos">2270</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</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">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2271"><a href="#L-2271"><span class="linenos">2271</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2272"><a href="#L-2272"><span class="linenos">2272</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2273"><a href="#L-2273"><span class="linenos">2273</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2274"><a href="#L-2274"><span class="linenos">2274</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-2275"><a href="#L-2275"><span class="linenos">2275</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2276"><a href="#L-2276"><span class="linenos">2276</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2277"><a href="#L-2277"><span class="linenos">2277</span></a> +</span><span id="L-2278"><a href="#L-2278"><span class="linenos">2278</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</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">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2279"><a href="#L-2279"><span class="linenos">2279</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2280"><a href="#L-2280"><span class="linenos">2280</span></a> +</span><span id="L-2281"><a href="#L-2281"><span class="linenos">2281</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</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">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2282"><a href="#L-2282"><span class="linenos">2282</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</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-2283"><a href="#L-2283"><span class="linenos">2283</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2284"><a href="#L-2284"><span class="linenos">2284</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2285"><a href="#L-2285"><span class="linenos">2285</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="L-2286"><a href="#L-2286"><span class="linenos">2286</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2287"><a href="#L-2287"><span class="linenos">2287</span></a> -</span><span id="L-2288"><a href="#L-2288"><span class="linenos">2288</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</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">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2289"><a href="#L-2289"><span class="linenos">2289</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2290"><a href="#L-2290"><span class="linenos">2290</span></a> -</span><span id="L-2291"><a href="#L-2291"><span class="linenos">2291</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</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">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2292"><a href="#L-2292"><span class="linenos">2292</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="L-2293"><a href="#L-2293"><span class="linenos">2293</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2288"><a href="#L-2288"><span class="linenos">2288</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-2289"><a href="#L-2289"><span class="linenos">2289</span></a> +</span><span id="L-2290"><a href="#L-2290"><span class="linenos">2290</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</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">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2291"><a href="#L-2291"><span class="linenos">2291</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> +</span><span id="L-2292"><a href="#L-2292"><span class="linenos">2292</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2293"><a href="#L-2293"><span class="linenos">2293</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2294"><a href="#L-2294"><span class="linenos">2294</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2295"><a href="#L-2295"><span class="linenos">2295</span></a> -</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</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">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2296"><a href="#L-2296"><span class="linenos">2296</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</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">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2297"><a href="#L-2297"><span class="linenos">2297</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2298"><a href="#L-2298"><span class="linenos">2298</span></a> -</span><span id="L-2299"><a href="#L-2299"><span class="linenos">2299</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</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">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2301"><a href="#L-2301"><span class="linenos">2301</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> -</span><span id="L-2302"><a href="#L-2302"><span class="linenos">2302</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2299"><a href="#L-2299"><span class="linenos">2299</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</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">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2300"><a href="#L-2300"><span class="linenos">2300</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="L-2301"><a href="#L-2301"><span class="linenos">2301</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2302"><a href="#L-2302"><span class="linenos">2302</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2303"><a href="#L-2303"><span class="linenos">2303</span></a> -</span><span id="L-2304"><a href="#L-2304"><span class="linenos">2304</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</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">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2305"><a href="#L-2305"><span class="linenos">2305</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> +</span><span id="L-2304"><a href="#L-2304"><span class="linenos">2304</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</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">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2305"><a href="#L-2305"><span class="linenos">2305</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span><span id="L-2306"><a href="#L-2306"><span class="linenos">2306</span></a> -</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</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">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2308"><a href="#L-2308"><span class="linenos">2308</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> -</span><span id="L-2309"><a href="#L-2309"><span class="linenos">2309</span></a> -</span><span id="L-2310"><a href="#L-2310"><span class="linenos">2310</span></a> <span class="k">def</span> <span class="nf">xor_sql</span><span class="p">(</span><span class="bp">self</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">Xor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"XOR"</span><span class="p">)</span> -</span><span id="L-2312"><a href="#L-2312"><span class="linenos">2312</span></a> -</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</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">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="L-2315"><a href="#L-2315"><span class="linenos">2315</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> -</span><span id="L-2316"><a href="#L-2316"><span class="linenos">2316</span></a> -</span><span id="L-2317"><a href="#L-2317"><span class="linenos">2317</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="L-2318"><a href="#L-2318"><span class="linenos">2318</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="L-2319"><a href="#L-2319"><span class="linenos">2319</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</span></a> <span class="p">)</span> -</span><span id="L-2321"><a href="#L-2321"><span class="linenos">2321</span></a> -</span><span id="L-2322"><a href="#L-2322"><span class="linenos">2322</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> +</span><span id="L-2307"><a href="#L-2307"><span class="linenos">2307</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</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">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2308"><a href="#L-2308"><span class="linenos">2308</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2309"><a href="#L-2309"><span class="linenos">2309</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> +</span><span id="L-2310"><a href="#L-2310"><span class="linenos">2310</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2311"><a href="#L-2311"><span class="linenos">2311</span></a> +</span><span id="L-2312"><a href="#L-2312"><span class="linenos">2312</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</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">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2313"><a href="#L-2313"><span class="linenos">2313</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> +</span><span id="L-2314"><a href="#L-2314"><span class="linenos">2314</span></a> +</span><span id="L-2315"><a href="#L-2315"><span class="linenos">2315</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</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">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2316"><a href="#L-2316"><span class="linenos">2316</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> +</span><span id="L-2317"><a href="#L-2317"><span class="linenos">2317</span></a> +</span><span id="L-2318"><a href="#L-2318"><span class="linenos">2318</span></a> <span class="k">def</span> <span class="nf">xor_sql</span><span class="p">(</span><span class="bp">self</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">Xor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2319"><a href="#L-2319"><span class="linenos">2319</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"XOR"</span><span class="p">)</span> +</span><span id="L-2320"><a href="#L-2320"><span class="linenos">2320</span></a> +</span><span id="L-2321"><a href="#L-2321"><span class="linenos">2321</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</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">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2322"><a href="#L-2322"><span class="linenos">2322</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="L-2323"><a href="#L-2323"><span class="linenos">2323</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> </span><span id="L-2324"><a href="#L-2324"><span class="linenos">2324</span></a> -</span><span id="L-2325"><a href="#L-2325"><span class="linenos">2325</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> -</span><span id="L-2327"><a href="#L-2327"><span class="linenos">2327</span></a> -</span><span id="L-2328"><a href="#L-2328"><span class="linenos">2328</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2329"><a href="#L-2329"><span class="linenos">2329</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> -</span><span id="L-2330"><a href="#L-2330"><span class="linenos">2330</span></a> -</span><span id="L-2331"><a href="#L-2331"><span class="linenos">2331</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</span></a> -</span><span id="L-2334"><a href="#L-2334"><span class="linenos">2334</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> -</span><span id="L-2336"><a href="#L-2336"><span class="linenos">2336</span></a> -</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2338"><a href="#L-2338"><span class="linenos">2338</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> -</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</span></a> -</span><span id="L-2340"><a href="#L-2340"><span class="linenos">2340</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2341"><a href="#L-2341"><span class="linenos">2341</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> -</span><span id="L-2342"><a href="#L-2342"><span class="linenos">2342</span></a> -</span><span id="L-2343"><a href="#L-2343"><span class="linenos">2343</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</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">Cast</span><span class="p">,</span> <span class="n">safe_prefix</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2344"><a href="#L-2344"><span class="linenos">2344</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">)</span> -</span><span id="L-2345"><a href="#L-2345"><span class="linenos">2345</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FORMAT </span><span class="si">{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">format_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">safe_prefix</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2325"><a href="#L-2325"><span class="linenos">2325</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="L-2326"><a href="#L-2326"><span class="linenos">2326</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="L-2327"><a href="#L-2327"><span class="linenos">2327</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="L-2328"><a href="#L-2328"><span class="linenos">2328</span></a> <span class="p">)</span> +</span><span id="L-2329"><a href="#L-2329"><span class="linenos">2329</span></a> +</span><span id="L-2330"><a href="#L-2330"><span class="linenos">2330</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-2331"><a href="#L-2331"><span class="linenos">2331</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> +</span><span id="L-2332"><a href="#L-2332"><span class="linenos">2332</span></a> +</span><span id="L-2333"><a href="#L-2333"><span class="linenos">2333</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2334"><a href="#L-2334"><span class="linenos">2334</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> +</span><span id="L-2335"><a href="#L-2335"><span class="linenos">2335</span></a> +</span><span id="L-2336"><a href="#L-2336"><span class="linenos">2336</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2337"><a href="#L-2337"><span class="linenos">2337</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> +</span><span id="L-2338"><a href="#L-2338"><span class="linenos">2338</span></a> +</span><span id="L-2339"><a href="#L-2339"><span class="linenos">2339</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2340"><a href="#L-2340"><span class="linenos">2340</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2341"><a href="#L-2341"><span class="linenos">2341</span></a> +</span><span id="L-2342"><a href="#L-2342"><span class="linenos">2342</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2343"><a href="#L-2343"><span class="linenos">2343</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> +</span><span id="L-2344"><a href="#L-2344"><span class="linenos">2344</span></a> +</span><span id="L-2345"><a href="#L-2345"><span class="linenos">2345</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2346"><a href="#L-2346"><span class="linenos">2346</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> </span><span id="L-2347"><a href="#L-2347"><span class="linenos">2347</span></a> -</span><span id="L-2348"><a href="#L-2348"><span class="linenos">2348</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</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">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2349"><a href="#L-2349"><span class="linenos">2349</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2350"><a href="#L-2350"><span class="linenos">2350</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> -</span><span id="L-2351"><a href="#L-2351"><span class="linenos">2351</span></a> -</span><span id="L-2352"><a href="#L-2352"><span class="linenos">2352</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</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">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2353"><a href="#L-2353"><span class="linenos">2353</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLLATE_IS_FUNC</span><span class="p">:</span> -</span><span id="L-2354"><a href="#L-2354"><span class="linenos">2354</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> -</span><span id="L-2356"><a href="#L-2356"><span class="linenos">2356</span></a> -</span><span id="L-2357"><a href="#L-2357"><span class="linenos">2357</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</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">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2348"><a href="#L-2348"><span class="linenos">2348</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2349"><a href="#L-2349"><span class="linenos">2349</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> +</span><span id="L-2350"><a href="#L-2350"><span class="linenos">2350</span></a> +</span><span id="L-2351"><a href="#L-2351"><span class="linenos">2351</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</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">Cast</span><span class="p">,</span> <span class="n">safe_prefix</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2352"><a href="#L-2352"><span class="linenos">2352</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">)</span> +</span><span id="L-2353"><a href="#L-2353"><span class="linenos">2353</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FORMAT </span><span class="si">{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">format_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2354"><a href="#L-2354"><span class="linenos">2354</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">safe_prefix</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2355"><a href="#L-2355"><span class="linenos">2355</span></a> +</span><span id="L-2356"><a href="#L-2356"><span class="linenos">2356</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</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">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2357"><a href="#L-2357"><span class="linenos">2357</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2358"><a href="#L-2358"><span class="linenos">2358</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> </span><span id="L-2359"><a href="#L-2359"><span class="linenos">2359</span></a> -</span><span id="L-2360"><a href="#L-2360"><span class="linenos">2360</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</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">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2362"><a href="#L-2362"><span class="linenos">2362</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="L-2363"><a href="#L-2363"><span class="linenos">2363</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-2364"><a href="#L-2364"><span class="linenos">2364</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-2365"><a href="#L-2365"><span class="linenos">2365</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2366"><a href="#L-2366"><span class="linenos">2366</span></a> -</span><span id="L-2367"><a href="#L-2367"><span class="linenos">2367</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2368"><a href="#L-2368"><span class="linenos">2368</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</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">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2370"><a href="#L-2370"><span class="linenos">2370</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> -</span><span id="L-2371"><a href="#L-2371"><span class="linenos">2371</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2372"><a href="#L-2372"><span class="linenos">2372</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> -</span><span id="L-2373"><a href="#L-2373"><span class="linenos">2373</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2374"><a href="#L-2374"><span class="linenos">2374</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> -</span><span id="L-2375"><a href="#L-2375"><span class="linenos">2375</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2376"><a href="#L-2376"><span class="linenos">2376</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2377"><a href="#L-2377"><span class="linenos">2377</span></a> -</span><span id="L-2378"><a href="#L-2378"><span class="linenos">2378</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2379"><a href="#L-2379"><span class="linenos">2379</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="L-2380"><a href="#L-2380"><span class="linenos">2380</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="L-2381"><a href="#L-2381"><span class="linenos">2381</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> -</span><span id="L-2382"><a href="#L-2382"><span class="linenos">2382</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2383"><a href="#L-2383"><span class="linenos">2383</span></a> -</span><span id="L-2384"><a href="#L-2384"><span class="linenos">2384</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="L-2385"><a href="#L-2385"><span class="linenos">2385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2386"><a href="#L-2386"><span class="linenos">2386</span></a> -</span><span id="L-2387"><a href="#L-2387"><span class="linenos">2387</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</span></a> -</span><span id="L-2389"><a href="#L-2389"><span class="linenos">2389</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</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">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2390"><a href="#L-2390"><span class="linenos">2390</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> +</span><span id="L-2360"><a href="#L-2360"><span class="linenos">2360</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</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">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2361"><a href="#L-2361"><span class="linenos">2361</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLLATE_IS_FUNC</span><span class="p">:</span> +</span><span id="L-2362"><a href="#L-2362"><span class="linenos">2362</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2363"><a href="#L-2363"><span class="linenos">2363</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> +</span><span id="L-2364"><a href="#L-2364"><span class="linenos">2364</span></a> +</span><span id="L-2365"><a href="#L-2365"><span class="linenos">2365</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</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">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2366"><a href="#L-2366"><span class="linenos">2366</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2367"><a href="#L-2367"><span class="linenos">2367</span></a> +</span><span id="L-2368"><a href="#L-2368"><span class="linenos">2368</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</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">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2369"><a href="#L-2369"><span class="linenos">2369</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2370"><a href="#L-2370"><span class="linenos">2370</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="L-2371"><a href="#L-2371"><span class="linenos">2371</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-2372"><a href="#L-2372"><span class="linenos">2372</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-2373"><a href="#L-2373"><span class="linenos">2373</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2374"><a href="#L-2374"><span class="linenos">2374</span></a> +</span><span id="L-2375"><a href="#L-2375"><span class="linenos">2375</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2376"><a href="#L-2376"><span class="linenos">2376</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2377"><a href="#L-2377"><span class="linenos">2377</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</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">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2378"><a href="#L-2378"><span class="linenos">2378</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> +</span><span id="L-2379"><a href="#L-2379"><span class="linenos">2379</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2380"><a href="#L-2380"><span class="linenos">2380</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> +</span><span id="L-2381"><a href="#L-2381"><span class="linenos">2381</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2382"><a href="#L-2382"><span class="linenos">2382</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> +</span><span id="L-2383"><a href="#L-2383"><span class="linenos">2383</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2384"><a href="#L-2384"><span class="linenos">2384</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2385"><a href="#L-2385"><span class="linenos">2385</span></a> +</span><span id="L-2386"><a href="#L-2386"><span class="linenos">2386</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2387"><a href="#L-2387"><span class="linenos">2387</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="L-2388"><a href="#L-2388"><span class="linenos">2388</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="L-2389"><a href="#L-2389"><span class="linenos">2389</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> +</span><span id="L-2390"><a href="#L-2390"><span class="linenos">2390</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="L-2391"><a href="#L-2391"><span class="linenos">2391</span></a> -</span><span id="L-2392"><a href="#L-2392"><span class="linenos">2392</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</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">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2393"><a href="#L-2393"><span class="linenos">2393</span></a> <span class="n">chain</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">"chain"</span><span class="p">)</span> -</span><span id="L-2394"><a href="#L-2394"><span class="linenos">2394</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-2395"><a href="#L-2395"><span class="linenos">2395</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> +</span><span id="L-2392"><a href="#L-2392"><span class="linenos">2392</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="L-2393"><a href="#L-2393"><span class="linenos">2393</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2394"><a href="#L-2394"><span class="linenos">2394</span></a> +</span><span id="L-2395"><a href="#L-2395"><span class="linenos">2395</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2396"><a href="#L-2396"><span class="linenos">2396</span></a> -</span><span id="L-2397"><a href="#L-2397"><span class="linenos">2397</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2398"><a href="#L-2398"><span class="linenos">2398</span></a> -</span><span id="L-2399"><a href="#L-2399"><span class="linenos">2399</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</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">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2400"><a href="#L-2400"><span class="linenos">2400</span></a> <span class="n">savepoint</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">"savepoint"</span><span class="p">)</span> -</span><span id="L-2401"><a href="#L-2401"><span class="linenos">2401</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2402"><a href="#L-2402"><span class="linenos">2402</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2403"><a href="#L-2403"><span class="linenos">2403</span></a> -</span><span id="L-2404"><a href="#L-2404"><span class="linenos">2404</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</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">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2405"><a href="#L-2405"><span class="linenos">2405</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2397"><a href="#L-2397"><span class="linenos">2397</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</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">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2398"><a href="#L-2398"><span class="linenos">2398</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> +</span><span id="L-2399"><a href="#L-2399"><span class="linenos">2399</span></a> +</span><span id="L-2400"><a href="#L-2400"><span class="linenos">2400</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</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">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2401"><a href="#L-2401"><span class="linenos">2401</span></a> <span class="n">chain</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">"chain"</span><span class="p">)</span> +</span><span id="L-2402"><a href="#L-2402"><span class="linenos">2402</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-2403"><a href="#L-2403"><span class="linenos">2403</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> +</span><span id="L-2404"><a href="#L-2404"><span class="linenos">2404</span></a> +</span><span id="L-2405"><a href="#L-2405"><span class="linenos">2405</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2406"><a href="#L-2406"><span class="linenos">2406</span></a> -</span><span id="L-2407"><a href="#L-2407"><span class="linenos">2407</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> -</span><span id="L-2408"><a href="#L-2408"><span class="linenos">2408</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="L-2409"><a href="#L-2409"><span class="linenos">2409</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="L-2410"><a href="#L-2410"><span class="linenos">2410</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2411"><a href="#L-2411"><span class="linenos">2411</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="L-2412"><a href="#L-2412"><span class="linenos">2412</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2413"><a href="#L-2413"><span class="linenos">2413</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DATA TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2407"><a href="#L-2407"><span class="linenos">2407</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</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">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2408"><a href="#L-2408"><span class="linenos">2408</span></a> <span class="n">savepoint</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">"savepoint"</span><span class="p">)</span> +</span><span id="L-2409"><a href="#L-2409"><span class="linenos">2409</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2410"><a href="#L-2410"><span class="linenos">2410</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2411"><a href="#L-2411"><span class="linenos">2411</span></a> +</span><span id="L-2412"><a href="#L-2412"><span class="linenos">2412</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</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">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2413"><a href="#L-2413"><span class="linenos">2413</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span><span id="L-2414"><a href="#L-2414"><span class="linenos">2414</span></a> -</span><span id="L-2415"><a href="#L-2415"><span class="linenos">2415</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="L-2416"><a href="#L-2416"><span class="linenos">2416</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="L-2417"><a href="#L-2417"><span class="linenos">2417</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2418"><a href="#L-2418"><span class="linenos">2418</span></a> -</span><span id="L-2419"><a href="#L-2419"><span class="linenos">2419</span></a> <span class="k">if</span> <span class="ow">not</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">"drop"</span><span class="p">):</span> -</span><span id="L-2420"><a href="#L-2420"><span class="linenos">2420</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> -</span><span id="L-2421"><a href="#L-2421"><span class="linenos">2421</span></a> -</span><span id="L-2422"><a href="#L-2422"><span class="linenos">2422</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> -</span><span id="L-2423"><a href="#L-2423"><span class="linenos">2423</span></a> -</span><span id="L-2424"><a href="#L-2424"><span class="linenos">2424</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</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">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2425"><a href="#L-2425"><span class="linenos">2425</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> -</span><span id="L-2426"><a href="#L-2426"><span class="linenos">2426</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="L-2427"><a href="#L-2427"><span class="linenos">2427</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="L-2428"><a href="#L-2428"><span class="linenos">2428</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> -</span><span id="L-2429"><a href="#L-2429"><span class="linenos">2429</span></a> <span class="p">)</span> -</span><span id="L-2430"><a href="#L-2430"><span class="linenos">2430</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2431"><a href="#L-2431"><span class="linenos">2431</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2432"><a href="#L-2432"><span class="linenos">2432</span></a> -</span><span id="L-2433"><a href="#L-2433"><span class="linenos">2433</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</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">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2434"><a href="#L-2434"><span class="linenos">2434</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> -</span><span id="L-2435"><a href="#L-2435"><span class="linenos">2435</span></a> -</span><span id="L-2436"><a href="#L-2436"><span class="linenos">2436</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> -</span><span id="L-2437"><a href="#L-2437"><span class="linenos">2437</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_ADD_COLUMN_KEYWORD</span><span class="p">:</span> -</span><span id="L-2438"><a href="#L-2438"><span class="linenos">2438</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> -</span><span id="L-2439"><a href="#L-2439"><span class="linenos">2439</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="L-2440"><a href="#L-2440"><span class="linenos">2440</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> -</span><span id="L-2441"><a href="#L-2441"><span class="linenos">2441</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">,</span> -</span><span id="L-2442"><a href="#L-2442"><span class="linenos">2442</span></a> <span class="p">)</span> -</span><span id="L-2443"><a href="#L-2443"><span class="linenos">2443</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2444"><a href="#L-2444"><span class="linenos">2444</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="o">=</span><span class="s1">'actions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2445"><a href="#L-2445"><span class="linenos">2445</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> -</span><span id="L-2446"><a href="#L-2446"><span class="linenos">2446</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> -</span><span id="L-2447"><a href="#L-2447"><span class="linenos">2447</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> -</span><span id="L-2448"><a href="#L-2448"><span class="linenos">2448</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2449"><a href="#L-2449"><span class="linenos">2449</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2450"><a href="#L-2450"><span class="linenos">2450</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2451"><a href="#L-2451"><span class="linenos">2451</span></a> -</span><span id="L-2452"><a href="#L-2452"><span class="linenos">2452</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2453"><a href="#L-2453"><span class="linenos">2453</span></a> <span class="n">only</span> <span class="o">=</span> <span class="s2">" ONLY"</span> <span class="k">if</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">"only"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2454"><a href="#L-2454"><span class="linenos">2454</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">only</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2455"><a href="#L-2455"><span class="linenos">2455</span></a> -</span><span id="L-2456"><a href="#L-2456"><span class="linenos">2456</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</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">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2457"><a href="#L-2457"><span class="linenos">2457</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2458"><a href="#L-2458"><span class="linenos">2458</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="L-2459"><a href="#L-2459"><span class="linenos">2459</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2460"><a href="#L-2460"><span class="linenos">2460</span></a> -</span><span id="L-2461"><a href="#L-2461"><span class="linenos">2461</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</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">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2462"><a href="#L-2462"><span class="linenos">2462</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2463"><a href="#L-2463"><span class="linenos">2463</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-2464"><a href="#L-2464"><span class="linenos">2464</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> -</span><span id="L-2465"><a href="#L-2465"><span class="linenos">2465</span></a> -</span><span id="L-2466"><a href="#L-2466"><span class="linenos">2466</span></a> <span class="n">enforced</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">"enforced"</span><span class="p">)</span> -</span><span id="L-2467"><a href="#L-2467"><span class="linenos">2467</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-2468"><a href="#L-2468"><span class="linenos">2468</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2469"><a href="#L-2469"><span class="linenos">2469</span></a> -</span><span id="L-2470"><a href="#L-2470"><span class="linenos">2470</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2471"><a href="#L-2471"><span class="linenos">2471</span></a> -</span><span id="L-2472"><a href="#L-2472"><span class="linenos">2472</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</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">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2473"><a href="#L-2473"><span class="linenos">2473</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2474"><a href="#L-2474"><span class="linenos">2474</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2475"><a href="#L-2475"><span class="linenos">2475</span></a> -</span><span id="L-2476"><a href="#L-2476"><span class="linenos">2476</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="L-2477"><a href="#L-2477"><span class="linenos">2477</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2478"><a href="#L-2478"><span class="linenos">2478</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2415"><a href="#L-2415"><span class="linenos">2415</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> +</span><span id="L-2416"><a href="#L-2416"><span class="linenos">2416</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="L-2417"><a href="#L-2417"><span class="linenos">2417</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="L-2418"><a href="#L-2418"><span class="linenos">2418</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2419"><a href="#L-2419"><span class="linenos">2419</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="L-2420"><a href="#L-2420"><span class="linenos">2420</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2421"><a href="#L-2421"><span class="linenos">2421</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DATA TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2422"><a href="#L-2422"><span class="linenos">2422</span></a> +</span><span id="L-2423"><a href="#L-2423"><span class="linenos">2423</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="L-2424"><a href="#L-2424"><span class="linenos">2424</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="L-2425"><a href="#L-2425"><span class="linenos">2425</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2426"><a href="#L-2426"><span class="linenos">2426</span></a> +</span><span id="L-2427"><a href="#L-2427"><span class="linenos">2427</span></a> <span class="k">if</span> <span class="ow">not</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">"drop"</span><span class="p">):</span> +</span><span id="L-2428"><a href="#L-2428"><span class="linenos">2428</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> +</span><span id="L-2429"><a href="#L-2429"><span class="linenos">2429</span></a> +</span><span id="L-2430"><a href="#L-2430"><span class="linenos">2430</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> +</span><span id="L-2431"><a href="#L-2431"><span class="linenos">2431</span></a> +</span><span id="L-2432"><a href="#L-2432"><span class="linenos">2432</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</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">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2433"><a href="#L-2433"><span class="linenos">2433</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> +</span><span id="L-2434"><a href="#L-2434"><span class="linenos">2434</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="L-2435"><a href="#L-2435"><span class="linenos">2435</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="L-2436"><a href="#L-2436"><span class="linenos">2436</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> +</span><span id="L-2437"><a href="#L-2437"><span class="linenos">2437</span></a> <span class="p">)</span> +</span><span id="L-2438"><a href="#L-2438"><span class="linenos">2438</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2439"><a href="#L-2439"><span class="linenos">2439</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2440"><a href="#L-2440"><span class="linenos">2440</span></a> +</span><span id="L-2441"><a href="#L-2441"><span class="linenos">2441</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</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">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2442"><a href="#L-2442"><span class="linenos">2442</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> +</span><span id="L-2443"><a href="#L-2443"><span class="linenos">2443</span></a> +</span><span id="L-2444"><a href="#L-2444"><span class="linenos">2444</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> +</span><span id="L-2445"><a href="#L-2445"><span class="linenos">2445</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_ADD_COLUMN_KEYWORD</span><span class="p">:</span> +</span><span id="L-2446"><a href="#L-2446"><span class="linenos">2446</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> +</span><span id="L-2447"><a href="#L-2447"><span class="linenos">2447</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="L-2448"><a href="#L-2448"><span class="linenos">2448</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> +</span><span id="L-2449"><a href="#L-2449"><span class="linenos">2449</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">,</span> +</span><span id="L-2450"><a href="#L-2450"><span class="linenos">2450</span></a> <span class="p">)</span> +</span><span id="L-2451"><a href="#L-2451"><span class="linenos">2451</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2452"><a href="#L-2452"><span class="linenos">2452</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="o">=</span><span class="s1">'actions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2453"><a href="#L-2453"><span class="linenos">2453</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> +</span><span id="L-2454"><a href="#L-2454"><span class="linenos">2454</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> +</span><span id="L-2455"><a href="#L-2455"><span class="linenos">2455</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> +</span><span id="L-2456"><a href="#L-2456"><span class="linenos">2456</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2457"><a href="#L-2457"><span class="linenos">2457</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2458"><a href="#L-2458"><span class="linenos">2458</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2459"><a href="#L-2459"><span class="linenos">2459</span></a> +</span><span id="L-2460"><a href="#L-2460"><span class="linenos">2460</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2461"><a href="#L-2461"><span class="linenos">2461</span></a> <span class="n">only</span> <span class="o">=</span> <span class="s2">" ONLY"</span> <span class="k">if</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">"only"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2462"><a href="#L-2462"><span class="linenos">2462</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">only</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2463"><a href="#L-2463"><span class="linenos">2463</span></a> +</span><span id="L-2464"><a href="#L-2464"><span class="linenos">2464</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</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">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2465"><a href="#L-2465"><span class="linenos">2465</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2466"><a href="#L-2466"><span class="linenos">2466</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="L-2467"><a href="#L-2467"><span class="linenos">2467</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2468"><a href="#L-2468"><span class="linenos">2468</span></a> +</span><span id="L-2469"><a href="#L-2469"><span class="linenos">2469</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</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">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2470"><a href="#L-2470"><span class="linenos">2470</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2471"><a href="#L-2471"><span class="linenos">2471</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-2472"><a href="#L-2472"><span class="linenos">2472</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> +</span><span id="L-2473"><a href="#L-2473"><span class="linenos">2473</span></a> +</span><span id="L-2474"><a href="#L-2474"><span class="linenos">2474</span></a> <span class="n">enforced</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">"enforced"</span><span class="p">)</span> +</span><span id="L-2475"><a href="#L-2475"><span class="linenos">2475</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-2476"><a href="#L-2476"><span class="linenos">2476</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2477"><a href="#L-2477"><span class="linenos">2477</span></a> +</span><span id="L-2478"><a href="#L-2478"><span class="linenos">2478</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2479"><a href="#L-2479"><span class="linenos">2479</span></a> -</span><span id="L-2480"><a href="#L-2480"><span class="linenos">2480</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</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">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2481"><a href="#L-2481"><span class="linenos">2481</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> -</span><span id="L-2482"><a href="#L-2482"><span class="linenos">2482</span></a> -</span><span id="L-2483"><a href="#L-2483"><span class="linenos">2483</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</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">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2484"><a href="#L-2484"><span class="linenos">2484</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> -</span><span id="L-2485"><a href="#L-2485"><span class="linenos">2485</span></a> -</span><span id="L-2486"><a href="#L-2486"><span class="linenos">2486</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</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">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2487"><a href="#L-2487"><span class="linenos">2487</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="L-2488"><a href="#L-2488"><span class="linenos">2488</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> -</span><span id="L-2489"><a href="#L-2489"><span class="linenos">2489</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()),</span> -</span><span id="L-2490"><a href="#L-2490"><span class="linenos">2490</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> -</span><span id="L-2491"><a href="#L-2491"><span class="linenos">2491</span></a> <span class="p">)</span> -</span><span id="L-2492"><a href="#L-2492"><span class="linenos">2492</span></a> <span class="p">)</span> +</span><span id="L-2480"><a href="#L-2480"><span class="linenos">2480</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</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">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2481"><a href="#L-2481"><span class="linenos">2481</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2482"><a href="#L-2482"><span class="linenos">2482</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2483"><a href="#L-2483"><span class="linenos">2483</span></a> +</span><span id="L-2484"><a href="#L-2484"><span class="linenos">2484</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="L-2485"><a href="#L-2485"><span class="linenos">2485</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2486"><a href="#L-2486"><span class="linenos">2486</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2487"><a href="#L-2487"><span class="linenos">2487</span></a> +</span><span id="L-2488"><a href="#L-2488"><span class="linenos">2488</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</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">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2489"><a href="#L-2489"><span class="linenos">2489</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> +</span><span id="L-2490"><a href="#L-2490"><span class="linenos">2490</span></a> +</span><span id="L-2491"><a href="#L-2491"><span class="linenos">2491</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</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">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2492"><a href="#L-2492"><span class="linenos">2492</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> </span><span id="L-2493"><a href="#L-2493"><span class="linenos">2493</span></a> -</span><span id="L-2494"><a href="#L-2494"><span class="linenos">2494</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</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">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2495"><a href="#L-2495"><span class="linenos">2495</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> -</span><span id="L-2496"><a href="#L-2496"><span class="linenos">2496</span></a> -</span><span id="L-2497"><a href="#L-2497"><span class="linenos">2497</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</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">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2498"><a href="#L-2498"><span class="linenos">2498</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="L-2499"><a href="#L-2499"><span class="linenos">2499</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> -</span><span id="L-2500"><a href="#L-2500"><span class="linenos">2500</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2494"><a href="#L-2494"><span class="linenos">2494</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</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">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2495"><a href="#L-2495"><span class="linenos">2495</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-2496"><a href="#L-2496"><span class="linenos">2496</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> +</span><span id="L-2497"><a href="#L-2497"><span class="linenos">2497</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()),</span> +</span><span id="L-2498"><a href="#L-2498"><span class="linenos">2498</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> +</span><span id="L-2499"><a href="#L-2499"><span class="linenos">2499</span></a> <span class="p">)</span> +</span><span id="L-2500"><a href="#L-2500"><span class="linenos">2500</span></a> <span class="p">)</span> </span><span id="L-2501"><a href="#L-2501"><span class="linenos">2501</span></a> -</span><span id="L-2502"><a href="#L-2502"><span class="linenos">2502</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</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">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2503"><a href="#L-2503"><span class="linenos">2503</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> +</span><span id="L-2502"><a href="#L-2502"><span class="linenos">2502</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</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">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2503"><a href="#L-2503"><span class="linenos">2503</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> </span><span id="L-2504"><a href="#L-2504"><span class="linenos">2504</span></a> -</span><span id="L-2505"><a href="#L-2505"><span class="linenos">2505</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</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">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2506"><a href="#L-2506"><span class="linenos">2506</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> -</span><span id="L-2507"><a href="#L-2507"><span class="linenos">2507</span></a> -</span><span id="L-2508"><a href="#L-2508"><span class="linenos">2508</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</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">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2509"><a href="#L-2509"><span class="linenos">2509</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> -</span><span id="L-2510"><a href="#L-2510"><span class="linenos">2510</span></a> -</span><span id="L-2511"><a href="#L-2511"><span class="linenos">2511</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</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">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2512"><a href="#L-2512"><span class="linenos">2512</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2513"><a href="#L-2513"><span class="linenos">2513</span></a> -</span><span id="L-2514"><a href="#L-2514"><span class="linenos">2514</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</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">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2515"><a href="#L-2515"><span class="linenos">2515</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> -</span><span id="L-2516"><a href="#L-2516"><span class="linenos">2516</span></a> -</span><span id="L-2517"><a href="#L-2517"><span class="linenos">2517</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</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">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2518"><a href="#L-2518"><span class="linenos">2518</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> -</span><span id="L-2519"><a href="#L-2519"><span class="linenos">2519</span></a> -</span><span id="L-2520"><a href="#L-2520"><span class="linenos">2520</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</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">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2521"><a href="#L-2521"><span class="linenos">2521</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> -</span><span id="L-2522"><a href="#L-2522"><span class="linenos">2522</span></a> -</span><span id="L-2523"><a href="#L-2523"><span class="linenos">2523</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</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">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2524"><a href="#L-2524"><span class="linenos">2524</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> -</span><span id="L-2525"><a href="#L-2525"><span class="linenos">2525</span></a> -</span><span id="L-2526"><a href="#L-2526"><span class="linenos">2526</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</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">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2527"><a href="#L-2527"><span class="linenos">2527</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> -</span><span id="L-2528"><a href="#L-2528"><span class="linenos">2528</span></a> -</span><span id="L-2529"><a href="#L-2529"><span class="linenos">2529</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</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">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2530"><a href="#L-2530"><span class="linenos">2530</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> -</span><span id="L-2531"><a href="#L-2531"><span class="linenos">2531</span></a> -</span><span id="L-2532"><a href="#L-2532"><span class="linenos">2532</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</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">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2533"><a href="#L-2533"><span class="linenos">2533</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> -</span><span id="L-2534"><a href="#L-2534"><span class="linenos">2534</span></a> -</span><span id="L-2535"><a href="#L-2535"><span class="linenos">2535</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</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">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2536"><a href="#L-2536"><span class="linenos">2536</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Boolean</span><span class="p">):</span> -</span><span id="L-2537"><a href="#L-2537"><span class="linenos">2537</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="L-2538"><a href="#L-2538"><span class="linenos">2538</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="L-2539"><a href="#L-2539"><span class="linenos">2539</span></a> <span class="p">)</span> -</span><span id="L-2540"><a href="#L-2540"><span class="linenos">2540</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> -</span><span id="L-2541"><a href="#L-2541"><span class="linenos">2541</span></a> -</span><span id="L-2542"><a href="#L-2542"><span class="linenos">2542</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</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">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2543"><a href="#L-2543"><span class="linenos">2543</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> -</span><span id="L-2544"><a href="#L-2544"><span class="linenos">2544</span></a> -</span><span id="L-2545"><a href="#L-2545"><span class="linenos">2545</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</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">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2546"><a href="#L-2546"><span class="linenos">2546</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> -</span><span id="L-2547"><a href="#L-2547"><span class="linenos">2547</span></a> -</span><span id="L-2548"><a href="#L-2548"><span class="linenos">2548</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</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">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2549"><a href="#L-2549"><span class="linenos">2549</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> -</span><span id="L-2550"><a href="#L-2550"><span class="linenos">2550</span></a> -</span><span id="L-2551"><a href="#L-2551"><span class="linenos">2551</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</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">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2552"><a href="#L-2552"><span class="linenos">2552</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> -</span><span id="L-2553"><a href="#L-2553"><span class="linenos">2553</span></a> -</span><span id="L-2554"><a href="#L-2554"><span class="linenos">2554</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</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">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2555"><a href="#L-2555"><span class="linenos">2555</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> -</span><span id="L-2556"><a href="#L-2556"><span class="linenos">2556</span></a> -</span><span id="L-2557"><a href="#L-2557"><span class="linenos">2557</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</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">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2558"><a href="#L-2558"><span class="linenos">2558</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> -</span><span id="L-2559"><a href="#L-2559"><span class="linenos">2559</span></a> -</span><span id="L-2560"><a href="#L-2560"><span class="linenos">2560</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</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">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2561"><a href="#L-2561"><span class="linenos">2561</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> -</span><span id="L-2562"><a href="#L-2562"><span class="linenos">2562</span></a> -</span><span id="L-2563"><a href="#L-2563"><span class="linenos">2563</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</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">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2564"><a href="#L-2564"><span class="linenos">2564</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> -</span><span id="L-2565"><a href="#L-2565"><span class="linenos">2565</span></a> -</span><span id="L-2566"><a href="#L-2566"><span class="linenos">2566</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2567"><a href="#L-2567"><span class="linenos">2567</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> -</span><span id="L-2568"><a href="#L-2568"><span class="linenos">2568</span></a> -</span><span id="L-2569"><a href="#L-2569"><span class="linenos">2569</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2570"><a href="#L-2570"><span class="linenos">2570</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> -</span><span id="L-2571"><a href="#L-2571"><span class="linenos">2571</span></a> -</span><span id="L-2572"><a href="#L-2572"><span class="linenos">2572</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</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">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2573"><a href="#L-2573"><span class="linenos">2573</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> -</span><span id="L-2574"><a href="#L-2574"><span class="linenos">2574</span></a> -</span><span id="L-2575"><a href="#L-2575"><span class="linenos">2575</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</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">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2576"><a href="#L-2576"><span class="linenos">2576</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> -</span><span id="L-2577"><a href="#L-2577"><span class="linenos">2577</span></a> -</span><span id="L-2578"><a href="#L-2578"><span class="linenos">2578</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</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">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2579"><a href="#L-2579"><span class="linenos">2579</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> -</span><span id="L-2580"><a href="#L-2580"><span class="linenos">2580</span></a> -</span><span id="L-2581"><a href="#L-2581"><span class="linenos">2581</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</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">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2582"><a href="#L-2582"><span class="linenos">2582</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY_"</span><span class="p">)</span> -</span><span id="L-2583"><a href="#L-2583"><span class="linenos">2583</span></a> -</span><span id="L-2584"><a href="#L-2584"><span class="linenos">2584</span></a> <span class="k">def</span> <span class="nf">log_sql</span><span class="p">(</span><span class="bp">self</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">Log</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2585"><a href="#L-2585"><span class="linenos">2585</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> -</span><span id="L-2586"><a href="#L-2586"><span class="linenos">2586</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> -</span><span id="L-2587"><a href="#L-2587"><span class="linenos">2587</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> -</span><span id="L-2588"><a href="#L-2588"><span class="linenos">2588</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LOG"</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-2589"><a href="#L-2589"><span class="linenos">2589</span></a> -</span><span id="L-2590"><a href="#L-2590"><span class="linenos">2590</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</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">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2591"><a href="#L-2591"><span class="linenos">2591</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-2592"><a href="#L-2592"><span class="linenos">2592</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2593"><a href="#L-2593"><span class="linenos">2593</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2594"><a href="#L-2594"><span class="linenos">2594</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2595"><a href="#L-2595"><span class="linenos">2595</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2596"><a href="#L-2596"><span class="linenos">2596</span></a> -</span><span id="L-2597"><a href="#L-2597"><span class="linenos">2597</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</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">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2598"><a href="#L-2598"><span class="linenos">2598</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> -</span><span id="L-2599"><a href="#L-2599"><span class="linenos">2599</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2600"><a href="#L-2600"><span class="linenos">2600</span></a> -</span><span id="L-2601"><a href="#L-2601"><span class="linenos">2601</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</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">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2602"><a href="#L-2602"><span class="linenos">2602</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-2603"><a href="#L-2603"><span class="linenos">2603</span></a> -</span><span id="L-2604"><a href="#L-2604"><span class="linenos">2604</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> -</span><span id="L-2605"><a href="#L-2605"><span class="linenos">2605</span></a> <span class="n">arg_value</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="n">key</span><span class="p">)</span> -</span><span id="L-2606"><a href="#L-2606"><span class="linenos">2606</span></a> -</span><span id="L-2607"><a href="#L-2607"><span class="linenos">2607</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="L-2608"><a href="#L-2608"><span class="linenos">2608</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> -</span><span id="L-2609"><a href="#L-2609"><span class="linenos">2609</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="L-2610"><a href="#L-2610"><span class="linenos">2610</span></a> <span class="k">elif</span> <span class="n">arg_value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-2611"><a href="#L-2611"><span class="linenos">2611</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> -</span><span id="L-2612"><a href="#L-2612"><span class="linenos">2612</span></a> -</span><span id="L-2613"><a href="#L-2613"><span class="linenos">2613</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span><span class="p">:</span> -</span><span id="L-2614"><a href="#L-2614"><span class="linenos">2614</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> -</span><span id="L-2615"><a href="#L-2615"><span class="linenos">2615</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2616"><a href="#L-2616"><span class="linenos">2616</span></a> <span class="n">name</span> <span class="o">=</span> <span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">_meta</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">))</span> <span class="ow">or</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> -</span><span id="L-2617"><a href="#L-2617"><span class="linenos">2617</span></a> -</span><span id="L-2618"><a href="#L-2618"><span class="linenos">2618</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> -</span><span id="L-2619"><a href="#L-2619"><span class="linenos">2619</span></a> -</span><span id="L-2620"><a href="#L-2620"><span class="linenos">2620</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="L-2621"><a href="#L-2621"><span class="linenos">2621</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2622"><a href="#L-2622"><span class="linenos">2622</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="L-2623"><a href="#L-2623"><span class="linenos">2623</span></a> <span class="o">*</span><span class="n">args</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">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> -</span><span id="L-2624"><a href="#L-2624"><span class="linenos">2624</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> -</span><span id="L-2625"><a href="#L-2625"><span class="linenos">2625</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> -</span><span id="L-2626"><a href="#L-2626"><span class="linenos">2626</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2627"><a href="#L-2627"><span class="linenos">2627</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2628"><a href="#L-2628"><span class="linenos">2628</span></a> -</span><span id="L-2629"><a href="#L-2629"><span class="linenos">2629</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</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="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2630"><a href="#L-2630"><span class="linenos">2630</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="L-2631"><a href="#L-2631"><span class="linenos">2631</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="L-2632"><a href="#L-2632"><span class="linenos">2632</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2633"><a href="#L-2633"><span class="linenos">2633</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> -</span><span id="L-2634"><a href="#L-2634"><span class="linenos">2634</span></a> -</span><span id="L-2635"><a href="#L-2635"><span class="linenos">2635</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="L-2636"><a href="#L-2636"><span class="linenos">2636</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> -</span><span id="L-2637"><a href="#L-2637"><span class="linenos">2637</span></a> -</span><span id="L-2638"><a href="#L-2638"><span class="linenos">2638</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="L-2639"><a href="#L-2639"><span class="linenos">2639</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="L-2640"><a href="#L-2640"><span class="linenos">2640</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> -</span><span id="L-2641"><a href="#L-2641"><span class="linenos">2641</span></a> <span class="p">)</span> +</span><span id="L-2505"><a href="#L-2505"><span class="linenos">2505</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</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">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2506"><a href="#L-2506"><span class="linenos">2506</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="L-2507"><a href="#L-2507"><span class="linenos">2507</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> +</span><span id="L-2508"><a href="#L-2508"><span class="linenos">2508</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2509"><a href="#L-2509"><span class="linenos">2509</span></a> +</span><span id="L-2510"><a href="#L-2510"><span class="linenos">2510</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</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">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2511"><a href="#L-2511"><span class="linenos">2511</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> +</span><span id="L-2512"><a href="#L-2512"><span class="linenos">2512</span></a> +</span><span id="L-2513"><a href="#L-2513"><span class="linenos">2513</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</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">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2514"><a href="#L-2514"><span class="linenos">2514</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> +</span><span id="L-2515"><a href="#L-2515"><span class="linenos">2515</span></a> +</span><span id="L-2516"><a href="#L-2516"><span class="linenos">2516</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</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">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2517"><a href="#L-2517"><span class="linenos">2517</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> +</span><span id="L-2518"><a href="#L-2518"><span class="linenos">2518</span></a> +</span><span id="L-2519"><a href="#L-2519"><span class="linenos">2519</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</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">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2520"><a href="#L-2520"><span class="linenos">2520</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2521"><a href="#L-2521"><span class="linenos">2521</span></a> +</span><span id="L-2522"><a href="#L-2522"><span class="linenos">2522</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</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">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2523"><a href="#L-2523"><span class="linenos">2523</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> +</span><span id="L-2524"><a href="#L-2524"><span class="linenos">2524</span></a> +</span><span id="L-2525"><a href="#L-2525"><span class="linenos">2525</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</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">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2526"><a href="#L-2526"><span class="linenos">2526</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> +</span><span id="L-2527"><a href="#L-2527"><span class="linenos">2527</span></a> +</span><span id="L-2528"><a href="#L-2528"><span class="linenos">2528</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</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">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2529"><a href="#L-2529"><span class="linenos">2529</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> +</span><span id="L-2530"><a href="#L-2530"><span class="linenos">2530</span></a> +</span><span id="L-2531"><a href="#L-2531"><span class="linenos">2531</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</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">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2532"><a href="#L-2532"><span class="linenos">2532</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> +</span><span id="L-2533"><a href="#L-2533"><span class="linenos">2533</span></a> +</span><span id="L-2534"><a href="#L-2534"><span class="linenos">2534</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</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">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2535"><a href="#L-2535"><span class="linenos">2535</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> +</span><span id="L-2536"><a href="#L-2536"><span class="linenos">2536</span></a> +</span><span id="L-2537"><a href="#L-2537"><span class="linenos">2537</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</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">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2538"><a href="#L-2538"><span class="linenos">2538</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> +</span><span id="L-2539"><a href="#L-2539"><span class="linenos">2539</span></a> +</span><span id="L-2540"><a href="#L-2540"><span class="linenos">2540</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</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">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2541"><a href="#L-2541"><span class="linenos">2541</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> +</span><span id="L-2542"><a href="#L-2542"><span class="linenos">2542</span></a> +</span><span id="L-2543"><a href="#L-2543"><span class="linenos">2543</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</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">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2544"><a href="#L-2544"><span class="linenos">2544</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Boolean</span><span class="p">):</span> +</span><span id="L-2545"><a href="#L-2545"><span class="linenos">2545</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="L-2546"><a href="#L-2546"><span class="linenos">2546</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="L-2547"><a href="#L-2547"><span class="linenos">2547</span></a> <span class="p">)</span> +</span><span id="L-2548"><a href="#L-2548"><span class="linenos">2548</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> +</span><span id="L-2549"><a href="#L-2549"><span class="linenos">2549</span></a> +</span><span id="L-2550"><a href="#L-2550"><span class="linenos">2550</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</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">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2551"><a href="#L-2551"><span class="linenos">2551</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> +</span><span id="L-2552"><a href="#L-2552"><span class="linenos">2552</span></a> +</span><span id="L-2553"><a href="#L-2553"><span class="linenos">2553</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</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">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2554"><a href="#L-2554"><span class="linenos">2554</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> +</span><span id="L-2555"><a href="#L-2555"><span class="linenos">2555</span></a> +</span><span id="L-2556"><a href="#L-2556"><span class="linenos">2556</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</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">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2557"><a href="#L-2557"><span class="linenos">2557</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> +</span><span id="L-2558"><a href="#L-2558"><span class="linenos">2558</span></a> +</span><span id="L-2559"><a href="#L-2559"><span class="linenos">2559</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</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">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2560"><a href="#L-2560"><span class="linenos">2560</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> +</span><span id="L-2561"><a href="#L-2561"><span class="linenos">2561</span></a> +</span><span id="L-2562"><a href="#L-2562"><span class="linenos">2562</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</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">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2563"><a href="#L-2563"><span class="linenos">2563</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> +</span><span id="L-2564"><a href="#L-2564"><span class="linenos">2564</span></a> +</span><span id="L-2565"><a href="#L-2565"><span class="linenos">2565</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</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">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2566"><a href="#L-2566"><span class="linenos">2566</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> +</span><span id="L-2567"><a href="#L-2567"><span class="linenos">2567</span></a> +</span><span id="L-2568"><a href="#L-2568"><span class="linenos">2568</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</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">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2569"><a href="#L-2569"><span class="linenos">2569</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> +</span><span id="L-2570"><a href="#L-2570"><span class="linenos">2570</span></a> +</span><span id="L-2571"><a href="#L-2571"><span class="linenos">2571</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</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">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2572"><a href="#L-2572"><span class="linenos">2572</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> +</span><span id="L-2573"><a href="#L-2573"><span class="linenos">2573</span></a> +</span><span id="L-2574"><a href="#L-2574"><span class="linenos">2574</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2575"><a href="#L-2575"><span class="linenos">2575</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> +</span><span id="L-2576"><a href="#L-2576"><span class="linenos">2576</span></a> +</span><span id="L-2577"><a href="#L-2577"><span class="linenos">2577</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2578"><a href="#L-2578"><span class="linenos">2578</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> +</span><span id="L-2579"><a href="#L-2579"><span class="linenos">2579</span></a> +</span><span id="L-2580"><a href="#L-2580"><span class="linenos">2580</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</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">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2581"><a href="#L-2581"><span class="linenos">2581</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> +</span><span id="L-2582"><a href="#L-2582"><span class="linenos">2582</span></a> +</span><span id="L-2583"><a href="#L-2583"><span class="linenos">2583</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</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">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2584"><a href="#L-2584"><span class="linenos">2584</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> +</span><span id="L-2585"><a href="#L-2585"><span class="linenos">2585</span></a> +</span><span id="L-2586"><a href="#L-2586"><span class="linenos">2586</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</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">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2587"><a href="#L-2587"><span class="linenos">2587</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> +</span><span id="L-2588"><a href="#L-2588"><span class="linenos">2588</span></a> +</span><span id="L-2589"><a href="#L-2589"><span class="linenos">2589</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</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">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2590"><a href="#L-2590"><span class="linenos">2590</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY_"</span><span class="p">)</span> +</span><span id="L-2591"><a href="#L-2591"><span class="linenos">2591</span></a> +</span><span id="L-2592"><a href="#L-2592"><span class="linenos">2592</span></a> <span class="k">def</span> <span class="nf">log_sql</span><span class="p">(</span><span class="bp">self</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">Log</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2593"><a href="#L-2593"><span class="linenos">2593</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> +</span><span id="L-2594"><a href="#L-2594"><span class="linenos">2594</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> +</span><span id="L-2595"><a href="#L-2595"><span class="linenos">2595</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> +</span><span id="L-2596"><a href="#L-2596"><span class="linenos">2596</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LOG"</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-2597"><a href="#L-2597"><span class="linenos">2597</span></a> +</span><span id="L-2598"><a href="#L-2598"><span class="linenos">2598</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</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">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2599"><a href="#L-2599"><span class="linenos">2599</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-2600"><a href="#L-2600"><span class="linenos">2600</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2601"><a href="#L-2601"><span class="linenos">2601</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2602"><a href="#L-2602"><span class="linenos">2602</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2603"><a href="#L-2603"><span class="linenos">2603</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2604"><a href="#L-2604"><span class="linenos">2604</span></a> +</span><span id="L-2605"><a href="#L-2605"><span class="linenos">2605</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</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">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2606"><a href="#L-2606"><span class="linenos">2606</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> +</span><span id="L-2607"><a href="#L-2607"><span class="linenos">2607</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2608"><a href="#L-2608"><span class="linenos">2608</span></a> +</span><span id="L-2609"><a href="#L-2609"><span class="linenos">2609</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</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">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2610"><a href="#L-2610"><span class="linenos">2610</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2611"><a href="#L-2611"><span class="linenos">2611</span></a> +</span><span id="L-2612"><a href="#L-2612"><span class="linenos">2612</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> +</span><span id="L-2613"><a href="#L-2613"><span class="linenos">2613</span></a> <span class="n">arg_value</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="n">key</span><span class="p">)</span> +</span><span id="L-2614"><a href="#L-2614"><span class="linenos">2614</span></a> +</span><span id="L-2615"><a href="#L-2615"><span class="linenos">2615</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="L-2616"><a href="#L-2616"><span class="linenos">2616</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> +</span><span id="L-2617"><a href="#L-2617"><span class="linenos">2617</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="L-2618"><a href="#L-2618"><span class="linenos">2618</span></a> <span class="k">elif</span> <span class="n">arg_value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-2619"><a href="#L-2619"><span class="linenos">2619</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> +</span><span id="L-2620"><a href="#L-2620"><span class="linenos">2620</span></a> +</span><span id="L-2621"><a href="#L-2621"><span class="linenos">2621</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span><span class="p">:</span> +</span><span id="L-2622"><a href="#L-2622"><span class="linenos">2622</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> +</span><span id="L-2623"><a href="#L-2623"><span class="linenos">2623</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2624"><a href="#L-2624"><span class="linenos">2624</span></a> <span class="n">name</span> <span class="o">=</span> <span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">_meta</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">))</span> <span class="ow">or</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> +</span><span id="L-2625"><a href="#L-2625"><span class="linenos">2625</span></a> +</span><span id="L-2626"><a href="#L-2626"><span class="linenos">2626</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> +</span><span id="L-2627"><a href="#L-2627"><span class="linenos">2627</span></a> +</span><span id="L-2628"><a href="#L-2628"><span class="linenos">2628</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> +</span><span id="L-2629"><a href="#L-2629"><span class="linenos">2629</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2630"><a href="#L-2630"><span class="linenos">2630</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="L-2631"><a href="#L-2631"><span class="linenos">2631</span></a> <span class="o">*</span><span class="n">args</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">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> +</span><span id="L-2632"><a href="#L-2632"><span class="linenos">2632</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> +</span><span id="L-2633"><a href="#L-2633"><span class="linenos">2633</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> +</span><span id="L-2634"><a href="#L-2634"><span class="linenos">2634</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2635"><a href="#L-2635"><span class="linenos">2635</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2636"><a href="#L-2636"><span class="linenos">2636</span></a> +</span><span id="L-2637"><a href="#L-2637"><span class="linenos">2637</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</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="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2638"><a href="#L-2638"><span class="linenos">2638</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-2639"><a href="#L-2639"><span class="linenos">2639</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="L-2640"><a href="#L-2640"><span class="linenos">2640</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2641"><a href="#L-2641"><span class="linenos">2641</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> </span><span id="L-2642"><a href="#L-2642"><span class="linenos">2642</span></a> -</span><span id="L-2643"><a href="#L-2643"><span class="linenos">2643</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="L-2644"><a href="#L-2644"><span class="linenos">2644</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="L-2645"><a href="#L-2645"><span class="linenos">2645</span></a> <span class="n">expression</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2646"><a href="#L-2646"><span class="linenos">2646</span></a> <span class="n">key</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2647"><a href="#L-2647"><span class="linenos">2647</span></a> <span class="n">sqls</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">Collection</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="L-2648"><a href="#L-2648"><span class="linenos">2648</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2649"><a href="#L-2649"><span class="linenos">2649</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="L-2650"><a href="#L-2650"><span class="linenos">2650</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="L-2651"><a href="#L-2651"><span class="linenos">2651</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="L-2652"><a href="#L-2652"><span class="linenos">2652</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="L-2653"><a href="#L-2653"><span class="linenos">2653</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2654"><a href="#L-2654"><span class="linenos">2654</span></a> <span class="n">expressions</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="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> -</span><span id="L-2655"><a href="#L-2655"><span class="linenos">2655</span></a> -</span><span id="L-2656"><a href="#L-2656"><span class="linenos">2656</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="L-2657"><a href="#L-2657"><span class="linenos">2657</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-2658"><a href="#L-2658"><span class="linenos">2658</span></a> -</span><span id="L-2659"><a href="#L-2659"><span class="linenos">2659</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="L-2660"><a href="#L-2660"><span class="linenos">2660</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sql</span> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="L-2661"><a href="#L-2661"><span class="linenos">2661</span></a> -</span><span id="L-2662"><a href="#L-2662"><span class="linenos">2662</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2643"><a href="#L-2643"><span class="linenos">2643</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="L-2644"><a href="#L-2644"><span class="linenos">2644</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> +</span><span id="L-2645"><a href="#L-2645"><span class="linenos">2645</span></a> +</span><span id="L-2646"><a href="#L-2646"><span class="linenos">2646</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="L-2647"><a href="#L-2647"><span class="linenos">2647</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="L-2648"><a href="#L-2648"><span class="linenos">2648</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> +</span><span id="L-2649"><a href="#L-2649"><span class="linenos">2649</span></a> <span class="p">)</span> +</span><span id="L-2650"><a href="#L-2650"><span class="linenos">2650</span></a> +</span><span id="L-2651"><a href="#L-2651"><span class="linenos">2651</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> +</span><span id="L-2652"><a href="#L-2652"><span class="linenos">2652</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="L-2653"><a href="#L-2653"><span class="linenos">2653</span></a> <span class="n">expression</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2654"><a href="#L-2654"><span class="linenos">2654</span></a> <span class="n">key</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2655"><a href="#L-2655"><span class="linenos">2655</span></a> <span class="n">sqls</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">Collection</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="L-2656"><a href="#L-2656"><span class="linenos">2656</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2657"><a href="#L-2657"><span class="linenos">2657</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="L-2658"><a href="#L-2658"><span class="linenos">2658</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="L-2659"><a href="#L-2659"><span class="linenos">2659</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="L-2660"><a href="#L-2660"><span class="linenos">2660</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="L-2661"><a href="#L-2661"><span class="linenos">2661</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2662"><a href="#L-2662"><span class="linenos">2662</span></a> <span class="n">expressions</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="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> </span><span id="L-2663"><a href="#L-2663"><span class="linenos">2663</span></a> -</span><span id="L-2664"><a href="#L-2664"><span class="linenos">2664</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> -</span><span id="L-2665"><a href="#L-2665"><span class="linenos">2665</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> -</span><span id="L-2666"><a href="#L-2666"><span class="linenos">2666</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="L-2667"><a href="#L-2667"><span class="linenos">2667</span></a> -</span><span id="L-2668"><a href="#L-2668"><span class="linenos">2668</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="L-2669"><a href="#L-2669"><span class="linenos">2669</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="L-2670"><a href="#L-2670"><span class="linenos">2670</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-2671"><a href="#L-2671"><span class="linenos">2671</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">sql</span><span class="p">:</span> -</span><span id="L-2672"><a href="#L-2672"><span class="linenos">2672</span></a> <span class="k">continue</span> -</span><span id="L-2673"><a href="#L-2673"><span class="linenos">2673</span></a> -</span><span id="L-2674"><a href="#L-2674"><span class="linenos">2674</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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="k">else</span> <span class="s2">""</span> +</span><span id="L-2664"><a href="#L-2664"><span class="linenos">2664</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="L-2665"><a href="#L-2665"><span class="linenos">2665</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-2666"><a href="#L-2666"><span class="linenos">2666</span></a> +</span><span id="L-2667"><a href="#L-2667"><span class="linenos">2667</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="L-2668"><a href="#L-2668"><span class="linenos">2668</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sql</span> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="L-2669"><a href="#L-2669"><span class="linenos">2669</span></a> +</span><span id="L-2670"><a href="#L-2670"><span class="linenos">2670</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2671"><a href="#L-2671"><span class="linenos">2671</span></a> +</span><span id="L-2672"><a href="#L-2672"><span class="linenos">2672</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> +</span><span id="L-2673"><a href="#L-2673"><span class="linenos">2673</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> +</span><span id="L-2674"><a href="#L-2674"><span class="linenos">2674</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> </span><span id="L-2675"><a href="#L-2675"><span class="linenos">2675</span></a> -</span><span id="L-2676"><a href="#L-2676"><span class="linenos">2676</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="L-2677"><a href="#L-2677"><span class="linenos">2677</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> -</span><span id="L-2678"><a href="#L-2678"><span class="linenos">2678</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-2679"><a href="#L-2679"><span class="linenos">2679</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2680"><a href="#L-2680"><span class="linenos">2680</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="L-2681"><a href="#L-2681"><span class="linenos">2681</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2682"><a href="#L-2682"><span class="linenos">2682</span></a> <span class="p">)</span> -</span><span id="L-2683"><a href="#L-2683"><span class="linenos">2683</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2684"><a href="#L-2684"><span class="linenos">2684</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-2685"><a href="#L-2685"><span class="linenos">2685</span></a> -</span><span id="L-2686"><a href="#L-2686"><span class="linenos">2686</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> -</span><span id="L-2687"><a href="#L-2687"><span class="linenos">2687</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="n">skip_first</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> -</span><span id="L-2688"><a href="#L-2688"><span class="linenos">2688</span></a> -</span><span id="L-2689"><a href="#L-2689"><span class="linenos">2689</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</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">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2690"><a href="#L-2690"><span class="linenos">2690</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> -</span><span id="L-2691"><a href="#L-2691"><span class="linenos">2691</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> -</span><span id="L-2692"><a href="#L-2692"><span class="linenos">2692</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="L-2693"><a href="#L-2693"><span class="linenos">2693</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2694"><a href="#L-2694"><span class="linenos">2694</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2695"><a href="#L-2695"><span class="linenos">2695</span></a> -</span><span id="L-2696"><a href="#L-2696"><span class="linenos">2696</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</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">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2697"><a href="#L-2697"><span class="linenos">2697</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="L-2698"><a href="#L-2698"><span class="linenos">2698</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="L-2699"><a href="#L-2699"><span class="linenos">2699</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="L-2700"><a href="#L-2700"><span class="linenos">2700</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2701"><a href="#L-2701"><span class="linenos">2701</span></a> -</span><span id="L-2702"><a href="#L-2702"><span class="linenos">2702</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2703"><a href="#L-2703"><span class="linenos">2703</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2704"><a href="#L-2704"><span class="linenos">2704</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> -</span><span id="L-2705"><a href="#L-2705"><span class="linenos">2705</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="L-2706"><a href="#L-2706"><span class="linenos">2706</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2707"><a href="#L-2707"><span class="linenos">2707</span></a> <span class="p">)</span> -</span><span id="L-2708"><a href="#L-2708"><span class="linenos">2708</span></a> -</span><span id="L-2709"><a href="#L-2709"><span class="linenos">2709</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</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">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2710"><a href="#L-2710"><span class="linenos">2710</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</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="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</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="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2711"><a href="#L-2711"><span class="linenos">2711</span></a> -</span><span id="L-2712"><a href="#L-2712"><span class="linenos">2712</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2713"><a href="#L-2713"><span class="linenos">2713</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="L-2714"><a href="#L-2714"><span class="linenos">2714</span></a> -</span><span id="L-2715"><a href="#L-2715"><span class="linenos">2715</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</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">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2716"><a href="#L-2716"><span class="linenos">2716</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2717"><a href="#L-2717"><span class="linenos">2717</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="L-2718"><a href="#L-2718"><span class="linenos">2718</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="L-2719"><a href="#L-2719"><span class="linenos">2719</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</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">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2720"><a href="#L-2720"><span class="linenos">2720</span></a> <span class="p">)</span> -</span><span id="L-2721"><a href="#L-2721"><span class="linenos">2721</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2676"><a href="#L-2676"><span class="linenos">2676</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="L-2677"><a href="#L-2677"><span class="linenos">2677</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="L-2678"><a href="#L-2678"><span class="linenos">2678</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-2679"><a href="#L-2679"><span class="linenos">2679</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">sql</span><span class="p">:</span> +</span><span id="L-2680"><a href="#L-2680"><span class="linenos">2680</span></a> <span class="k">continue</span> +</span><span id="L-2681"><a href="#L-2681"><span class="linenos">2681</span></a> +</span><span id="L-2682"><a href="#L-2682"><span class="linenos">2682</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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="k">else</span> <span class="s2">""</span> +</span><span id="L-2683"><a href="#L-2683"><span class="linenos">2683</span></a> +</span><span id="L-2684"><a href="#L-2684"><span class="linenos">2684</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="L-2685"><a href="#L-2685"><span class="linenos">2685</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> +</span><span id="L-2686"><a href="#L-2686"><span class="linenos">2686</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-2687"><a href="#L-2687"><span class="linenos">2687</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2688"><a href="#L-2688"><span class="linenos">2688</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="L-2689"><a href="#L-2689"><span class="linenos">2689</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2690"><a href="#L-2690"><span class="linenos">2690</span></a> <span class="p">)</span> +</span><span id="L-2691"><a href="#L-2691"><span class="linenos">2691</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2692"><a href="#L-2692"><span class="linenos">2692</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-2693"><a href="#L-2693"><span class="linenos">2693</span></a> +</span><span id="L-2694"><a href="#L-2694"><span class="linenos">2694</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> +</span><span id="L-2695"><a href="#L-2695"><span class="linenos">2695</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="n">skip_first</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> +</span><span id="L-2696"><a href="#L-2696"><span class="linenos">2696</span></a> +</span><span id="L-2697"><a href="#L-2697"><span class="linenos">2697</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</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">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2698"><a href="#L-2698"><span class="linenos">2698</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> +</span><span id="L-2699"><a href="#L-2699"><span class="linenos">2699</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> +</span><span id="L-2700"><a href="#L-2700"><span class="linenos">2700</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="L-2701"><a href="#L-2701"><span class="linenos">2701</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2702"><a href="#L-2702"><span class="linenos">2702</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2703"><a href="#L-2703"><span class="linenos">2703</span></a> +</span><span id="L-2704"><a href="#L-2704"><span class="linenos">2704</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</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">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2705"><a href="#L-2705"><span class="linenos">2705</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> +</span><span id="L-2706"><a href="#L-2706"><span class="linenos">2706</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="L-2707"><a href="#L-2707"><span class="linenos">2707</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="L-2708"><a href="#L-2708"><span class="linenos">2708</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2709"><a href="#L-2709"><span class="linenos">2709</span></a> +</span><span id="L-2710"><a href="#L-2710"><span class="linenos">2710</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2711"><a href="#L-2711"><span class="linenos">2711</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2712"><a href="#L-2712"><span class="linenos">2712</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> +</span><span id="L-2713"><a href="#L-2713"><span class="linenos">2713</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="L-2714"><a href="#L-2714"><span class="linenos">2714</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2715"><a href="#L-2715"><span class="linenos">2715</span></a> <span class="p">)</span> +</span><span id="L-2716"><a href="#L-2716"><span class="linenos">2716</span></a> +</span><span id="L-2717"><a href="#L-2717"><span class="linenos">2717</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</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">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2718"><a href="#L-2718"><span class="linenos">2718</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</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="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</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="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2719"><a href="#L-2719"><span class="linenos">2719</span></a> +</span><span id="L-2720"><a href="#L-2720"><span class="linenos">2720</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2721"><a href="#L-2721"><span class="linenos">2721</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> </span><span id="L-2722"><a href="#L-2722"><span class="linenos">2722</span></a> -</span><span id="L-2723"><a href="#L-2723"><span class="linenos">2723</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</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">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2723"><a href="#L-2723"><span class="linenos">2723</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</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">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="L-2724"><a href="#L-2724"><span class="linenos">2724</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2725"><a href="#L-2725"><span class="linenos">2725</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2726"><a href="#L-2726"><span class="linenos">2726</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2727"><a href="#L-2727"><span class="linenos">2727</span></a> -</span><span id="L-2728"><a href="#L-2728"><span class="linenos">2728</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</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">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2729"><a href="#L-2729"><span class="linenos">2729</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> +</span><span id="L-2725"><a href="#L-2725"><span class="linenos">2725</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="L-2726"><a href="#L-2726"><span class="linenos">2726</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="L-2727"><a href="#L-2727"><span class="linenos">2727</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</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">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2728"><a href="#L-2728"><span class="linenos">2728</span></a> <span class="p">)</span> +</span><span id="L-2729"><a href="#L-2729"><span class="linenos">2729</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2730"><a href="#L-2730"><span class="linenos">2730</span></a> -</span><span id="L-2731"><a href="#L-2731"><span class="linenos">2731</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</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">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2732"><a href="#L-2732"><span class="linenos">2732</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> -</span><span id="L-2733"><a href="#L-2733"><span class="linenos">2733</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</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">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2734"><a href="#L-2734"><span class="linenos">2734</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="L-2735"><a href="#L-2735"><span class="linenos">2735</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2736"><a href="#L-2736"><span class="linenos">2736</span></a> -</span><span id="L-2737"><a href="#L-2737"><span class="linenos">2737</span></a> <span class="n">then_expression</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">"then"</span><span class="p">)</span> -</span><span id="L-2738"><a href="#L-2738"><span class="linenos">2738</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> -</span><span id="L-2739"><a href="#L-2739"><span class="linenos">2739</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2740"><a href="#L-2740"><span class="linenos">2740</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> -</span><span id="L-2741"><a href="#L-2741"><span class="linenos">2741</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2742"><a href="#L-2742"><span class="linenos">2742</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="L-2743"><a href="#L-2743"><span class="linenos">2743</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_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">"expressions"</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-2744"><a href="#L-2744"><span class="linenos">2744</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2745"><a href="#L-2745"><span class="linenos">2745</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2746"><a href="#L-2746"><span class="linenos">2746</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2747"><a href="#L-2747"><span class="linenos">2747</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="L-2748"><a href="#L-2748"><span class="linenos">2748</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> -</span><span id="L-2749"><a href="#L-2749"><span class="linenos">2749</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2750"><a href="#L-2750"><span class="linenos">2750</span></a> -</span><span id="L-2751"><a href="#L-2751"><span class="linenos">2751</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</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">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2752"><a href="#L-2752"><span class="linenos">2752</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="L-2753"><a href="#L-2753"><span class="linenos">2753</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="L-2754"><a href="#L-2754"><span class="linenos">2754</span></a> -</span><span id="L-2755"><a href="#L-2755"><span class="linenos">2755</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="n">table</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">"hints"</span><span class="p">)</span> -</span><span id="L-2756"><a href="#L-2756"><span class="linenos">2756</span></a> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="n">table</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">hints</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">):</span> -</span><span id="L-2757"><a href="#L-2757"><span class="linenos">2757</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> -</span><span id="L-2758"><a href="#L-2758"><span class="linenos">2758</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="L-2759"><a href="#L-2759"><span class="linenos">2759</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'alias'</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">())</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2760"><a href="#L-2760"><span class="linenos">2760</span></a> -</span><span id="L-2761"><a href="#L-2761"><span class="linenos">2761</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="L-2762"><a href="#L-2762"><span class="linenos">2762</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2763"><a href="#L-2763"><span class="linenos">2763</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2764"><a href="#L-2764"><span class="linenos">2764</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-2765"><a href="#L-2765"><span class="linenos">2765</span></a> -</span><span id="L-2766"><a href="#L-2766"><span class="linenos">2766</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">table_alias</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2767"><a href="#L-2767"><span class="linenos">2767</span></a> -</span><span id="L-2768"><a href="#L-2768"><span class="linenos">2768</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</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">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2769"><a href="#L-2769"><span class="linenos">2769</span></a> <span class="k">if</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">"format"</span><span class="p">):</span> -</span><span id="L-2770"><a href="#L-2770"><span class="linenos">2770</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> -</span><span id="L-2771"><a href="#L-2771"><span class="linenos">2771</span></a> -</span><span id="L-2772"><a href="#L-2772"><span class="linenos">2772</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> +</span><span id="L-2731"><a href="#L-2731"><span class="linenos">2731</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</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">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2732"><a href="#L-2732"><span class="linenos">2732</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2733"><a href="#L-2733"><span class="linenos">2733</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2734"><a href="#L-2734"><span class="linenos">2734</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2735"><a href="#L-2735"><span class="linenos">2735</span></a> +</span><span id="L-2736"><a href="#L-2736"><span class="linenos">2736</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</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">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2737"><a href="#L-2737"><span class="linenos">2737</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> +</span><span id="L-2738"><a href="#L-2738"><span class="linenos">2738</span></a> +</span><span id="L-2739"><a href="#L-2739"><span class="linenos">2739</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</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">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2740"><a href="#L-2740"><span class="linenos">2740</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> +</span><span id="L-2741"><a href="#L-2741"><span class="linenos">2741</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</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">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2742"><a href="#L-2742"><span class="linenos">2742</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="L-2743"><a href="#L-2743"><span class="linenos">2743</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2744"><a href="#L-2744"><span class="linenos">2744</span></a> +</span><span id="L-2745"><a href="#L-2745"><span class="linenos">2745</span></a> <span class="n">then_expression</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">"then"</span><span class="p">)</span> +</span><span id="L-2746"><a href="#L-2746"><span class="linenos">2746</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> +</span><span id="L-2747"><a href="#L-2747"><span class="linenos">2747</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2748"><a href="#L-2748"><span class="linenos">2748</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> +</span><span id="L-2749"><a href="#L-2749"><span class="linenos">2749</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2750"><a href="#L-2750"><span class="linenos">2750</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="L-2751"><a href="#L-2751"><span class="linenos">2751</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_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">"expressions"</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-2752"><a href="#L-2752"><span class="linenos">2752</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2753"><a href="#L-2753"><span class="linenos">2753</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2754"><a href="#L-2754"><span class="linenos">2754</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2755"><a href="#L-2755"><span class="linenos">2755</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="L-2756"><a href="#L-2756"><span class="linenos">2756</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> +</span><span id="L-2757"><a href="#L-2757"><span class="linenos">2757</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2758"><a href="#L-2758"><span class="linenos">2758</span></a> +</span><span id="L-2759"><a href="#L-2759"><span class="linenos">2759</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</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">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2760"><a href="#L-2760"><span class="linenos">2760</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="L-2761"><a href="#L-2761"><span class="linenos">2761</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="L-2762"><a href="#L-2762"><span class="linenos">2762</span></a> +</span><span id="L-2763"><a href="#L-2763"><span class="linenos">2763</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="n">table</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">"hints"</span><span class="p">)</span> +</span><span id="L-2764"><a href="#L-2764"><span class="linenos">2764</span></a> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="n">table</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">hints</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">):</span> +</span><span id="L-2765"><a href="#L-2765"><span class="linenos">2765</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> +</span><span id="L-2766"><a href="#L-2766"><span class="linenos">2766</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="L-2767"><a href="#L-2767"><span class="linenos">2767</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'alias'</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">())</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2768"><a href="#L-2768"><span class="linenos">2768</span></a> +</span><span id="L-2769"><a href="#L-2769"><span class="linenos">2769</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="L-2770"><a href="#L-2770"><span class="linenos">2770</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2771"><a href="#L-2771"><span class="linenos">2771</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2772"><a href="#L-2772"><span class="linenos">2772</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> </span><span id="L-2773"><a href="#L-2773"><span class="linenos">2773</span></a> -</span><span id="L-2774"><a href="#L-2774"><span class="linenos">2774</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2775"><a href="#L-2775"><span class="linenos">2775</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2776"><a href="#L-2776"><span class="linenos">2776</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-2777"><a href="#L-2777"><span class="linenos">2777</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-2778"><a href="#L-2778"><span class="linenos">2778</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> -</span><span id="L-2779"><a href="#L-2779"><span class="linenos">2779</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2780"><a href="#L-2780"><span class="linenos">2780</span></a> -</span><span id="L-2781"><a href="#L-2781"><span class="linenos">2781</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</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">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2782"><a href="#L-2782"><span class="linenos">2782</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2783"><a href="#L-2783"><span class="linenos">2783</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> -</span><span id="L-2784"><a href="#L-2784"><span class="linenos">2784</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> -</span><span id="L-2785"><a href="#L-2785"><span class="linenos">2785</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2786"><a href="#L-2786"><span class="linenos">2786</span></a> -</span><span id="L-2787"><a href="#L-2787"><span class="linenos">2787</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2788"><a href="#L-2788"><span class="linenos">2788</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2789"><a href="#L-2789"><span class="linenos">2789</span></a> -</span><span id="L-2790"><a href="#L-2790"><span class="linenos">2790</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</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">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2791"><a href="#L-2791"><span class="linenos">2791</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-2792"><a href="#L-2792"><span class="linenos">2792</span></a> -</span><span id="L-2793"><a href="#L-2793"><span class="linenos">2793</span></a> <span class="k">def</span> <span class="nf">clusteredbyproperty_sql</span><span class="p">(</span><span class="bp">self</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">ClusteredByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2794"><a href="#L-2794"><span class="linenos">2794</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2795"><a href="#L-2795"><span class="linenos">2795</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"sorted_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="L-2796"><a href="#L-2796"><span class="linenos">2796</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SORTED BY (</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">sorted_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2797"><a href="#L-2797"><span class="linenos">2797</span></a> <span class="n">buckets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"buckets"</span><span class="p">)</span> -</span><span id="L-2798"><a href="#L-2798"><span class="linenos">2798</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLUSTERED BY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2"> INTO </span><span class="si">{</span><span class="n">buckets</span><span class="si">}</span><span class="s2"> BUCKETS"</span> -</span><span id="L-2799"><a href="#L-2799"><span class="linenos">2799</span></a> -</span><span id="L-2800"><a href="#L-2800"><span class="linenos">2800</span></a> <span class="k">def</span> <span class="nf">anyvalue_sql</span><span class="p">(</span><span class="bp">self</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">AnyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2801"><a href="#L-2801"><span class="linenos">2801</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2802"><a href="#L-2802"><span class="linenos">2802</span></a> <span class="n">having</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">)</span> -</span><span id="L-2803"><a href="#L-2803"><span class="linenos">2803</span></a> -</span><span id="L-2804"><a href="#L-2804"><span class="linenos">2804</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> -</span><span id="L-2805"><a href="#L-2805"><span class="linenos">2805</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> HAVING </span><span class="si">{</span><span class="s1">'MAX'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="s1">'max'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'MIN'</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">having</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2806"><a href="#L-2806"><span class="linenos">2806</span></a> -</span><span id="L-2807"><a href="#L-2807"><span class="linenos">2807</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ANY_VALUE"</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> -</span><span id="L-2808"><a href="#L-2808"><span class="linenos">2808</span></a> -</span><span id="L-2809"><a href="#L-2809"><span class="linenos">2809</span></a> <span class="k">def</span> <span class="nf">querytransform_sql</span><span class="p">(</span><span class="bp">self</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">QueryTransform</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2810"><a href="#L-2810"><span class="linenos">2810</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRANSFORM"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="L-2811"><a href="#L-2811"><span class="linenos">2811</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_before"</span><span class="p">)</span> -</span><span id="L-2812"><a href="#L-2812"><span class="linenos">2812</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_before</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_before</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2813"><a href="#L-2813"><span class="linenos">2813</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_writer"</span><span class="p">)</span> -</span><span id="L-2814"><a href="#L-2814"><span class="linenos">2814</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDWRITER </span><span class="si">{</span><span class="n">record_writer</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_writer</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2815"><a href="#L-2815"><span class="linenos">2815</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'command_script'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2816"><a href="#L-2816"><span class="linenos">2816</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> -</span><span id="L-2817"><a href="#L-2817"><span class="linenos">2817</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2818"><a href="#L-2818"><span class="linenos">2818</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_after"</span><span class="p">)</span> -</span><span id="L-2819"><a href="#L-2819"><span class="linenos">2819</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_after</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2820"><a href="#L-2820"><span class="linenos">2820</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_reader"</span><span class="p">)</span> -</span><span id="L-2821"><a href="#L-2821"><span class="linenos">2821</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDREADER </span><span class="si">{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_reader</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2822"><a href="#L-2822"><span class="linenos">2822</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">transform</span><span class="si">}{</span><span class="n">row_format_before</span><span class="si">}{</span><span class="n">record_writer</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">row_format_after</span><span class="si">}{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2823"><a href="#L-2823"><span class="linenos">2823</span></a> -</span><span id="L-2824"><a href="#L-2824"><span class="linenos">2824</span></a> <span class="k">def</span> <span class="nf">indexconstraintoption_sql</span><span class="p">(</span><span class="bp">self</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">IndexConstraintOption</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2825"><a href="#L-2825"><span class="linenos">2825</span></a> <span class="n">key_block_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"key_block_size"</span><span class="p">)</span> -</span><span id="L-2826"><a href="#L-2826"><span class="linenos">2826</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> -</span><span id="L-2827"><a href="#L-2827"><span class="linenos">2827</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KEY_BLOCK_SIZE = </span><span class="si">{</span><span class="n">key_block_size</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2828"><a href="#L-2828"><span class="linenos">2828</span></a> -</span><span id="L-2829"><a href="#L-2829"><span class="linenos">2829</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="L-2830"><a href="#L-2830"><span class="linenos">2830</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="L-2831"><a href="#L-2831"><span class="linenos">2831</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2832"><a href="#L-2832"><span class="linenos">2832</span></a> -</span><span id="L-2833"><a href="#L-2833"><span class="linenos">2833</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"parser"</span><span class="p">)</span> -</span><span id="L-2834"><a href="#L-2834"><span class="linenos">2834</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="L-2835"><a href="#L-2835"><span class="linenos">2835</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH PARSER </span><span class="si">{</span><span class="n">parser</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2774"><a href="#L-2774"><span class="linenos">2774</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">table_alias</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2775"><a href="#L-2775"><span class="linenos">2775</span></a> +</span><span id="L-2776"><a href="#L-2776"><span class="linenos">2776</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</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">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2777"><a href="#L-2777"><span class="linenos">2777</span></a> <span class="k">if</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">"format"</span><span class="p">):</span> +</span><span id="L-2778"><a href="#L-2778"><span class="linenos">2778</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> +</span><span id="L-2779"><a href="#L-2779"><span class="linenos">2779</span></a> +</span><span id="L-2780"><a href="#L-2780"><span class="linenos">2780</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> +</span><span id="L-2781"><a href="#L-2781"><span class="linenos">2781</span></a> +</span><span id="L-2782"><a href="#L-2782"><span class="linenos">2782</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2783"><a href="#L-2783"><span class="linenos">2783</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2784"><a href="#L-2784"><span class="linenos">2784</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-2785"><a href="#L-2785"><span class="linenos">2785</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-2786"><a href="#L-2786"><span class="linenos">2786</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> +</span><span id="L-2787"><a href="#L-2787"><span class="linenos">2787</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2788"><a href="#L-2788"><span class="linenos">2788</span></a> +</span><span id="L-2789"><a href="#L-2789"><span class="linenos">2789</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</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">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2790"><a href="#L-2790"><span class="linenos">2790</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2791"><a href="#L-2791"><span class="linenos">2791</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> +</span><span id="L-2792"><a href="#L-2792"><span class="linenos">2792</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> +</span><span id="L-2793"><a href="#L-2793"><span class="linenos">2793</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2794"><a href="#L-2794"><span class="linenos">2794</span></a> +</span><span id="L-2795"><a href="#L-2795"><span class="linenos">2795</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2796"><a href="#L-2796"><span class="linenos">2796</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2797"><a href="#L-2797"><span class="linenos">2797</span></a> +</span><span id="L-2798"><a href="#L-2798"><span class="linenos">2798</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</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">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2799"><a href="#L-2799"><span class="linenos">2799</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-2800"><a href="#L-2800"><span class="linenos">2800</span></a> +</span><span id="L-2801"><a href="#L-2801"><span class="linenos">2801</span></a> <span class="k">def</span> <span class="nf">clusteredbyproperty_sql</span><span class="p">(</span><span class="bp">self</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">ClusteredByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2802"><a href="#L-2802"><span class="linenos">2802</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2803"><a href="#L-2803"><span class="linenos">2803</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"sorted_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="L-2804"><a href="#L-2804"><span class="linenos">2804</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SORTED BY (</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">sorted_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2805"><a href="#L-2805"><span class="linenos">2805</span></a> <span class="n">buckets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"buckets"</span><span class="p">)</span> +</span><span id="L-2806"><a href="#L-2806"><span class="linenos">2806</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLUSTERED BY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2"> INTO </span><span class="si">{</span><span class="n">buckets</span><span class="si">}</span><span class="s2"> BUCKETS"</span> +</span><span id="L-2807"><a href="#L-2807"><span class="linenos">2807</span></a> +</span><span id="L-2808"><a href="#L-2808"><span class="linenos">2808</span></a> <span class="k">def</span> <span class="nf">anyvalue_sql</span><span class="p">(</span><span class="bp">self</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">AnyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2809"><a href="#L-2809"><span class="linenos">2809</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2810"><a href="#L-2810"><span class="linenos">2810</span></a> <span class="n">having</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">)</span> +</span><span id="L-2811"><a href="#L-2811"><span class="linenos">2811</span></a> +</span><span id="L-2812"><a href="#L-2812"><span class="linenos">2812</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> +</span><span id="L-2813"><a href="#L-2813"><span class="linenos">2813</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> HAVING </span><span class="si">{</span><span class="s1">'MAX'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="s1">'max'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'MIN'</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">having</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2814"><a href="#L-2814"><span class="linenos">2814</span></a> +</span><span id="L-2815"><a href="#L-2815"><span class="linenos">2815</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ANY_VALUE"</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> +</span><span id="L-2816"><a href="#L-2816"><span class="linenos">2816</span></a> +</span><span id="L-2817"><a href="#L-2817"><span class="linenos">2817</span></a> <span class="k">def</span> <span class="nf">querytransform_sql</span><span class="p">(</span><span class="bp">self</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">QueryTransform</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2818"><a href="#L-2818"><span class="linenos">2818</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRANSFORM"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="L-2819"><a href="#L-2819"><span class="linenos">2819</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_before"</span><span class="p">)</span> +</span><span id="L-2820"><a href="#L-2820"><span class="linenos">2820</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_before</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_before</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2821"><a href="#L-2821"><span class="linenos">2821</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_writer"</span><span class="p">)</span> +</span><span id="L-2822"><a href="#L-2822"><span class="linenos">2822</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDWRITER </span><span class="si">{</span><span class="n">record_writer</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_writer</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2823"><a href="#L-2823"><span class="linenos">2823</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'command_script'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2824"><a href="#L-2824"><span class="linenos">2824</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="L-2825"><a href="#L-2825"><span class="linenos">2825</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2826"><a href="#L-2826"><span class="linenos">2826</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_after"</span><span class="p">)</span> +</span><span id="L-2827"><a href="#L-2827"><span class="linenos">2827</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_after</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2828"><a href="#L-2828"><span class="linenos">2828</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_reader"</span><span class="p">)</span> +</span><span id="L-2829"><a href="#L-2829"><span class="linenos">2829</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDREADER </span><span class="si">{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_reader</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2830"><a href="#L-2830"><span class="linenos">2830</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">transform</span><span class="si">}{</span><span class="n">row_format_before</span><span class="si">}{</span><span class="n">record_writer</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">row_format_after</span><span class="si">}{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2831"><a href="#L-2831"><span class="linenos">2831</span></a> +</span><span id="L-2832"><a href="#L-2832"><span class="linenos">2832</span></a> <span class="k">def</span> <span class="nf">indexconstraintoption_sql</span><span class="p">(</span><span class="bp">self</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">IndexConstraintOption</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2833"><a href="#L-2833"><span class="linenos">2833</span></a> <span class="n">key_block_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"key_block_size"</span><span class="p">)</span> +</span><span id="L-2834"><a href="#L-2834"><span class="linenos">2834</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> +</span><span id="L-2835"><a href="#L-2835"><span class="linenos">2835</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KEY_BLOCK_SIZE = </span><span class="si">{</span><span class="n">key_block_size</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2836"><a href="#L-2836"><span class="linenos">2836</span></a> -</span><span id="L-2837"><a href="#L-2837"><span class="linenos">2837</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"comment"</span><span class="p">)</span> -</span><span id="L-2838"><a href="#L-2838"><span class="linenos">2838</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> -</span><span id="L-2839"><a href="#L-2839"><span class="linenos">2839</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT </span><span class="si">{</span><span class="n">comment</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2837"><a href="#L-2837"><span class="linenos">2837</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="L-2838"><a href="#L-2838"><span class="linenos">2838</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="L-2839"><a href="#L-2839"><span class="linenos">2839</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2840"><a href="#L-2840"><span class="linenos">2840</span></a> -</span><span id="L-2841"><a href="#L-2841"><span class="linenos">2841</span></a> <span class="n">visible</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">"visible"</span><span class="p">)</span> -</span><span id="L-2842"><a href="#L-2842"><span class="linenos">2842</span></a> <span class="k">if</span> <span class="n">visible</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="L-2843"><a href="#L-2843"><span class="linenos">2843</span></a> <span class="k">return</span> <span class="s2">"VISIBLE"</span> <span class="k">if</span> <span class="n">visible</span> <span class="k">else</span> <span class="s2">"INVISIBLE"</span> +</span><span id="L-2841"><a href="#L-2841"><span class="linenos">2841</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"parser"</span><span class="p">)</span> +</span><span id="L-2842"><a href="#L-2842"><span class="linenos">2842</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="L-2843"><a href="#L-2843"><span class="linenos">2843</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH PARSER </span><span class="si">{</span><span class="n">parser</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2844"><a href="#L-2844"><span class="linenos">2844</span></a> -</span><span id="L-2845"><a href="#L-2845"><span class="linenos">2845</span></a> <span class="n">engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"engine_attr"</span><span class="p">)</span> -</span><span id="L-2846"><a href="#L-2846"><span class="linenos">2846</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> -</span><span id="L-2847"><a href="#L-2847"><span class="linenos">2847</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2845"><a href="#L-2845"><span class="linenos">2845</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"comment"</span><span class="p">)</span> +</span><span id="L-2846"><a href="#L-2846"><span class="linenos">2846</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> +</span><span id="L-2847"><a href="#L-2847"><span class="linenos">2847</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT </span><span class="si">{</span><span class="n">comment</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2848"><a href="#L-2848"><span class="linenos">2848</span></a> -</span><span id="L-2849"><a href="#L-2849"><span class="linenos">2849</span></a> <span class="n">secondary_engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"secondary_engine_attr"</span><span class="p">)</span> -</span><span id="L-2850"><a href="#L-2850"><span class="linenos">2850</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> -</span><span id="L-2851"><a href="#L-2851"><span class="linenos">2851</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SECONDARY_ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">secondary_engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2849"><a href="#L-2849"><span class="linenos">2849</span></a> <span class="n">visible</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">"visible"</span><span class="p">)</span> +</span><span id="L-2850"><a href="#L-2850"><span class="linenos">2850</span></a> <span class="k">if</span> <span class="n">visible</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="L-2851"><a href="#L-2851"><span class="linenos">2851</span></a> <span class="k">return</span> <span class="s2">"VISIBLE"</span> <span class="k">if</span> <span class="n">visible</span> <span class="k">else</span> <span class="s2">"INVISIBLE"</span> </span><span id="L-2852"><a href="#L-2852"><span class="linenos">2852</span></a> -</span><span id="L-2853"><a href="#L-2853"><span class="linenos">2853</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported index constraint option."</span><span class="p">)</span> -</span><span id="L-2854"><a href="#L-2854"><span class="linenos">2854</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="L-2855"><a href="#L-2855"><span class="linenos">2855</span></a> -</span><span id="L-2856"><a href="#L-2856"><span class="linenos">2856</span></a> <span class="k">def</span> <span class="nf">indexcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</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">IndexColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2857"><a href="#L-2857"><span class="linenos">2857</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="L-2858"><a href="#L-2858"><span class="linenos">2858</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> INDEX"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">"INDEX"</span> -</span><span id="L-2859"><a href="#L-2859"><span class="linenos">2859</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2860"><a href="#L-2860"><span class="linenos">2860</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2861"><a href="#L-2861"><span class="linenos">2861</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"index_type"</span><span class="p">)</span> -</span><span id="L-2862"><a href="#L-2862"><span class="linenos">2862</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">index_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2863"><a href="#L-2863"><span class="linenos">2863</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> -</span><span id="L-2864"><a href="#L-2864"><span class="linenos">2864</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2865"><a href="#L-2865"><span class="linenos">2865</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="L-2866"><a href="#L-2866"><span class="linenos">2866</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2867"><a href="#L-2867"><span class="linenos">2867</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">index_type</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2868"><a href="#L-2868"><span class="linenos">2868</span></a> -</span><span id="L-2869"><a href="#L-2869"><span class="linenos">2869</span></a> <span class="k">def</span> <span class="nf">nvl2_sql</span><span class="p">(</span><span class="bp">self</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">Nvl2</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2870"><a href="#L-2870"><span class="linenos">2870</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">NVL2_SUPPORTED</span><span class="p">:</span> -</span><span id="L-2871"><a href="#L-2871"><span class="linenos">2871</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="L-2872"><a href="#L-2872"><span class="linenos">2872</span></a> -</span><span id="L-2873"><a href="#L-2873"><span class="linenos">2873</span></a> <span class="n">case</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span> -</span><span id="L-2874"><a href="#L-2874"><span class="linenos">2874</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">())</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="L-2875"><a href="#L-2875"><span class="linenos">2875</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"true"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> -</span><span id="L-2876"><a href="#L-2876"><span class="linenos">2876</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="L-2877"><a href="#L-2877"><span class="linenos">2877</span></a> <span class="p">)</span> -</span><span id="L-2878"><a href="#L-2878"><span class="linenos">2878</span></a> <span class="n">else_cond</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">"false"</span><span class="p">)</span> -</span><span id="L-2879"><a href="#L-2879"><span class="linenos">2879</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> -</span><span id="L-2880"><a href="#L-2880"><span class="linenos">2880</span></a> <span class="k">case</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">else_cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="L-2881"><a href="#L-2881"><span class="linenos">2881</span></a> -</span><span id="L-2882"><a href="#L-2882"><span class="linenos">2882</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> -</span><span id="L-2883"><a href="#L-2883"><span class="linenos">2883</span></a> -</span><span id="L-2884"><a href="#L-2884"><span class="linenos">2884</span></a> <span class="k">def</span> <span class="nf">comprehension_sql</span><span class="p">(</span><span class="bp">self</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">Comprehension</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2885"><a href="#L-2885"><span class="linenos">2885</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2886"><a href="#L-2886"><span class="linenos">2886</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-2887"><a href="#L-2887"><span class="linenos">2887</span></a> <span class="n">iterator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"iterator"</span><span class="p">)</span> -</span><span id="L-2888"><a href="#L-2888"><span class="linenos">2888</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="L-2889"><a href="#L-2889"><span class="linenos">2889</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" IF </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="L-2890"><a href="#L-2890"><span class="linenos">2890</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">iterator</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2853"><a href="#L-2853"><span class="linenos">2853</span></a> <span class="n">engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"engine_attr"</span><span class="p">)</span> +</span><span id="L-2854"><a href="#L-2854"><span class="linenos">2854</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> +</span><span id="L-2855"><a href="#L-2855"><span class="linenos">2855</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2856"><a href="#L-2856"><span class="linenos">2856</span></a> +</span><span id="L-2857"><a href="#L-2857"><span class="linenos">2857</span></a> <span class="n">secondary_engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"secondary_engine_attr"</span><span class="p">)</span> +</span><span id="L-2858"><a href="#L-2858"><span class="linenos">2858</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> +</span><span id="L-2859"><a href="#L-2859"><span class="linenos">2859</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SECONDARY_ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">secondary_engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2860"><a href="#L-2860"><span class="linenos">2860</span></a> +</span><span id="L-2861"><a href="#L-2861"><span class="linenos">2861</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported index constraint option."</span><span class="p">)</span> +</span><span id="L-2862"><a href="#L-2862"><span class="linenos">2862</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="L-2863"><a href="#L-2863"><span class="linenos">2863</span></a> +</span><span id="L-2864"><a href="#L-2864"><span class="linenos">2864</span></a> <span class="k">def</span> <span class="nf">indexcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</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">IndexColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2865"><a href="#L-2865"><span class="linenos">2865</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="L-2866"><a href="#L-2866"><span class="linenos">2866</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> INDEX"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">"INDEX"</span> +</span><span id="L-2867"><a href="#L-2867"><span class="linenos">2867</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2868"><a href="#L-2868"><span class="linenos">2868</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2869"><a href="#L-2869"><span class="linenos">2869</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"index_type"</span><span class="p">)</span> +</span><span id="L-2870"><a href="#L-2870"><span class="linenos">2870</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">index_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2871"><a href="#L-2871"><span class="linenos">2871</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="L-2872"><a href="#L-2872"><span class="linenos">2872</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2873"><a href="#L-2873"><span class="linenos">2873</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="L-2874"><a href="#L-2874"><span class="linenos">2874</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2875"><a href="#L-2875"><span class="linenos">2875</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">index_type</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2876"><a href="#L-2876"><span class="linenos">2876</span></a> +</span><span id="L-2877"><a href="#L-2877"><span class="linenos">2877</span></a> <span class="k">def</span> <span class="nf">nvl2_sql</span><span class="p">(</span><span class="bp">self</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">Nvl2</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2878"><a href="#L-2878"><span class="linenos">2878</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">NVL2_SUPPORTED</span><span class="p">:</span> +</span><span id="L-2879"><a href="#L-2879"><span class="linenos">2879</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="L-2880"><a href="#L-2880"><span class="linenos">2880</span></a> +</span><span id="L-2881"><a href="#L-2881"><span class="linenos">2881</span></a> <span class="n">case</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span> +</span><span id="L-2882"><a href="#L-2882"><span class="linenos">2882</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">())</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="L-2883"><a href="#L-2883"><span class="linenos">2883</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"true"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> +</span><span id="L-2884"><a href="#L-2884"><span class="linenos">2884</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="L-2885"><a href="#L-2885"><span class="linenos">2885</span></a> <span class="p">)</span> +</span><span id="L-2886"><a href="#L-2886"><span class="linenos">2886</span></a> <span class="n">else_cond</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">"false"</span><span class="p">)</span> +</span><span id="L-2887"><a href="#L-2887"><span class="linenos">2887</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> +</span><span id="L-2888"><a href="#L-2888"><span class="linenos">2888</span></a> <span class="k">case</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">else_cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="L-2889"><a href="#L-2889"><span class="linenos">2889</span></a> +</span><span id="L-2890"><a href="#L-2890"><span class="linenos">2890</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> </span><span id="L-2891"><a href="#L-2891"><span class="linenos">2891</span></a> -</span><span id="L-2892"><a href="#L-2892"><span class="linenos">2892</span></a> <span class="k">def</span> <span class="nf">columnprefix_sql</span><span class="p">(</span><span class="bp">self</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">ColumnPrefix</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2893"><a href="#L-2893"><span class="linenos">2893</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="L-2894"><a href="#L-2894"><span class="linenos">2894</span></a> -</span><span id="L-2895"><a href="#L-2895"><span class="linenos">2895</span></a> <span class="k">def</span> <span class="nf">opclass_sql</span><span class="p">(</span><span class="bp">self</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">Opclass</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2896"><a href="#L-2896"><span class="linenos">2896</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2897"><a href="#L-2897"><span class="linenos">2897</span></a> -</span><span id="L-2898"><a href="#L-2898"><span class="linenos">2898</span></a> <span class="k">def</span> <span class="nf">predict_sql</span><span class="p">(</span><span class="bp">self</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">Predict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="L-2899"><a href="#L-2899"><span class="linenos">2899</span></a> <span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="L-2900"><a href="#L-2900"><span class="linenos">2900</span></a> <span class="n">model</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"MODEL </span><span class="si">{</span><span class="n">model</span><span class="si">}</span><span class="s2">"</span> -</span><span id="L-2901"><a href="#L-2901"><span class="linenos">2901</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="L-2902"><a href="#L-2902"><span class="linenos">2902</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Subquery</span><span class="p">)</span> <span class="k">else</span> <span class="n">table</span> -</span><span id="L-2903"><a href="#L-2903"><span class="linenos">2903</span></a> <span class="n">parameters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"params_struct"</span><span class="p">)</span> -</span><span id="L-2904"><a href="#L-2904"><span class="linenos">2904</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"PREDICT"</span><span class="p">,</span> <span class="n">model</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">parameters</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-2892"><a href="#L-2892"><span class="linenos">2892</span></a> <span class="k">def</span> <span class="nf">comprehension_sql</span><span class="p">(</span><span class="bp">self</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">Comprehension</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2893"><a href="#L-2893"><span class="linenos">2893</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2894"><a href="#L-2894"><span class="linenos">2894</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-2895"><a href="#L-2895"><span class="linenos">2895</span></a> <span class="n">iterator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"iterator"</span><span class="p">)</span> +</span><span id="L-2896"><a href="#L-2896"><span class="linenos">2896</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="L-2897"><a href="#L-2897"><span class="linenos">2897</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" IF </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="L-2898"><a href="#L-2898"><span class="linenos">2898</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">iterator</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2899"><a href="#L-2899"><span class="linenos">2899</span></a> +</span><span id="L-2900"><a href="#L-2900"><span class="linenos">2900</span></a> <span class="k">def</span> <span class="nf">columnprefix_sql</span><span class="p">(</span><span class="bp">self</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">ColumnPrefix</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2901"><a href="#L-2901"><span class="linenos">2901</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="L-2902"><a href="#L-2902"><span class="linenos">2902</span></a> +</span><span id="L-2903"><a href="#L-2903"><span class="linenos">2903</span></a> <span class="k">def</span> <span class="nf">opclass_sql</span><span class="p">(</span><span class="bp">self</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">Opclass</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2904"><a href="#L-2904"><span class="linenos">2904</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="L-2905"><a href="#L-2905"><span class="linenos">2905</span></a> -</span><span id="L-2906"><a href="#L-2906"><span class="linenos">2906</span></a> -</span><span id="L-2907"><a href="#L-2907"><span class="linenos">2907</span></a><span class="k">def</span> <span class="nf">cached_generator</span><span class="p">(</span> -</span><span id="L-2908"><a href="#L-2908"><span class="linenos">2908</span></a> <span class="n">cache</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="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="L-2909"><a href="#L-2909"><span class="linenos">2909</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</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="nb">str</span><span class="p">]:</span> -</span><span id="L-2910"><a href="#L-2910"><span class="linenos">2910</span></a><span class="w"> </span><span class="sd">"""Returns a cached generator."""</span> -</span><span id="L-2911"><a href="#L-2911"><span class="linenos">2911</span></a> <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">cache</span> -</span><span id="L-2912"><a href="#L-2912"><span class="linenos">2912</span></a> <span class="n">generator</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="s2">"safe"</span><span class="p">)</span> -</span><span id="L-2913"><a href="#L-2913"><span class="linenos">2913</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> +</span><span id="L-2906"><a href="#L-2906"><span class="linenos">2906</span></a> <span class="k">def</span> <span class="nf">predict_sql</span><span class="p">(</span><span class="bp">self</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">Predict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="L-2907"><a href="#L-2907"><span class="linenos">2907</span></a> <span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="L-2908"><a href="#L-2908"><span class="linenos">2908</span></a> <span class="n">model</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"MODEL </span><span class="si">{</span><span class="n">model</span><span class="si">}</span><span class="s2">"</span> +</span><span id="L-2909"><a href="#L-2909"><span class="linenos">2909</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="L-2910"><a href="#L-2910"><span class="linenos">2910</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Subquery</span><span class="p">)</span> <span class="k">else</span> <span class="n">table</span> +</span><span id="L-2911"><a href="#L-2911"><span class="linenos">2911</span></a> <span class="n">parameters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"params_struct"</span><span class="p">)</span> +</span><span id="L-2912"><a href="#L-2912"><span class="linenos">2912</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"PREDICT"</span><span class="p">,</span> <span class="n">model</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">parameters</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="L-2913"><a href="#L-2913"><span class="linenos">2913</span></a> +</span><span id="L-2914"><a href="#L-2914"><span class="linenos">2914</span></a> +</span><span id="L-2915"><a href="#L-2915"><span class="linenos">2915</span></a><span class="k">def</span> <span class="nf">cached_generator</span><span class="p">(</span> +</span><span id="L-2916"><a href="#L-2916"><span class="linenos">2916</span></a> <span class="n">cache</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="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="L-2917"><a href="#L-2917"><span class="linenos">2917</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</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="nb">str</span><span class="p">]:</span> +</span><span id="L-2918"><a href="#L-2918"><span class="linenos">2918</span></a><span class="w"> </span><span class="sd">"""Returns a cached generator."""</span> +</span><span id="L-2919"><a href="#L-2919"><span class="linenos">2919</span></a> <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">cache</span> +</span><span id="L-2920"><a href="#L-2920"><span class="linenos">2920</span></a> <span class="n">generator</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="s2">"safe"</span><span class="p">)</span> +</span><span id="L-2921"><a href="#L-2921"><span class="linenos">2921</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> </span></pre></div> @@ -6223,729 +6234,737 @@ </span><span id="Generator-2180"><a href="#Generator-2180"><span class="linenos">2180</span></a> <span class="p">)</span> </span><span id="Generator-2181"><a href="#Generator-2181"><span class="linenos">2181</span></a> </span><span id="Generator-2182"><a href="#Generator-2182"><span class="linenos">2182</span></a> <span class="k">def</span> <span class="nf">jsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">JSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2183"><a href="#Generator-2183"><span class="linenos">2183</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2184"><a href="#Generator-2184"><span class="linenos">2184</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-2185"><a href="#Generator-2185"><span class="linenos">2185</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2186"><a href="#Generator-2186"><span class="linenos">2186</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator-2187"><a href="#Generator-2187"><span class="linenos">2187</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PATH </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2188"><a href="#Generator-2188"><span class="linenos">2188</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2183"><a href="#Generator-2183"><span class="linenos">2183</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator-2184"><a href="#Generator-2184"><span class="linenos">2184</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PATH </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2185"><a href="#Generator-2185"><span class="linenos">2185</span></a> <span class="n">nested_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"nested_schema"</span><span class="p">)</span> +</span><span id="Generator-2186"><a href="#Generator-2186"><span class="linenos">2186</span></a> +</span><span id="Generator-2187"><a href="#Generator-2187"><span class="linenos">2187</span></a> <span class="k">if</span> <span class="n">nested_schema</span><span class="p">:</span> +</span><span id="Generator-2188"><a href="#Generator-2188"><span class="linenos">2188</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NESTED</span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">nested_schema</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2189"><a href="#Generator-2189"><span class="linenos">2189</span></a> -</span><span id="Generator-2190"><a href="#Generator-2190"><span class="linenos">2190</span></a> <span class="k">def</span> <span class="nf">jsontable_sql</span><span class="p">(</span><span class="bp">self</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">JSONTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2191"><a href="#Generator-2191"><span class="linenos">2191</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2192"><a href="#Generator-2192"><span class="linenos">2192</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator-2193"><a href="#Generator-2193"><span class="linenos">2193</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2194"><a href="#Generator-2194"><span class="linenos">2194</span></a> <span class="n">error_handling</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">"error_handling"</span><span class="p">)</span> -</span><span id="Generator-2195"><a href="#Generator-2195"><span class="linenos">2195</span></a> <span class="n">error_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">error_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">error_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2196"><a href="#Generator-2196"><span class="linenos">2196</span></a> <span class="n">empty_handling</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">"empty_handling"</span><span class="p">)</span> -</span><span id="Generator-2197"><a href="#Generator-2197"><span class="linenos">2197</span></a> <span class="n">empty_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">empty_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2198"><a href="#Generator-2198"><span class="linenos">2198</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLUMNS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2199"><a href="#Generator-2199"><span class="linenos">2199</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Generator-2200"><a href="#Generator-2200"><span class="linenos">2200</span></a> <span class="s2">"JSON_TABLE"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">path</span><span class="si">}{</span><span class="n">error_handling</span><span class="si">}{</span><span class="n">empty_handling</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2201"><a href="#Generator-2201"><span class="linenos">2201</span></a> <span class="p">)</span> -</span><span id="Generator-2202"><a href="#Generator-2202"><span class="linenos">2202</span></a> -</span><span id="Generator-2203"><a href="#Generator-2203"><span class="linenos">2203</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2204"><a href="#Generator-2204"><span class="linenos">2204</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2205"><a href="#Generator-2205"><span class="linenos">2205</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-2206"><a href="#Generator-2206"><span class="linenos">2206</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator-2207"><a href="#Generator-2207"><span class="linenos">2207</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2208"><a href="#Generator-2208"><span class="linenos">2208</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</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">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2209"><a href="#Generator-2209"><span class="linenos">2209</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2190"><a href="#Generator-2190"><span class="linenos">2190</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2191"><a href="#Generator-2191"><span class="linenos">2191</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-2192"><a href="#Generator-2192"><span class="linenos">2192</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2193"><a href="#Generator-2193"><span class="linenos">2193</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2194"><a href="#Generator-2194"><span class="linenos">2194</span></a> +</span><span id="Generator-2195"><a href="#Generator-2195"><span class="linenos">2195</span></a> <span class="k">def</span> <span class="nf">jsonschema_sql</span><span class="p">(</span><span class="bp">self</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">JSONSchema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2196"><a href="#Generator-2196"><span class="linenos">2196</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COLUMNS"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-2197"><a href="#Generator-2197"><span class="linenos">2197</span></a> +</span><span id="Generator-2198"><a href="#Generator-2198"><span class="linenos">2198</span></a> <span class="k">def</span> <span class="nf">jsontable_sql</span><span class="p">(</span><span class="bp">self</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">JSONTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2199"><a href="#Generator-2199"><span class="linenos">2199</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2200"><a href="#Generator-2200"><span class="linenos">2200</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator-2201"><a href="#Generator-2201"><span class="linenos">2201</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2202"><a href="#Generator-2202"><span class="linenos">2202</span></a> <span class="n">error_handling</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">"error_handling"</span><span class="p">)</span> +</span><span id="Generator-2203"><a href="#Generator-2203"><span class="linenos">2203</span></a> <span class="n">error_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">error_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">error_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2204"><a href="#Generator-2204"><span class="linenos">2204</span></a> <span class="n">empty_handling</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">"empty_handling"</span><span class="p">)</span> +</span><span id="Generator-2205"><a href="#Generator-2205"><span class="linenos">2205</span></a> <span class="n">empty_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">empty_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2206"><a href="#Generator-2206"><span class="linenos">2206</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="Generator-2207"><a href="#Generator-2207"><span class="linenos">2207</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Generator-2208"><a href="#Generator-2208"><span class="linenos">2208</span></a> <span class="s2">"JSON_TABLE"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">path</span><span class="si">}{</span><span class="n">error_handling</span><span class="si">}{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2209"><a href="#Generator-2209"><span class="linenos">2209</span></a> <span class="p">)</span> </span><span id="Generator-2210"><a href="#Generator-2210"><span class="linenos">2210</span></a> -</span><span id="Generator-2211"><a href="#Generator-2211"><span class="linenos">2211</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2211"><a href="#Generator-2211"><span class="linenos">2211</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="Generator-2212"><a href="#Generator-2212"><span class="linenos">2212</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2213"><a href="#Generator-2213"><span class="linenos">2213</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator-2214"><a href="#Generator-2214"><span class="linenos">2214</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2215"><a href="#Generator-2215"><span class="linenos">2215</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2216"><a href="#Generator-2216"><span class="linenos">2216</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-2217"><a href="#Generator-2217"><span class="linenos">2217</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2218"><a href="#Generator-2218"><span class="linenos">2218</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="Generator-2219"><a href="#Generator-2219"><span class="linenos">2219</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2220"><a href="#Generator-2220"><span class="linenos">2220</span></a> <span class="p">)</span> -</span><span id="Generator-2221"><a href="#Generator-2221"><span class="linenos">2221</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2222"><a href="#Generator-2222"><span class="linenos">2222</span></a> -</span><span id="Generator-2223"><a href="#Generator-2223"><span class="linenos">2223</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</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">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2224"><a href="#Generator-2224"><span class="linenos">2224</span></a> <span class="n">query</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">"query"</span><span class="p">)</span> -</span><span id="Generator-2225"><a href="#Generator-2225"><span class="linenos">2225</span></a> <span class="n">unnest</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">"unnest"</span><span class="p">)</span> -</span><span id="Generator-2226"><a href="#Generator-2226"><span class="linenos">2226</span></a> <span class="n">field</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">"field"</span><span class="p">)</span> -</span><span id="Generator-2227"><a href="#Generator-2227"><span class="linenos">2227</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</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">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2228"><a href="#Generator-2228"><span class="linenos">2228</span></a> -</span><span id="Generator-2229"><a href="#Generator-2229"><span class="linenos">2229</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="Generator-2230"><a href="#Generator-2230"><span class="linenos">2230</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> -</span><span id="Generator-2231"><a href="#Generator-2231"><span class="linenos">2231</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="Generator-2232"><a href="#Generator-2232"><span class="linenos">2232</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> -</span><span id="Generator-2233"><a href="#Generator-2233"><span class="linenos">2233</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="Generator-2234"><a href="#Generator-2234"><span class="linenos">2234</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> -</span><span id="Generator-2235"><a href="#Generator-2235"><span class="linenos">2235</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2236"><a href="#Generator-2236"><span class="linenos">2236</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2237"><a href="#Generator-2237"><span class="linenos">2237</span></a> -</span><span id="Generator-2238"><a href="#Generator-2238"><span class="linenos">2238</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2239"><a href="#Generator-2239"><span class="linenos">2239</span></a> -</span><span id="Generator-2240"><a href="#Generator-2240"><span class="linenos">2240</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2241"><a href="#Generator-2241"><span class="linenos">2241</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2242"><a href="#Generator-2242"><span class="linenos">2242</span></a> -</span><span id="Generator-2243"><a href="#Generator-2243"><span class="linenos">2243</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2244"><a href="#Generator-2244"><span class="linenos">2244</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Generator-2245"><a href="#Generator-2245"><span class="linenos">2245</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="Generator-2246"><a href="#Generator-2246"><span class="linenos">2246</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> -</span><span id="Generator-2247"><a href="#Generator-2247"><span class="linenos">2247</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2248"><a href="#Generator-2248"><span class="linenos">2248</span></a> -</span><span id="Generator-2249"><a href="#Generator-2249"><span class="linenos">2249</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> -</span><span id="Generator-2250"><a href="#Generator-2250"><span class="linenos">2250</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2251"><a href="#Generator-2251"><span class="linenos">2251</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2252"><a href="#Generator-2252"><span class="linenos">2252</span></a> -</span><span id="Generator-2253"><a href="#Generator-2253"><span class="linenos">2253</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2254"><a href="#Generator-2254"><span class="linenos">2254</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Generator-2255"><a href="#Generator-2255"><span class="linenos">2255</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> -</span><span id="Generator-2256"><a href="#Generator-2256"><span class="linenos">2256</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2257"><a href="#Generator-2257"><span class="linenos">2257</span></a> -</span><span id="Generator-2258"><a href="#Generator-2258"><span class="linenos">2258</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2259"><a href="#Generator-2259"><span class="linenos">2259</span></a> -</span><span id="Generator-2260"><a href="#Generator-2260"><span class="linenos">2260</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</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">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2261"><a href="#Generator-2261"><span class="linenos">2261</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2262"><a href="#Generator-2262"><span class="linenos">2262</span></a> -</span><span id="Generator-2263"><a href="#Generator-2263"><span class="linenos">2263</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</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">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2264"><a href="#Generator-2264"><span class="linenos">2264</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2265"><a href="#Generator-2265"><span class="linenos">2265</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2266"><a href="#Generator-2266"><span class="linenos">2266</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2267"><a href="#Generator-2267"><span class="linenos">2267</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-2268"><a href="#Generator-2268"><span class="linenos">2268</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2269"><a href="#Generator-2269"><span class="linenos">2269</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2213"><a href="#Generator-2213"><span class="linenos">2213</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-2214"><a href="#Generator-2214"><span class="linenos">2214</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator-2215"><a href="#Generator-2215"><span class="linenos">2215</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2216"><a href="#Generator-2216"><span class="linenos">2216</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</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">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2217"><a href="#Generator-2217"><span class="linenos">2217</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2218"><a href="#Generator-2218"><span class="linenos">2218</span></a> +</span><span id="Generator-2219"><a href="#Generator-2219"><span class="linenos">2219</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2220"><a href="#Generator-2220"><span class="linenos">2220</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2221"><a href="#Generator-2221"><span class="linenos">2221</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator-2222"><a href="#Generator-2222"><span class="linenos">2222</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2223"><a href="#Generator-2223"><span class="linenos">2223</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2224"><a href="#Generator-2224"><span class="linenos">2224</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-2225"><a href="#Generator-2225"><span class="linenos">2225</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2226"><a href="#Generator-2226"><span class="linenos">2226</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="Generator-2227"><a href="#Generator-2227"><span class="linenos">2227</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2228"><a href="#Generator-2228"><span class="linenos">2228</span></a> <span class="p">)</span> +</span><span id="Generator-2229"><a href="#Generator-2229"><span class="linenos">2229</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2230"><a href="#Generator-2230"><span class="linenos">2230</span></a> +</span><span id="Generator-2231"><a href="#Generator-2231"><span class="linenos">2231</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</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">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2232"><a href="#Generator-2232"><span class="linenos">2232</span></a> <span class="n">query</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">"query"</span><span class="p">)</span> +</span><span id="Generator-2233"><a href="#Generator-2233"><span class="linenos">2233</span></a> <span class="n">unnest</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">"unnest"</span><span class="p">)</span> +</span><span id="Generator-2234"><a href="#Generator-2234"><span class="linenos">2234</span></a> <span class="n">field</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">"field"</span><span class="p">)</span> +</span><span id="Generator-2235"><a href="#Generator-2235"><span class="linenos">2235</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</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">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2236"><a href="#Generator-2236"><span class="linenos">2236</span></a> +</span><span id="Generator-2237"><a href="#Generator-2237"><span class="linenos">2237</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="Generator-2238"><a href="#Generator-2238"><span class="linenos">2238</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> +</span><span id="Generator-2239"><a href="#Generator-2239"><span class="linenos">2239</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="Generator-2240"><a href="#Generator-2240"><span class="linenos">2240</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> +</span><span id="Generator-2241"><a href="#Generator-2241"><span class="linenos">2241</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="Generator-2242"><a href="#Generator-2242"><span class="linenos">2242</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> +</span><span id="Generator-2243"><a href="#Generator-2243"><span class="linenos">2243</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2244"><a href="#Generator-2244"><span class="linenos">2244</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2245"><a href="#Generator-2245"><span class="linenos">2245</span></a> +</span><span id="Generator-2246"><a href="#Generator-2246"><span class="linenos">2246</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2247"><a href="#Generator-2247"><span class="linenos">2247</span></a> +</span><span id="Generator-2248"><a href="#Generator-2248"><span class="linenos">2248</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2249"><a href="#Generator-2249"><span class="linenos">2249</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2250"><a href="#Generator-2250"><span class="linenos">2250</span></a> +</span><span id="Generator-2251"><a href="#Generator-2251"><span class="linenos">2251</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2252"><a href="#Generator-2252"><span class="linenos">2252</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Generator-2253"><a href="#Generator-2253"><span class="linenos">2253</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> +</span><span id="Generator-2254"><a href="#Generator-2254"><span class="linenos">2254</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> +</span><span id="Generator-2255"><a href="#Generator-2255"><span class="linenos">2255</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2256"><a href="#Generator-2256"><span class="linenos">2256</span></a> +</span><span id="Generator-2257"><a href="#Generator-2257"><span class="linenos">2257</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> +</span><span id="Generator-2258"><a href="#Generator-2258"><span class="linenos">2258</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2259"><a href="#Generator-2259"><span class="linenos">2259</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2260"><a href="#Generator-2260"><span class="linenos">2260</span></a> +</span><span id="Generator-2261"><a href="#Generator-2261"><span class="linenos">2261</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2262"><a href="#Generator-2262"><span class="linenos">2262</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Generator-2263"><a href="#Generator-2263"><span class="linenos">2263</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> +</span><span id="Generator-2264"><a href="#Generator-2264"><span class="linenos">2264</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2265"><a href="#Generator-2265"><span class="linenos">2265</span></a> +</span><span id="Generator-2266"><a href="#Generator-2266"><span class="linenos">2266</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2267"><a href="#Generator-2267"><span class="linenos">2267</span></a> +</span><span id="Generator-2268"><a href="#Generator-2268"><span class="linenos">2268</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</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">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2269"><a href="#Generator-2269"><span class="linenos">2269</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2270"><a href="#Generator-2270"><span class="linenos">2270</span></a> -</span><span id="Generator-2271"><a href="#Generator-2271"><span class="linenos">2271</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</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">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2272"><a href="#Generator-2272"><span class="linenos">2272</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator-2273"><a href="#Generator-2273"><span class="linenos">2273</span></a> -</span><span id="Generator-2274"><a href="#Generator-2274"><span class="linenos">2274</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</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">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2275"><a href="#Generator-2275"><span class="linenos">2275</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</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="Generator-2276"><a href="#Generator-2276"><span class="linenos">2276</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2277"><a href="#Generator-2277"><span class="linenos">2277</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2278"><a href="#Generator-2278"><span class="linenos">2278</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Generator-2279"><a href="#Generator-2279"><span class="linenos">2279</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2280"><a href="#Generator-2280"><span class="linenos">2280</span></a> -</span><span id="Generator-2281"><a href="#Generator-2281"><span class="linenos">2281</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator-2282"><a href="#Generator-2282"><span class="linenos">2282</span></a> -</span><span id="Generator-2283"><a href="#Generator-2283"><span class="linenos">2283</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</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">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2284"><a href="#Generator-2284"><span class="linenos">2284</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> -</span><span id="Generator-2285"><a href="#Generator-2285"><span class="linenos">2285</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2286"><a href="#Generator-2286"><span class="linenos">2286</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2287"><a href="#Generator-2287"><span class="linenos">2287</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2271"><a href="#Generator-2271"><span class="linenos">2271</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</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">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2272"><a href="#Generator-2272"><span class="linenos">2272</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2273"><a href="#Generator-2273"><span class="linenos">2273</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2274"><a href="#Generator-2274"><span class="linenos">2274</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2275"><a href="#Generator-2275"><span class="linenos">2275</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-2276"><a href="#Generator-2276"><span class="linenos">2276</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2277"><a href="#Generator-2277"><span class="linenos">2277</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2278"><a href="#Generator-2278"><span class="linenos">2278</span></a> +</span><span id="Generator-2279"><a href="#Generator-2279"><span class="linenos">2279</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</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">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2280"><a href="#Generator-2280"><span class="linenos">2280</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-2281"><a href="#Generator-2281"><span class="linenos">2281</span></a> +</span><span id="Generator-2282"><a href="#Generator-2282"><span class="linenos">2282</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</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">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2283"><a href="#Generator-2283"><span class="linenos">2283</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</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="Generator-2284"><a href="#Generator-2284"><span class="linenos">2284</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2285"><a href="#Generator-2285"><span class="linenos">2285</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2286"><a href="#Generator-2286"><span class="linenos">2286</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Generator-2287"><a href="#Generator-2287"><span class="linenos">2287</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2288"><a href="#Generator-2288"><span class="linenos">2288</span></a> -</span><span id="Generator-2289"><a href="#Generator-2289"><span class="linenos">2289</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</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">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2290"><a href="#Generator-2290"><span class="linenos">2290</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2291"><a href="#Generator-2291"><span class="linenos">2291</span></a> -</span><span id="Generator-2292"><a href="#Generator-2292"><span class="linenos">2292</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</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">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2293"><a href="#Generator-2293"><span class="linenos">2293</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator-2294"><a href="#Generator-2294"><span class="linenos">2294</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2295"><a href="#Generator-2295"><span class="linenos">2295</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2289"><a href="#Generator-2289"><span class="linenos">2289</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator-2290"><a href="#Generator-2290"><span class="linenos">2290</span></a> +</span><span id="Generator-2291"><a href="#Generator-2291"><span class="linenos">2291</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</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">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2292"><a href="#Generator-2292"><span class="linenos">2292</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> +</span><span id="Generator-2293"><a href="#Generator-2293"><span class="linenos">2293</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2294"><a href="#Generator-2294"><span class="linenos">2294</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2295"><a href="#Generator-2295"><span class="linenos">2295</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2296"><a href="#Generator-2296"><span class="linenos">2296</span></a> -</span><span id="Generator-2297"><a href="#Generator-2297"><span class="linenos">2297</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</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">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2298"><a href="#Generator-2298"><span class="linenos">2298</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2297"><a href="#Generator-2297"><span class="linenos">2297</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</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">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2298"><a href="#Generator-2298"><span class="linenos">2298</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2299"><a href="#Generator-2299"><span class="linenos">2299</span></a> -</span><span id="Generator-2300"><a href="#Generator-2300"><span class="linenos">2300</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</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">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2301"><a href="#Generator-2301"><span class="linenos">2301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2302"><a href="#Generator-2302"><span class="linenos">2302</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> -</span><span id="Generator-2303"><a href="#Generator-2303"><span class="linenos">2303</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2300"><a href="#Generator-2300"><span class="linenos">2300</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</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">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2301"><a href="#Generator-2301"><span class="linenos">2301</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator-2302"><a href="#Generator-2302"><span class="linenos">2302</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2303"><a href="#Generator-2303"><span class="linenos">2303</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2304"><a href="#Generator-2304"><span class="linenos">2304</span></a> -</span><span id="Generator-2305"><a href="#Generator-2305"><span class="linenos">2305</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</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">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2306"><a href="#Generator-2306"><span class="linenos">2306</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> +</span><span id="Generator-2305"><a href="#Generator-2305"><span class="linenos">2305</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</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">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2306"><a href="#Generator-2306"><span class="linenos">2306</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span><span id="Generator-2307"><a href="#Generator-2307"><span class="linenos">2307</span></a> -</span><span id="Generator-2308"><a href="#Generator-2308"><span class="linenos">2308</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</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">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2309"><a href="#Generator-2309"><span class="linenos">2309</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> -</span><span id="Generator-2310"><a href="#Generator-2310"><span class="linenos">2310</span></a> -</span><span id="Generator-2311"><a href="#Generator-2311"><span class="linenos">2311</span></a> <span class="k">def</span> <span class="nf">xor_sql</span><span class="p">(</span><span class="bp">self</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">Xor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2312"><a href="#Generator-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"XOR"</span><span class="p">)</span> -</span><span id="Generator-2313"><a href="#Generator-2313"><span class="linenos">2313</span></a> -</span><span id="Generator-2314"><a href="#Generator-2314"><span class="linenos">2314</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</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">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2315"><a href="#Generator-2315"><span class="linenos">2315</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator-2316"><a href="#Generator-2316"><span class="linenos">2316</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> -</span><span id="Generator-2317"><a href="#Generator-2317"><span class="linenos">2317</span></a> -</span><span id="Generator-2318"><a href="#Generator-2318"><span class="linenos">2318</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="Generator-2319"><a href="#Generator-2319"><span class="linenos">2319</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="Generator-2320"><a href="#Generator-2320"><span class="linenos">2320</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="Generator-2321"><a href="#Generator-2321"><span class="linenos">2321</span></a> <span class="p">)</span> -</span><span id="Generator-2322"><a href="#Generator-2322"><span class="linenos">2322</span></a> -</span><span id="Generator-2323"><a href="#Generator-2323"><span class="linenos">2323</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-2324"><a href="#Generator-2324"><span class="linenos">2324</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> +</span><span id="Generator-2308"><a href="#Generator-2308"><span class="linenos">2308</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</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">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2309"><a href="#Generator-2309"><span class="linenos">2309</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2310"><a href="#Generator-2310"><span class="linenos">2310</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> +</span><span id="Generator-2311"><a href="#Generator-2311"><span class="linenos">2311</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2312"><a href="#Generator-2312"><span class="linenos">2312</span></a> +</span><span id="Generator-2313"><a href="#Generator-2313"><span class="linenos">2313</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</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">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2314"><a href="#Generator-2314"><span class="linenos">2314</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> +</span><span id="Generator-2315"><a href="#Generator-2315"><span class="linenos">2315</span></a> +</span><span id="Generator-2316"><a href="#Generator-2316"><span class="linenos">2316</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</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">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2317"><a href="#Generator-2317"><span class="linenos">2317</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> +</span><span id="Generator-2318"><a href="#Generator-2318"><span class="linenos">2318</span></a> +</span><span id="Generator-2319"><a href="#Generator-2319"><span class="linenos">2319</span></a> <span class="k">def</span> <span class="nf">xor_sql</span><span class="p">(</span><span class="bp">self</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">Xor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2320"><a href="#Generator-2320"><span class="linenos">2320</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"XOR"</span><span class="p">)</span> +</span><span id="Generator-2321"><a href="#Generator-2321"><span class="linenos">2321</span></a> +</span><span id="Generator-2322"><a href="#Generator-2322"><span class="linenos">2322</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</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">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2323"><a href="#Generator-2323"><span class="linenos">2323</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator-2324"><a href="#Generator-2324"><span class="linenos">2324</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> </span><span id="Generator-2325"><a href="#Generator-2325"><span class="linenos">2325</span></a> -</span><span id="Generator-2326"><a href="#Generator-2326"><span class="linenos">2326</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2327"><a href="#Generator-2327"><span class="linenos">2327</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> -</span><span id="Generator-2328"><a href="#Generator-2328"><span class="linenos">2328</span></a> -</span><span id="Generator-2329"><a href="#Generator-2329"><span class="linenos">2329</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2330"><a href="#Generator-2330"><span class="linenos">2330</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> -</span><span id="Generator-2331"><a href="#Generator-2331"><span class="linenos">2331</span></a> -</span><span id="Generator-2332"><a href="#Generator-2332"><span class="linenos">2332</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2333"><a href="#Generator-2333"><span class="linenos">2333</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2334"><a href="#Generator-2334"><span class="linenos">2334</span></a> -</span><span id="Generator-2335"><a href="#Generator-2335"><span class="linenos">2335</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2336"><a href="#Generator-2336"><span class="linenos">2336</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> -</span><span id="Generator-2337"><a href="#Generator-2337"><span class="linenos">2337</span></a> -</span><span id="Generator-2338"><a href="#Generator-2338"><span class="linenos">2338</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2339"><a href="#Generator-2339"><span class="linenos">2339</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> -</span><span id="Generator-2340"><a href="#Generator-2340"><span class="linenos">2340</span></a> -</span><span id="Generator-2341"><a href="#Generator-2341"><span class="linenos">2341</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2342"><a href="#Generator-2342"><span class="linenos">2342</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> -</span><span id="Generator-2343"><a href="#Generator-2343"><span class="linenos">2343</span></a> -</span><span id="Generator-2344"><a href="#Generator-2344"><span class="linenos">2344</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</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">Cast</span><span class="p">,</span> <span class="n">safe_prefix</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2345"><a href="#Generator-2345"><span class="linenos">2345</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">)</span> -</span><span id="Generator-2346"><a href="#Generator-2346"><span class="linenos">2346</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FORMAT </span><span class="si">{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">format_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2347"><a href="#Generator-2347"><span class="linenos">2347</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">safe_prefix</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2326"><a href="#Generator-2326"><span class="linenos">2326</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="Generator-2327"><a href="#Generator-2327"><span class="linenos">2327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="Generator-2328"><a href="#Generator-2328"><span class="linenos">2328</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="Generator-2329"><a href="#Generator-2329"><span class="linenos">2329</span></a> <span class="p">)</span> +</span><span id="Generator-2330"><a href="#Generator-2330"><span class="linenos">2330</span></a> +</span><span id="Generator-2331"><a href="#Generator-2331"><span class="linenos">2331</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-2332"><a href="#Generator-2332"><span class="linenos">2332</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> +</span><span id="Generator-2333"><a href="#Generator-2333"><span class="linenos">2333</span></a> +</span><span id="Generator-2334"><a href="#Generator-2334"><span class="linenos">2334</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2335"><a href="#Generator-2335"><span class="linenos">2335</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> +</span><span id="Generator-2336"><a href="#Generator-2336"><span class="linenos">2336</span></a> +</span><span id="Generator-2337"><a href="#Generator-2337"><span class="linenos">2337</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2338"><a href="#Generator-2338"><span class="linenos">2338</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> +</span><span id="Generator-2339"><a href="#Generator-2339"><span class="linenos">2339</span></a> +</span><span id="Generator-2340"><a href="#Generator-2340"><span class="linenos">2340</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2341"><a href="#Generator-2341"><span class="linenos">2341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2342"><a href="#Generator-2342"><span class="linenos">2342</span></a> +</span><span id="Generator-2343"><a href="#Generator-2343"><span class="linenos">2343</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2344"><a href="#Generator-2344"><span class="linenos">2344</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> +</span><span id="Generator-2345"><a href="#Generator-2345"><span class="linenos">2345</span></a> +</span><span id="Generator-2346"><a href="#Generator-2346"><span class="linenos">2346</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2347"><a href="#Generator-2347"><span class="linenos">2347</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> </span><span id="Generator-2348"><a href="#Generator-2348"><span class="linenos">2348</span></a> -</span><span id="Generator-2349"><a href="#Generator-2349"><span class="linenos">2349</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</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">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2350"><a href="#Generator-2350"><span class="linenos">2350</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2351"><a href="#Generator-2351"><span class="linenos">2351</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> -</span><span id="Generator-2352"><a href="#Generator-2352"><span class="linenos">2352</span></a> -</span><span id="Generator-2353"><a href="#Generator-2353"><span class="linenos">2353</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</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">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2354"><a href="#Generator-2354"><span class="linenos">2354</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLLATE_IS_FUNC</span><span class="p">:</span> -</span><span id="Generator-2355"><a href="#Generator-2355"><span class="linenos">2355</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2356"><a href="#Generator-2356"><span class="linenos">2356</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> -</span><span id="Generator-2357"><a href="#Generator-2357"><span class="linenos">2357</span></a> -</span><span id="Generator-2358"><a href="#Generator-2358"><span class="linenos">2358</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</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">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2359"><a href="#Generator-2359"><span class="linenos">2359</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2349"><a href="#Generator-2349"><span class="linenos">2349</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2350"><a href="#Generator-2350"><span class="linenos">2350</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> +</span><span id="Generator-2351"><a href="#Generator-2351"><span class="linenos">2351</span></a> +</span><span id="Generator-2352"><a href="#Generator-2352"><span class="linenos">2352</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</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">Cast</span><span class="p">,</span> <span class="n">safe_prefix</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2353"><a href="#Generator-2353"><span class="linenos">2353</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">)</span> +</span><span id="Generator-2354"><a href="#Generator-2354"><span class="linenos">2354</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FORMAT </span><span class="si">{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">format_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2355"><a href="#Generator-2355"><span class="linenos">2355</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">safe_prefix</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2356"><a href="#Generator-2356"><span class="linenos">2356</span></a> +</span><span id="Generator-2357"><a href="#Generator-2357"><span class="linenos">2357</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</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">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2358"><a href="#Generator-2358"><span class="linenos">2358</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2359"><a href="#Generator-2359"><span class="linenos">2359</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> </span><span id="Generator-2360"><a href="#Generator-2360"><span class="linenos">2360</span></a> -</span><span id="Generator-2361"><a href="#Generator-2361"><span class="linenos">2361</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</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">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2362"><a href="#Generator-2362"><span class="linenos">2362</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2363"><a href="#Generator-2363"><span class="linenos">2363</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Generator-2364"><a href="#Generator-2364"><span class="linenos">2364</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-2365"><a href="#Generator-2365"><span class="linenos">2365</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-2366"><a href="#Generator-2366"><span class="linenos">2366</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2367"><a href="#Generator-2367"><span class="linenos">2367</span></a> -</span><span id="Generator-2368"><a href="#Generator-2368"><span class="linenos">2368</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2369"><a href="#Generator-2369"><span class="linenos">2369</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2370"><a href="#Generator-2370"><span class="linenos">2370</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</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">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2371"><a href="#Generator-2371"><span class="linenos">2371</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> -</span><span id="Generator-2372"><a href="#Generator-2372"><span class="linenos">2372</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2373"><a href="#Generator-2373"><span class="linenos">2373</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> -</span><span id="Generator-2374"><a href="#Generator-2374"><span class="linenos">2374</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2375"><a href="#Generator-2375"><span class="linenos">2375</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> -</span><span id="Generator-2376"><a href="#Generator-2376"><span class="linenos">2376</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2377"><a href="#Generator-2377"><span class="linenos">2377</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2378"><a href="#Generator-2378"><span class="linenos">2378</span></a> -</span><span id="Generator-2379"><a href="#Generator-2379"><span class="linenos">2379</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2380"><a href="#Generator-2380"><span class="linenos">2380</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Generator-2381"><a href="#Generator-2381"><span class="linenos">2381</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="Generator-2382"><a href="#Generator-2382"><span class="linenos">2382</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> -</span><span id="Generator-2383"><a href="#Generator-2383"><span class="linenos">2383</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2384"><a href="#Generator-2384"><span class="linenos">2384</span></a> -</span><span id="Generator-2385"><a href="#Generator-2385"><span class="linenos">2385</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Generator-2386"><a href="#Generator-2386"><span class="linenos">2386</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2387"><a href="#Generator-2387"><span class="linenos">2387</span></a> -</span><span id="Generator-2388"><a href="#Generator-2388"><span class="linenos">2388</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2389"><a href="#Generator-2389"><span class="linenos">2389</span></a> -</span><span id="Generator-2390"><a href="#Generator-2390"><span class="linenos">2390</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</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">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2391"><a href="#Generator-2391"><span class="linenos">2391</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> +</span><span id="Generator-2361"><a href="#Generator-2361"><span class="linenos">2361</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</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">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2362"><a href="#Generator-2362"><span class="linenos">2362</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLLATE_IS_FUNC</span><span class="p">:</span> +</span><span id="Generator-2363"><a href="#Generator-2363"><span class="linenos">2363</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2364"><a href="#Generator-2364"><span class="linenos">2364</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> +</span><span id="Generator-2365"><a href="#Generator-2365"><span class="linenos">2365</span></a> +</span><span id="Generator-2366"><a href="#Generator-2366"><span class="linenos">2366</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</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">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2367"><a href="#Generator-2367"><span class="linenos">2367</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2368"><a href="#Generator-2368"><span class="linenos">2368</span></a> +</span><span id="Generator-2369"><a href="#Generator-2369"><span class="linenos">2369</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</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">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2370"><a href="#Generator-2370"><span class="linenos">2370</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2371"><a href="#Generator-2371"><span class="linenos">2371</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Generator-2372"><a href="#Generator-2372"><span class="linenos">2372</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-2373"><a href="#Generator-2373"><span class="linenos">2373</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-2374"><a href="#Generator-2374"><span class="linenos">2374</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2375"><a href="#Generator-2375"><span class="linenos">2375</span></a> +</span><span id="Generator-2376"><a href="#Generator-2376"><span class="linenos">2376</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2377"><a href="#Generator-2377"><span class="linenos">2377</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2378"><a href="#Generator-2378"><span class="linenos">2378</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</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">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2379"><a href="#Generator-2379"><span class="linenos">2379</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> +</span><span id="Generator-2380"><a href="#Generator-2380"><span class="linenos">2380</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2381"><a href="#Generator-2381"><span class="linenos">2381</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> +</span><span id="Generator-2382"><a href="#Generator-2382"><span class="linenos">2382</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2383"><a href="#Generator-2383"><span class="linenos">2383</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> +</span><span id="Generator-2384"><a href="#Generator-2384"><span class="linenos">2384</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2385"><a href="#Generator-2385"><span class="linenos">2385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2386"><a href="#Generator-2386"><span class="linenos">2386</span></a> +</span><span id="Generator-2387"><a href="#Generator-2387"><span class="linenos">2387</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2388"><a href="#Generator-2388"><span class="linenos">2388</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Generator-2389"><a href="#Generator-2389"><span class="linenos">2389</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="Generator-2390"><a href="#Generator-2390"><span class="linenos">2390</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> +</span><span id="Generator-2391"><a href="#Generator-2391"><span class="linenos">2391</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> </span><span id="Generator-2392"><a href="#Generator-2392"><span class="linenos">2392</span></a> -</span><span id="Generator-2393"><a href="#Generator-2393"><span class="linenos">2393</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</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">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2394"><a href="#Generator-2394"><span class="linenos">2394</span></a> <span class="n">chain</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">"chain"</span><span class="p">)</span> -</span><span id="Generator-2395"><a href="#Generator-2395"><span class="linenos">2395</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-2396"><a href="#Generator-2396"><span class="linenos">2396</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> +</span><span id="Generator-2393"><a href="#Generator-2393"><span class="linenos">2393</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Generator-2394"><a href="#Generator-2394"><span class="linenos">2394</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2395"><a href="#Generator-2395"><span class="linenos">2395</span></a> +</span><span id="Generator-2396"><a href="#Generator-2396"><span class="linenos">2396</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2397"><a href="#Generator-2397"><span class="linenos">2397</span></a> -</span><span id="Generator-2398"><a href="#Generator-2398"><span class="linenos">2398</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2399"><a href="#Generator-2399"><span class="linenos">2399</span></a> -</span><span id="Generator-2400"><a href="#Generator-2400"><span class="linenos">2400</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</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">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2401"><a href="#Generator-2401"><span class="linenos">2401</span></a> <span class="n">savepoint</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">"savepoint"</span><span class="p">)</span> -</span><span id="Generator-2402"><a href="#Generator-2402"><span class="linenos">2402</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2403"><a href="#Generator-2403"><span class="linenos">2403</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2404"><a href="#Generator-2404"><span class="linenos">2404</span></a> -</span><span id="Generator-2405"><a href="#Generator-2405"><span class="linenos">2405</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</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">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2406"><a href="#Generator-2406"><span class="linenos">2406</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2398"><a href="#Generator-2398"><span class="linenos">2398</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</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">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2399"><a href="#Generator-2399"><span class="linenos">2399</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> +</span><span id="Generator-2400"><a href="#Generator-2400"><span class="linenos">2400</span></a> +</span><span id="Generator-2401"><a href="#Generator-2401"><span class="linenos">2401</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</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">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2402"><a href="#Generator-2402"><span class="linenos">2402</span></a> <span class="n">chain</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">"chain"</span><span class="p">)</span> +</span><span id="Generator-2403"><a href="#Generator-2403"><span class="linenos">2403</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-2404"><a href="#Generator-2404"><span class="linenos">2404</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> +</span><span id="Generator-2405"><a href="#Generator-2405"><span class="linenos">2405</span></a> +</span><span id="Generator-2406"><a href="#Generator-2406"><span class="linenos">2406</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2407"><a href="#Generator-2407"><span class="linenos">2407</span></a> -</span><span id="Generator-2408"><a href="#Generator-2408"><span class="linenos">2408</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> -</span><span id="Generator-2409"><a href="#Generator-2409"><span class="linenos">2409</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="Generator-2410"><a href="#Generator-2410"><span class="linenos">2410</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="Generator-2411"><a href="#Generator-2411"><span class="linenos">2411</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2412"><a href="#Generator-2412"><span class="linenos">2412</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator-2413"><a href="#Generator-2413"><span class="linenos">2413</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2414"><a href="#Generator-2414"><span class="linenos">2414</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DATA TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2408"><a href="#Generator-2408"><span class="linenos">2408</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</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">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2409"><a href="#Generator-2409"><span class="linenos">2409</span></a> <span class="n">savepoint</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">"savepoint"</span><span class="p">)</span> +</span><span id="Generator-2410"><a href="#Generator-2410"><span class="linenos">2410</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2411"><a href="#Generator-2411"><span class="linenos">2411</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2412"><a href="#Generator-2412"><span class="linenos">2412</span></a> +</span><span id="Generator-2413"><a href="#Generator-2413"><span class="linenos">2413</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</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">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2414"><a href="#Generator-2414"><span class="linenos">2414</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span><span id="Generator-2415"><a href="#Generator-2415"><span class="linenos">2415</span></a> -</span><span id="Generator-2416"><a href="#Generator-2416"><span class="linenos">2416</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator-2417"><a href="#Generator-2417"><span class="linenos">2417</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator-2418"><a href="#Generator-2418"><span class="linenos">2418</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2419"><a href="#Generator-2419"><span class="linenos">2419</span></a> -</span><span id="Generator-2420"><a href="#Generator-2420"><span class="linenos">2420</span></a> <span class="k">if</span> <span class="ow">not</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">"drop"</span><span class="p">):</span> -</span><span id="Generator-2421"><a href="#Generator-2421"><span class="linenos">2421</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> -</span><span id="Generator-2422"><a href="#Generator-2422"><span class="linenos">2422</span></a> -</span><span id="Generator-2423"><a href="#Generator-2423"><span class="linenos">2423</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> -</span><span id="Generator-2424"><a href="#Generator-2424"><span class="linenos">2424</span></a> -</span><span id="Generator-2425"><a href="#Generator-2425"><span class="linenos">2425</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</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">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2426"><a href="#Generator-2426"><span class="linenos">2426</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> -</span><span id="Generator-2427"><a href="#Generator-2427"><span class="linenos">2427</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="Generator-2428"><a href="#Generator-2428"><span class="linenos">2428</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="Generator-2429"><a href="#Generator-2429"><span class="linenos">2429</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> -</span><span id="Generator-2430"><a href="#Generator-2430"><span class="linenos">2430</span></a> <span class="p">)</span> -</span><span id="Generator-2431"><a href="#Generator-2431"><span class="linenos">2431</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2432"><a href="#Generator-2432"><span class="linenos">2432</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2433"><a href="#Generator-2433"><span class="linenos">2433</span></a> -</span><span id="Generator-2434"><a href="#Generator-2434"><span class="linenos">2434</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</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">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2435"><a href="#Generator-2435"><span class="linenos">2435</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> -</span><span id="Generator-2436"><a href="#Generator-2436"><span class="linenos">2436</span></a> -</span><span id="Generator-2437"><a href="#Generator-2437"><span class="linenos">2437</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> -</span><span id="Generator-2438"><a href="#Generator-2438"><span class="linenos">2438</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_ADD_COLUMN_KEYWORD</span><span class="p">:</span> -</span><span id="Generator-2439"><a href="#Generator-2439"><span class="linenos">2439</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> -</span><span id="Generator-2440"><a href="#Generator-2440"><span class="linenos">2440</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator-2441"><a href="#Generator-2441"><span class="linenos">2441</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> -</span><span id="Generator-2442"><a href="#Generator-2442"><span class="linenos">2442</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">,</span> -</span><span id="Generator-2443"><a href="#Generator-2443"><span class="linenos">2443</span></a> <span class="p">)</span> -</span><span id="Generator-2444"><a href="#Generator-2444"><span class="linenos">2444</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2445"><a href="#Generator-2445"><span class="linenos">2445</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="o">=</span><span class="s1">'actions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2446"><a href="#Generator-2446"><span class="linenos">2446</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> -</span><span id="Generator-2447"><a href="#Generator-2447"><span class="linenos">2447</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> -</span><span id="Generator-2448"><a href="#Generator-2448"><span class="linenos">2448</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> -</span><span id="Generator-2449"><a href="#Generator-2449"><span class="linenos">2449</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2450"><a href="#Generator-2450"><span class="linenos">2450</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2451"><a href="#Generator-2451"><span class="linenos">2451</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2452"><a href="#Generator-2452"><span class="linenos">2452</span></a> -</span><span id="Generator-2453"><a href="#Generator-2453"><span class="linenos">2453</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2454"><a href="#Generator-2454"><span class="linenos">2454</span></a> <span class="n">only</span> <span class="o">=</span> <span class="s2">" ONLY"</span> <span class="k">if</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">"only"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2455"><a href="#Generator-2455"><span class="linenos">2455</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">only</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2456"><a href="#Generator-2456"><span class="linenos">2456</span></a> -</span><span id="Generator-2457"><a href="#Generator-2457"><span class="linenos">2457</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</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">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2458"><a href="#Generator-2458"><span class="linenos">2458</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2459"><a href="#Generator-2459"><span class="linenos">2459</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator-2460"><a href="#Generator-2460"><span class="linenos">2460</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2461"><a href="#Generator-2461"><span class="linenos">2461</span></a> -</span><span id="Generator-2462"><a href="#Generator-2462"><span class="linenos">2462</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</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">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2463"><a href="#Generator-2463"><span class="linenos">2463</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2464"><a href="#Generator-2464"><span class="linenos">2464</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-2465"><a href="#Generator-2465"><span class="linenos">2465</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> -</span><span id="Generator-2466"><a href="#Generator-2466"><span class="linenos">2466</span></a> -</span><span id="Generator-2467"><a href="#Generator-2467"><span class="linenos">2467</span></a> <span class="n">enforced</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">"enforced"</span><span class="p">)</span> -</span><span id="Generator-2468"><a href="#Generator-2468"><span class="linenos">2468</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-2469"><a href="#Generator-2469"><span class="linenos">2469</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2470"><a href="#Generator-2470"><span class="linenos">2470</span></a> -</span><span id="Generator-2471"><a href="#Generator-2471"><span class="linenos">2471</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2472"><a href="#Generator-2472"><span class="linenos">2472</span></a> -</span><span id="Generator-2473"><a href="#Generator-2473"><span class="linenos">2473</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</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">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2474"><a href="#Generator-2474"><span class="linenos">2474</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2475"><a href="#Generator-2475"><span class="linenos">2475</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2476"><a href="#Generator-2476"><span class="linenos">2476</span></a> -</span><span id="Generator-2477"><a href="#Generator-2477"><span class="linenos">2477</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="Generator-2478"><a href="#Generator-2478"><span class="linenos">2478</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2479"><a href="#Generator-2479"><span class="linenos">2479</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2416"><a href="#Generator-2416"><span class="linenos">2416</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> +</span><span id="Generator-2417"><a href="#Generator-2417"><span class="linenos">2417</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="Generator-2418"><a href="#Generator-2418"><span class="linenos">2418</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="Generator-2419"><a href="#Generator-2419"><span class="linenos">2419</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2420"><a href="#Generator-2420"><span class="linenos">2420</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator-2421"><a href="#Generator-2421"><span class="linenos">2421</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2422"><a href="#Generator-2422"><span class="linenos">2422</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DATA TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2423"><a href="#Generator-2423"><span class="linenos">2423</span></a> +</span><span id="Generator-2424"><a href="#Generator-2424"><span class="linenos">2424</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator-2425"><a href="#Generator-2425"><span class="linenos">2425</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator-2426"><a href="#Generator-2426"><span class="linenos">2426</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2427"><a href="#Generator-2427"><span class="linenos">2427</span></a> +</span><span id="Generator-2428"><a href="#Generator-2428"><span class="linenos">2428</span></a> <span class="k">if</span> <span class="ow">not</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">"drop"</span><span class="p">):</span> +</span><span id="Generator-2429"><a href="#Generator-2429"><span class="linenos">2429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> +</span><span id="Generator-2430"><a href="#Generator-2430"><span class="linenos">2430</span></a> +</span><span id="Generator-2431"><a href="#Generator-2431"><span class="linenos">2431</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> +</span><span id="Generator-2432"><a href="#Generator-2432"><span class="linenos">2432</span></a> +</span><span id="Generator-2433"><a href="#Generator-2433"><span class="linenos">2433</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</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">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2434"><a href="#Generator-2434"><span class="linenos">2434</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> +</span><span id="Generator-2435"><a href="#Generator-2435"><span class="linenos">2435</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="Generator-2436"><a href="#Generator-2436"><span class="linenos">2436</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="Generator-2437"><a href="#Generator-2437"><span class="linenos">2437</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> +</span><span id="Generator-2438"><a href="#Generator-2438"><span class="linenos">2438</span></a> <span class="p">)</span> +</span><span id="Generator-2439"><a href="#Generator-2439"><span class="linenos">2439</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2440"><a href="#Generator-2440"><span class="linenos">2440</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2441"><a href="#Generator-2441"><span class="linenos">2441</span></a> +</span><span id="Generator-2442"><a href="#Generator-2442"><span class="linenos">2442</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</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">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2443"><a href="#Generator-2443"><span class="linenos">2443</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> +</span><span id="Generator-2444"><a href="#Generator-2444"><span class="linenos">2444</span></a> +</span><span id="Generator-2445"><a href="#Generator-2445"><span class="linenos">2445</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> +</span><span id="Generator-2446"><a href="#Generator-2446"><span class="linenos">2446</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_ADD_COLUMN_KEYWORD</span><span class="p">:</span> +</span><span id="Generator-2447"><a href="#Generator-2447"><span class="linenos">2447</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> +</span><span id="Generator-2448"><a href="#Generator-2448"><span class="linenos">2448</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator-2449"><a href="#Generator-2449"><span class="linenos">2449</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> +</span><span id="Generator-2450"><a href="#Generator-2450"><span class="linenos">2450</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">,</span> +</span><span id="Generator-2451"><a href="#Generator-2451"><span class="linenos">2451</span></a> <span class="p">)</span> +</span><span id="Generator-2452"><a href="#Generator-2452"><span class="linenos">2452</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2453"><a href="#Generator-2453"><span class="linenos">2453</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="o">=</span><span class="s1">'actions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2454"><a href="#Generator-2454"><span class="linenos">2454</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> +</span><span id="Generator-2455"><a href="#Generator-2455"><span class="linenos">2455</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> +</span><span id="Generator-2456"><a href="#Generator-2456"><span class="linenos">2456</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> +</span><span id="Generator-2457"><a href="#Generator-2457"><span class="linenos">2457</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2458"><a href="#Generator-2458"><span class="linenos">2458</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2459"><a href="#Generator-2459"><span class="linenos">2459</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2460"><a href="#Generator-2460"><span class="linenos">2460</span></a> +</span><span id="Generator-2461"><a href="#Generator-2461"><span class="linenos">2461</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2462"><a href="#Generator-2462"><span class="linenos">2462</span></a> <span class="n">only</span> <span class="o">=</span> <span class="s2">" ONLY"</span> <span class="k">if</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">"only"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2463"><a href="#Generator-2463"><span class="linenos">2463</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">only</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2464"><a href="#Generator-2464"><span class="linenos">2464</span></a> +</span><span id="Generator-2465"><a href="#Generator-2465"><span class="linenos">2465</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</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">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2466"><a href="#Generator-2466"><span class="linenos">2466</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2467"><a href="#Generator-2467"><span class="linenos">2467</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator-2468"><a href="#Generator-2468"><span class="linenos">2468</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2469"><a href="#Generator-2469"><span class="linenos">2469</span></a> +</span><span id="Generator-2470"><a href="#Generator-2470"><span class="linenos">2470</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</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">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2471"><a href="#Generator-2471"><span class="linenos">2471</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2472"><a href="#Generator-2472"><span class="linenos">2472</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-2473"><a href="#Generator-2473"><span class="linenos">2473</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> +</span><span id="Generator-2474"><a href="#Generator-2474"><span class="linenos">2474</span></a> +</span><span id="Generator-2475"><a href="#Generator-2475"><span class="linenos">2475</span></a> <span class="n">enforced</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">"enforced"</span><span class="p">)</span> +</span><span id="Generator-2476"><a href="#Generator-2476"><span class="linenos">2476</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-2477"><a href="#Generator-2477"><span class="linenos">2477</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2478"><a href="#Generator-2478"><span class="linenos">2478</span></a> +</span><span id="Generator-2479"><a href="#Generator-2479"><span class="linenos">2479</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2480"><a href="#Generator-2480"><span class="linenos">2480</span></a> -</span><span id="Generator-2481"><a href="#Generator-2481"><span class="linenos">2481</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</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">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2482"><a href="#Generator-2482"><span class="linenos">2482</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> -</span><span id="Generator-2483"><a href="#Generator-2483"><span class="linenos">2483</span></a> -</span><span id="Generator-2484"><a href="#Generator-2484"><span class="linenos">2484</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</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">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2485"><a href="#Generator-2485"><span class="linenos">2485</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> -</span><span id="Generator-2486"><a href="#Generator-2486"><span class="linenos">2486</span></a> -</span><span id="Generator-2487"><a href="#Generator-2487"><span class="linenos">2487</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</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">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2488"><a href="#Generator-2488"><span class="linenos">2488</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator-2489"><a href="#Generator-2489"><span class="linenos">2489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> -</span><span id="Generator-2490"><a href="#Generator-2490"><span class="linenos">2490</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()),</span> -</span><span id="Generator-2491"><a href="#Generator-2491"><span class="linenos">2491</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> -</span><span id="Generator-2492"><a href="#Generator-2492"><span class="linenos">2492</span></a> <span class="p">)</span> -</span><span id="Generator-2493"><a href="#Generator-2493"><span class="linenos">2493</span></a> <span class="p">)</span> +</span><span id="Generator-2481"><a href="#Generator-2481"><span class="linenos">2481</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</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">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2482"><a href="#Generator-2482"><span class="linenos">2482</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2483"><a href="#Generator-2483"><span class="linenos">2483</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2484"><a href="#Generator-2484"><span class="linenos">2484</span></a> +</span><span id="Generator-2485"><a href="#Generator-2485"><span class="linenos">2485</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="Generator-2486"><a href="#Generator-2486"><span class="linenos">2486</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2487"><a href="#Generator-2487"><span class="linenos">2487</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2488"><a href="#Generator-2488"><span class="linenos">2488</span></a> +</span><span id="Generator-2489"><a href="#Generator-2489"><span class="linenos">2489</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</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">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2490"><a href="#Generator-2490"><span class="linenos">2490</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> +</span><span id="Generator-2491"><a href="#Generator-2491"><span class="linenos">2491</span></a> +</span><span id="Generator-2492"><a href="#Generator-2492"><span class="linenos">2492</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</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">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2493"><a href="#Generator-2493"><span class="linenos">2493</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> </span><span id="Generator-2494"><a href="#Generator-2494"><span class="linenos">2494</span></a> -</span><span id="Generator-2495"><a href="#Generator-2495"><span class="linenos">2495</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</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">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2496"><a href="#Generator-2496"><span class="linenos">2496</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> -</span><span id="Generator-2497"><a href="#Generator-2497"><span class="linenos">2497</span></a> -</span><span id="Generator-2498"><a href="#Generator-2498"><span class="linenos">2498</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</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">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2499"><a href="#Generator-2499"><span class="linenos">2499</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="Generator-2500"><a href="#Generator-2500"><span class="linenos">2500</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> -</span><span id="Generator-2501"><a href="#Generator-2501"><span class="linenos">2501</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2495"><a href="#Generator-2495"><span class="linenos">2495</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</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">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2496"><a href="#Generator-2496"><span class="linenos">2496</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator-2497"><a href="#Generator-2497"><span class="linenos">2497</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> +</span><span id="Generator-2498"><a href="#Generator-2498"><span class="linenos">2498</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()),</span> +</span><span id="Generator-2499"><a href="#Generator-2499"><span class="linenos">2499</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> +</span><span id="Generator-2500"><a href="#Generator-2500"><span class="linenos">2500</span></a> <span class="p">)</span> +</span><span id="Generator-2501"><a href="#Generator-2501"><span class="linenos">2501</span></a> <span class="p">)</span> </span><span id="Generator-2502"><a href="#Generator-2502"><span class="linenos">2502</span></a> -</span><span id="Generator-2503"><a href="#Generator-2503"><span class="linenos">2503</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</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">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2504"><a href="#Generator-2504"><span class="linenos">2504</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> +</span><span id="Generator-2503"><a href="#Generator-2503"><span class="linenos">2503</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</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">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2504"><a href="#Generator-2504"><span class="linenos">2504</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> </span><span id="Generator-2505"><a href="#Generator-2505"><span class="linenos">2505</span></a> -</span><span id="Generator-2506"><a href="#Generator-2506"><span class="linenos">2506</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</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">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2507"><a href="#Generator-2507"><span class="linenos">2507</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> -</span><span id="Generator-2508"><a href="#Generator-2508"><span class="linenos">2508</span></a> -</span><span id="Generator-2509"><a href="#Generator-2509"><span class="linenos">2509</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</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">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2510"><a href="#Generator-2510"><span class="linenos">2510</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> -</span><span id="Generator-2511"><a href="#Generator-2511"><span class="linenos">2511</span></a> -</span><span id="Generator-2512"><a href="#Generator-2512"><span class="linenos">2512</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</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">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2513"><a href="#Generator-2513"><span class="linenos">2513</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2514"><a href="#Generator-2514"><span class="linenos">2514</span></a> -</span><span id="Generator-2515"><a href="#Generator-2515"><span class="linenos">2515</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</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">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2516"><a href="#Generator-2516"><span class="linenos">2516</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> -</span><span id="Generator-2517"><a href="#Generator-2517"><span class="linenos">2517</span></a> -</span><span id="Generator-2518"><a href="#Generator-2518"><span class="linenos">2518</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</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">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2519"><a href="#Generator-2519"><span class="linenos">2519</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> -</span><span id="Generator-2520"><a href="#Generator-2520"><span class="linenos">2520</span></a> -</span><span id="Generator-2521"><a href="#Generator-2521"><span class="linenos">2521</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</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">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2522"><a href="#Generator-2522"><span class="linenos">2522</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> -</span><span id="Generator-2523"><a href="#Generator-2523"><span class="linenos">2523</span></a> -</span><span id="Generator-2524"><a href="#Generator-2524"><span class="linenos">2524</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</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">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2525"><a href="#Generator-2525"><span class="linenos">2525</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> -</span><span id="Generator-2526"><a href="#Generator-2526"><span class="linenos">2526</span></a> -</span><span id="Generator-2527"><a href="#Generator-2527"><span class="linenos">2527</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</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">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2528"><a href="#Generator-2528"><span class="linenos">2528</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> -</span><span id="Generator-2529"><a href="#Generator-2529"><span class="linenos">2529</span></a> -</span><span id="Generator-2530"><a href="#Generator-2530"><span class="linenos">2530</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</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">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2531"><a href="#Generator-2531"><span class="linenos">2531</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> -</span><span id="Generator-2532"><a href="#Generator-2532"><span class="linenos">2532</span></a> -</span><span id="Generator-2533"><a href="#Generator-2533"><span class="linenos">2533</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</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">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2534"><a href="#Generator-2534"><span class="linenos">2534</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> -</span><span id="Generator-2535"><a href="#Generator-2535"><span class="linenos">2535</span></a> -</span><span id="Generator-2536"><a href="#Generator-2536"><span class="linenos">2536</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</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">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2537"><a href="#Generator-2537"><span class="linenos">2537</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Boolean</span><span class="p">):</span> -</span><span id="Generator-2538"><a href="#Generator-2538"><span class="linenos">2538</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator-2539"><a href="#Generator-2539"><span class="linenos">2539</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator-2540"><a href="#Generator-2540"><span class="linenos">2540</span></a> <span class="p">)</span> -</span><span id="Generator-2541"><a href="#Generator-2541"><span class="linenos">2541</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> -</span><span id="Generator-2542"><a href="#Generator-2542"><span class="linenos">2542</span></a> -</span><span id="Generator-2543"><a href="#Generator-2543"><span class="linenos">2543</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</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">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2544"><a href="#Generator-2544"><span class="linenos">2544</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> -</span><span id="Generator-2545"><a href="#Generator-2545"><span class="linenos">2545</span></a> -</span><span id="Generator-2546"><a href="#Generator-2546"><span class="linenos">2546</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</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">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2547"><a href="#Generator-2547"><span class="linenos">2547</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> -</span><span id="Generator-2548"><a href="#Generator-2548"><span class="linenos">2548</span></a> -</span><span id="Generator-2549"><a href="#Generator-2549"><span class="linenos">2549</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</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">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2550"><a href="#Generator-2550"><span class="linenos">2550</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> -</span><span id="Generator-2551"><a href="#Generator-2551"><span class="linenos">2551</span></a> -</span><span id="Generator-2552"><a href="#Generator-2552"><span class="linenos">2552</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</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">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2553"><a href="#Generator-2553"><span class="linenos">2553</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> -</span><span id="Generator-2554"><a href="#Generator-2554"><span class="linenos">2554</span></a> -</span><span id="Generator-2555"><a href="#Generator-2555"><span class="linenos">2555</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</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">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2556"><a href="#Generator-2556"><span class="linenos">2556</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> -</span><span id="Generator-2557"><a href="#Generator-2557"><span class="linenos">2557</span></a> -</span><span id="Generator-2558"><a href="#Generator-2558"><span class="linenos">2558</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</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">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2559"><a href="#Generator-2559"><span class="linenos">2559</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> -</span><span id="Generator-2560"><a href="#Generator-2560"><span class="linenos">2560</span></a> -</span><span id="Generator-2561"><a href="#Generator-2561"><span class="linenos">2561</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</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">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2562"><a href="#Generator-2562"><span class="linenos">2562</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> -</span><span id="Generator-2563"><a href="#Generator-2563"><span class="linenos">2563</span></a> -</span><span id="Generator-2564"><a href="#Generator-2564"><span class="linenos">2564</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</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">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2565"><a href="#Generator-2565"><span class="linenos">2565</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> -</span><span id="Generator-2566"><a href="#Generator-2566"><span class="linenos">2566</span></a> -</span><span id="Generator-2567"><a href="#Generator-2567"><span class="linenos">2567</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2568"><a href="#Generator-2568"><span class="linenos">2568</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> -</span><span id="Generator-2569"><a href="#Generator-2569"><span class="linenos">2569</span></a> -</span><span id="Generator-2570"><a href="#Generator-2570"><span class="linenos">2570</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2571"><a href="#Generator-2571"><span class="linenos">2571</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> -</span><span id="Generator-2572"><a href="#Generator-2572"><span class="linenos">2572</span></a> -</span><span id="Generator-2573"><a href="#Generator-2573"><span class="linenos">2573</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</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">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2574"><a href="#Generator-2574"><span class="linenos">2574</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> -</span><span id="Generator-2575"><a href="#Generator-2575"><span class="linenos">2575</span></a> -</span><span id="Generator-2576"><a href="#Generator-2576"><span class="linenos">2576</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</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">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2577"><a href="#Generator-2577"><span class="linenos">2577</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> -</span><span id="Generator-2578"><a href="#Generator-2578"><span class="linenos">2578</span></a> -</span><span id="Generator-2579"><a href="#Generator-2579"><span class="linenos">2579</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</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">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2580"><a href="#Generator-2580"><span class="linenos">2580</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> -</span><span id="Generator-2581"><a href="#Generator-2581"><span class="linenos">2581</span></a> -</span><span id="Generator-2582"><a href="#Generator-2582"><span class="linenos">2582</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</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">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2583"><a href="#Generator-2583"><span class="linenos">2583</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY_"</span><span class="p">)</span> -</span><span id="Generator-2584"><a href="#Generator-2584"><span class="linenos">2584</span></a> -</span><span id="Generator-2585"><a href="#Generator-2585"><span class="linenos">2585</span></a> <span class="k">def</span> <span class="nf">log_sql</span><span class="p">(</span><span class="bp">self</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">Log</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2586"><a href="#Generator-2586"><span class="linenos">2586</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> -</span><span id="Generator-2587"><a href="#Generator-2587"><span class="linenos">2587</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> -</span><span id="Generator-2588"><a href="#Generator-2588"><span class="linenos">2588</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> -</span><span id="Generator-2589"><a href="#Generator-2589"><span class="linenos">2589</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LOG"</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> -</span><span id="Generator-2590"><a href="#Generator-2590"><span class="linenos">2590</span></a> -</span><span id="Generator-2591"><a href="#Generator-2591"><span class="linenos">2591</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</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">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2592"><a href="#Generator-2592"><span class="linenos">2592</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-2593"><a href="#Generator-2593"><span class="linenos">2593</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2594"><a href="#Generator-2594"><span class="linenos">2594</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2595"><a href="#Generator-2595"><span class="linenos">2595</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2596"><a href="#Generator-2596"><span class="linenos">2596</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2597"><a href="#Generator-2597"><span class="linenos">2597</span></a> -</span><span id="Generator-2598"><a href="#Generator-2598"><span class="linenos">2598</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</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">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2599"><a href="#Generator-2599"><span class="linenos">2599</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> -</span><span id="Generator-2600"><a href="#Generator-2600"><span class="linenos">2600</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2601"><a href="#Generator-2601"><span class="linenos">2601</span></a> -</span><span id="Generator-2602"><a href="#Generator-2602"><span class="linenos">2602</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</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">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2603"><a href="#Generator-2603"><span class="linenos">2603</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-2604"><a href="#Generator-2604"><span class="linenos">2604</span></a> -</span><span id="Generator-2605"><a href="#Generator-2605"><span class="linenos">2605</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> -</span><span id="Generator-2606"><a href="#Generator-2606"><span class="linenos">2606</span></a> <span class="n">arg_value</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="n">key</span><span class="p">)</span> -</span><span id="Generator-2607"><a href="#Generator-2607"><span class="linenos">2607</span></a> -</span><span id="Generator-2608"><a href="#Generator-2608"><span class="linenos">2608</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator-2609"><a href="#Generator-2609"><span class="linenos">2609</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> -</span><span id="Generator-2610"><a href="#Generator-2610"><span class="linenos">2610</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Generator-2611"><a href="#Generator-2611"><span class="linenos">2611</span></a> <span class="k">elif</span> <span class="n">arg_value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-2612"><a href="#Generator-2612"><span class="linenos">2612</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> -</span><span id="Generator-2613"><a href="#Generator-2613"><span class="linenos">2613</span></a> -</span><span id="Generator-2614"><a href="#Generator-2614"><span class="linenos">2614</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span><span class="p">:</span> -</span><span id="Generator-2615"><a href="#Generator-2615"><span class="linenos">2615</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> -</span><span id="Generator-2616"><a href="#Generator-2616"><span class="linenos">2616</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2617"><a href="#Generator-2617"><span class="linenos">2617</span></a> <span class="n">name</span> <span class="o">=</span> <span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">_meta</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">))</span> <span class="ow">or</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> -</span><span id="Generator-2618"><a href="#Generator-2618"><span class="linenos">2618</span></a> -</span><span id="Generator-2619"><a href="#Generator-2619"><span class="linenos">2619</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> -</span><span id="Generator-2620"><a href="#Generator-2620"><span class="linenos">2620</span></a> -</span><span id="Generator-2621"><a href="#Generator-2621"><span class="linenos">2621</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="Generator-2622"><a href="#Generator-2622"><span class="linenos">2622</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-2623"><a href="#Generator-2623"><span class="linenos">2623</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator-2624"><a href="#Generator-2624"><span class="linenos">2624</span></a> <span class="o">*</span><span class="n">args</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">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> -</span><span id="Generator-2625"><a href="#Generator-2625"><span class="linenos">2625</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> -</span><span id="Generator-2626"><a href="#Generator-2626"><span class="linenos">2626</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> -</span><span id="Generator-2627"><a href="#Generator-2627"><span class="linenos">2627</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2628"><a href="#Generator-2628"><span class="linenos">2628</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2629"><a href="#Generator-2629"><span class="linenos">2629</span></a> -</span><span id="Generator-2630"><a href="#Generator-2630"><span class="linenos">2630</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</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="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2631"><a href="#Generator-2631"><span class="linenos">2631</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Generator-2632"><a href="#Generator-2632"><span class="linenos">2632</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="Generator-2633"><a href="#Generator-2633"><span class="linenos">2633</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2634"><a href="#Generator-2634"><span class="linenos">2634</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> -</span><span id="Generator-2635"><a href="#Generator-2635"><span class="linenos">2635</span></a> -</span><span id="Generator-2636"><a href="#Generator-2636"><span class="linenos">2636</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="Generator-2637"><a href="#Generator-2637"><span class="linenos">2637</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> -</span><span id="Generator-2638"><a href="#Generator-2638"><span class="linenos">2638</span></a> -</span><span id="Generator-2639"><a href="#Generator-2639"><span class="linenos">2639</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator-2640"><a href="#Generator-2640"><span class="linenos">2640</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="Generator-2641"><a href="#Generator-2641"><span class="linenos">2641</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> -</span><span id="Generator-2642"><a href="#Generator-2642"><span class="linenos">2642</span></a> <span class="p">)</span> +</span><span id="Generator-2506"><a href="#Generator-2506"><span class="linenos">2506</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</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">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2507"><a href="#Generator-2507"><span class="linenos">2507</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="Generator-2508"><a href="#Generator-2508"><span class="linenos">2508</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> +</span><span id="Generator-2509"><a href="#Generator-2509"><span class="linenos">2509</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2510"><a href="#Generator-2510"><span class="linenos">2510</span></a> +</span><span id="Generator-2511"><a href="#Generator-2511"><span class="linenos">2511</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</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">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2512"><a href="#Generator-2512"><span class="linenos">2512</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> +</span><span id="Generator-2513"><a href="#Generator-2513"><span class="linenos">2513</span></a> +</span><span id="Generator-2514"><a href="#Generator-2514"><span class="linenos">2514</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</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">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2515"><a href="#Generator-2515"><span class="linenos">2515</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> +</span><span id="Generator-2516"><a href="#Generator-2516"><span class="linenos">2516</span></a> +</span><span id="Generator-2517"><a href="#Generator-2517"><span class="linenos">2517</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</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">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2518"><a href="#Generator-2518"><span class="linenos">2518</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> +</span><span id="Generator-2519"><a href="#Generator-2519"><span class="linenos">2519</span></a> +</span><span id="Generator-2520"><a href="#Generator-2520"><span class="linenos">2520</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</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">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2521"><a href="#Generator-2521"><span class="linenos">2521</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2522"><a href="#Generator-2522"><span class="linenos">2522</span></a> +</span><span id="Generator-2523"><a href="#Generator-2523"><span class="linenos">2523</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</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">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2524"><a href="#Generator-2524"><span class="linenos">2524</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> +</span><span id="Generator-2525"><a href="#Generator-2525"><span class="linenos">2525</span></a> +</span><span id="Generator-2526"><a href="#Generator-2526"><span class="linenos">2526</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</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">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2527"><a href="#Generator-2527"><span class="linenos">2527</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> +</span><span id="Generator-2528"><a href="#Generator-2528"><span class="linenos">2528</span></a> +</span><span id="Generator-2529"><a href="#Generator-2529"><span class="linenos">2529</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</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">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2530"><a href="#Generator-2530"><span class="linenos">2530</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> +</span><span id="Generator-2531"><a href="#Generator-2531"><span class="linenos">2531</span></a> +</span><span id="Generator-2532"><a href="#Generator-2532"><span class="linenos">2532</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</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">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2533"><a href="#Generator-2533"><span class="linenos">2533</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> +</span><span id="Generator-2534"><a href="#Generator-2534"><span class="linenos">2534</span></a> +</span><span id="Generator-2535"><a href="#Generator-2535"><span class="linenos">2535</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</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">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2536"><a href="#Generator-2536"><span class="linenos">2536</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> +</span><span id="Generator-2537"><a href="#Generator-2537"><span class="linenos">2537</span></a> +</span><span id="Generator-2538"><a href="#Generator-2538"><span class="linenos">2538</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</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">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2539"><a href="#Generator-2539"><span class="linenos">2539</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> +</span><span id="Generator-2540"><a href="#Generator-2540"><span class="linenos">2540</span></a> +</span><span id="Generator-2541"><a href="#Generator-2541"><span class="linenos">2541</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</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">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2542"><a href="#Generator-2542"><span class="linenos">2542</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> +</span><span id="Generator-2543"><a href="#Generator-2543"><span class="linenos">2543</span></a> +</span><span id="Generator-2544"><a href="#Generator-2544"><span class="linenos">2544</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</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">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2545"><a href="#Generator-2545"><span class="linenos">2545</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Boolean</span><span class="p">):</span> +</span><span id="Generator-2546"><a href="#Generator-2546"><span class="linenos">2546</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator-2547"><a href="#Generator-2547"><span class="linenos">2547</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator-2548"><a href="#Generator-2548"><span class="linenos">2548</span></a> <span class="p">)</span> +</span><span id="Generator-2549"><a href="#Generator-2549"><span class="linenos">2549</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> +</span><span id="Generator-2550"><a href="#Generator-2550"><span class="linenos">2550</span></a> +</span><span id="Generator-2551"><a href="#Generator-2551"><span class="linenos">2551</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</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">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2552"><a href="#Generator-2552"><span class="linenos">2552</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> +</span><span id="Generator-2553"><a href="#Generator-2553"><span class="linenos">2553</span></a> +</span><span id="Generator-2554"><a href="#Generator-2554"><span class="linenos">2554</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</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">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2555"><a href="#Generator-2555"><span class="linenos">2555</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> +</span><span id="Generator-2556"><a href="#Generator-2556"><span class="linenos">2556</span></a> +</span><span id="Generator-2557"><a href="#Generator-2557"><span class="linenos">2557</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</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">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2558"><a href="#Generator-2558"><span class="linenos">2558</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> +</span><span id="Generator-2559"><a href="#Generator-2559"><span class="linenos">2559</span></a> +</span><span id="Generator-2560"><a href="#Generator-2560"><span class="linenos">2560</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</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">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2561"><a href="#Generator-2561"><span class="linenos">2561</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> +</span><span id="Generator-2562"><a href="#Generator-2562"><span class="linenos">2562</span></a> +</span><span id="Generator-2563"><a href="#Generator-2563"><span class="linenos">2563</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</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">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2564"><a href="#Generator-2564"><span class="linenos">2564</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> +</span><span id="Generator-2565"><a href="#Generator-2565"><span class="linenos">2565</span></a> +</span><span id="Generator-2566"><a href="#Generator-2566"><span class="linenos">2566</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</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">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2567"><a href="#Generator-2567"><span class="linenos">2567</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> +</span><span id="Generator-2568"><a href="#Generator-2568"><span class="linenos">2568</span></a> +</span><span id="Generator-2569"><a href="#Generator-2569"><span class="linenos">2569</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</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">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2570"><a href="#Generator-2570"><span class="linenos">2570</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> +</span><span id="Generator-2571"><a href="#Generator-2571"><span class="linenos">2571</span></a> +</span><span id="Generator-2572"><a href="#Generator-2572"><span class="linenos">2572</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</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">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2573"><a href="#Generator-2573"><span class="linenos">2573</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> +</span><span id="Generator-2574"><a href="#Generator-2574"><span class="linenos">2574</span></a> +</span><span id="Generator-2575"><a href="#Generator-2575"><span class="linenos">2575</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2576"><a href="#Generator-2576"><span class="linenos">2576</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> +</span><span id="Generator-2577"><a href="#Generator-2577"><span class="linenos">2577</span></a> +</span><span id="Generator-2578"><a href="#Generator-2578"><span class="linenos">2578</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2579"><a href="#Generator-2579"><span class="linenos">2579</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> +</span><span id="Generator-2580"><a href="#Generator-2580"><span class="linenos">2580</span></a> +</span><span id="Generator-2581"><a href="#Generator-2581"><span class="linenos">2581</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</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">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2582"><a href="#Generator-2582"><span class="linenos">2582</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> +</span><span id="Generator-2583"><a href="#Generator-2583"><span class="linenos">2583</span></a> +</span><span id="Generator-2584"><a href="#Generator-2584"><span class="linenos">2584</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</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">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2585"><a href="#Generator-2585"><span class="linenos">2585</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> +</span><span id="Generator-2586"><a href="#Generator-2586"><span class="linenos">2586</span></a> +</span><span id="Generator-2587"><a href="#Generator-2587"><span class="linenos">2587</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</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">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2588"><a href="#Generator-2588"><span class="linenos">2588</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> +</span><span id="Generator-2589"><a href="#Generator-2589"><span class="linenos">2589</span></a> +</span><span id="Generator-2590"><a href="#Generator-2590"><span class="linenos">2590</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</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">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2591"><a href="#Generator-2591"><span class="linenos">2591</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY_"</span><span class="p">)</span> +</span><span id="Generator-2592"><a href="#Generator-2592"><span class="linenos">2592</span></a> +</span><span id="Generator-2593"><a href="#Generator-2593"><span class="linenos">2593</span></a> <span class="k">def</span> <span class="nf">log_sql</span><span class="p">(</span><span class="bp">self</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">Log</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2594"><a href="#Generator-2594"><span class="linenos">2594</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> +</span><span id="Generator-2595"><a href="#Generator-2595"><span class="linenos">2595</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> +</span><span id="Generator-2596"><a href="#Generator-2596"><span class="linenos">2596</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> +</span><span id="Generator-2597"><a href="#Generator-2597"><span class="linenos">2597</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LOG"</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> +</span><span id="Generator-2598"><a href="#Generator-2598"><span class="linenos">2598</span></a> +</span><span id="Generator-2599"><a href="#Generator-2599"><span class="linenos">2599</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</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">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2600"><a href="#Generator-2600"><span class="linenos">2600</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-2601"><a href="#Generator-2601"><span class="linenos">2601</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2602"><a href="#Generator-2602"><span class="linenos">2602</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2603"><a href="#Generator-2603"><span class="linenos">2603</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2604"><a href="#Generator-2604"><span class="linenos">2604</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2605"><a href="#Generator-2605"><span class="linenos">2605</span></a> +</span><span id="Generator-2606"><a href="#Generator-2606"><span class="linenos">2606</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</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">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2607"><a href="#Generator-2607"><span class="linenos">2607</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> +</span><span id="Generator-2608"><a href="#Generator-2608"><span class="linenos">2608</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2609"><a href="#Generator-2609"><span class="linenos">2609</span></a> +</span><span id="Generator-2610"><a href="#Generator-2610"><span class="linenos">2610</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</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">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2611"><a href="#Generator-2611"><span class="linenos">2611</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-2612"><a href="#Generator-2612"><span class="linenos">2612</span></a> +</span><span id="Generator-2613"><a href="#Generator-2613"><span class="linenos">2613</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> +</span><span id="Generator-2614"><a href="#Generator-2614"><span class="linenos">2614</span></a> <span class="n">arg_value</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="n">key</span><span class="p">)</span> +</span><span id="Generator-2615"><a href="#Generator-2615"><span class="linenos">2615</span></a> +</span><span id="Generator-2616"><a href="#Generator-2616"><span class="linenos">2616</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator-2617"><a href="#Generator-2617"><span class="linenos">2617</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> +</span><span id="Generator-2618"><a href="#Generator-2618"><span class="linenos">2618</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Generator-2619"><a href="#Generator-2619"><span class="linenos">2619</span></a> <span class="k">elif</span> <span class="n">arg_value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-2620"><a href="#Generator-2620"><span class="linenos">2620</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> +</span><span id="Generator-2621"><a href="#Generator-2621"><span class="linenos">2621</span></a> +</span><span id="Generator-2622"><a href="#Generator-2622"><span class="linenos">2622</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span><span class="p">:</span> +</span><span id="Generator-2623"><a href="#Generator-2623"><span class="linenos">2623</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> +</span><span id="Generator-2624"><a href="#Generator-2624"><span class="linenos">2624</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2625"><a href="#Generator-2625"><span class="linenos">2625</span></a> <span class="n">name</span> <span class="o">=</span> <span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">_meta</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">))</span> <span class="ow">or</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> +</span><span id="Generator-2626"><a href="#Generator-2626"><span class="linenos">2626</span></a> +</span><span id="Generator-2627"><a href="#Generator-2627"><span class="linenos">2627</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> +</span><span id="Generator-2628"><a href="#Generator-2628"><span class="linenos">2628</span></a> +</span><span id="Generator-2629"><a href="#Generator-2629"><span class="linenos">2629</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> +</span><span id="Generator-2630"><a href="#Generator-2630"><span class="linenos">2630</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-2631"><a href="#Generator-2631"><span class="linenos">2631</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator-2632"><a href="#Generator-2632"><span class="linenos">2632</span></a> <span class="o">*</span><span class="n">args</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">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> +</span><span id="Generator-2633"><a href="#Generator-2633"><span class="linenos">2633</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> +</span><span id="Generator-2634"><a href="#Generator-2634"><span class="linenos">2634</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> +</span><span id="Generator-2635"><a href="#Generator-2635"><span class="linenos">2635</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2636"><a href="#Generator-2636"><span class="linenos">2636</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2637"><a href="#Generator-2637"><span class="linenos">2637</span></a> +</span><span id="Generator-2638"><a href="#Generator-2638"><span class="linenos">2638</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</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="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2639"><a href="#Generator-2639"><span class="linenos">2639</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator-2640"><a href="#Generator-2640"><span class="linenos">2640</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="Generator-2641"><a href="#Generator-2641"><span class="linenos">2641</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2642"><a href="#Generator-2642"><span class="linenos">2642</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> </span><span id="Generator-2643"><a href="#Generator-2643"><span class="linenos">2643</span></a> -</span><span id="Generator-2644"><a href="#Generator-2644"><span class="linenos">2644</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="Generator-2645"><a href="#Generator-2645"><span class="linenos">2645</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator-2646"><a href="#Generator-2646"><span class="linenos">2646</span></a> <span class="n">expression</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-2647"><a href="#Generator-2647"><span class="linenos">2647</span></a> <span class="n">key</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-2648"><a href="#Generator-2648"><span class="linenos">2648</span></a> <span class="n">sqls</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">Collection</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator-2649"><a href="#Generator-2649"><span class="linenos">2649</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-2650"><a href="#Generator-2650"><span class="linenos">2650</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator-2651"><a href="#Generator-2651"><span class="linenos">2651</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-2652"><a href="#Generator-2652"><span class="linenos">2652</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="Generator-2653"><a href="#Generator-2653"><span class="linenos">2653</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator-2654"><a href="#Generator-2654"><span class="linenos">2654</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2655"><a href="#Generator-2655"><span class="linenos">2655</span></a> <span class="n">expressions</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="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> -</span><span id="Generator-2656"><a href="#Generator-2656"><span class="linenos">2656</span></a> -</span><span id="Generator-2657"><a href="#Generator-2657"><span class="linenos">2657</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator-2658"><a href="#Generator-2658"><span class="linenos">2658</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-2659"><a href="#Generator-2659"><span class="linenos">2659</span></a> -</span><span id="Generator-2660"><a href="#Generator-2660"><span class="linenos">2660</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator-2661"><a href="#Generator-2661"><span class="linenos">2661</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sql</span> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator-2662"><a href="#Generator-2662"><span class="linenos">2662</span></a> -</span><span id="Generator-2663"><a href="#Generator-2663"><span class="linenos">2663</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-2644"><a href="#Generator-2644"><span class="linenos">2644</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="Generator-2645"><a href="#Generator-2645"><span class="linenos">2645</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> +</span><span id="Generator-2646"><a href="#Generator-2646"><span class="linenos">2646</span></a> +</span><span id="Generator-2647"><a href="#Generator-2647"><span class="linenos">2647</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator-2648"><a href="#Generator-2648"><span class="linenos">2648</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="Generator-2649"><a href="#Generator-2649"><span class="linenos">2649</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> +</span><span id="Generator-2650"><a href="#Generator-2650"><span class="linenos">2650</span></a> <span class="p">)</span> +</span><span id="Generator-2651"><a href="#Generator-2651"><span class="linenos">2651</span></a> +</span><span id="Generator-2652"><a href="#Generator-2652"><span class="linenos">2652</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> +</span><span id="Generator-2653"><a href="#Generator-2653"><span class="linenos">2653</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator-2654"><a href="#Generator-2654"><span class="linenos">2654</span></a> <span class="n">expression</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-2655"><a href="#Generator-2655"><span class="linenos">2655</span></a> <span class="n">key</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-2656"><a href="#Generator-2656"><span class="linenos">2656</span></a> <span class="n">sqls</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">Collection</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator-2657"><a href="#Generator-2657"><span class="linenos">2657</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-2658"><a href="#Generator-2658"><span class="linenos">2658</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator-2659"><a href="#Generator-2659"><span class="linenos">2659</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-2660"><a href="#Generator-2660"><span class="linenos">2660</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="Generator-2661"><a href="#Generator-2661"><span class="linenos">2661</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator-2662"><a href="#Generator-2662"><span class="linenos">2662</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2663"><a href="#Generator-2663"><span class="linenos">2663</span></a> <span class="n">expressions</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="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> </span><span id="Generator-2664"><a href="#Generator-2664"><span class="linenos">2664</span></a> -</span><span id="Generator-2665"><a href="#Generator-2665"><span class="linenos">2665</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> -</span><span id="Generator-2666"><a href="#Generator-2666"><span class="linenos">2666</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> -</span><span id="Generator-2667"><a href="#Generator-2667"><span class="linenos">2667</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator-2668"><a href="#Generator-2668"><span class="linenos">2668</span></a> -</span><span id="Generator-2669"><a href="#Generator-2669"><span class="linenos">2669</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator-2670"><a href="#Generator-2670"><span class="linenos">2670</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="Generator-2671"><a href="#Generator-2671"><span class="linenos">2671</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-2672"><a href="#Generator-2672"><span class="linenos">2672</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">sql</span><span class="p">:</span> -</span><span id="Generator-2673"><a href="#Generator-2673"><span class="linenos">2673</span></a> <span class="k">continue</span> -</span><span id="Generator-2674"><a href="#Generator-2674"><span class="linenos">2674</span></a> -</span><span id="Generator-2675"><a href="#Generator-2675"><span class="linenos">2675</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2665"><a href="#Generator-2665"><span class="linenos">2665</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator-2666"><a href="#Generator-2666"><span class="linenos">2666</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-2667"><a href="#Generator-2667"><span class="linenos">2667</span></a> +</span><span id="Generator-2668"><a href="#Generator-2668"><span class="linenos">2668</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator-2669"><a href="#Generator-2669"><span class="linenos">2669</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sql</span> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator-2670"><a href="#Generator-2670"><span class="linenos">2670</span></a> +</span><span id="Generator-2671"><a href="#Generator-2671"><span class="linenos">2671</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-2672"><a href="#Generator-2672"><span class="linenos">2672</span></a> +</span><span id="Generator-2673"><a href="#Generator-2673"><span class="linenos">2673</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> +</span><span id="Generator-2674"><a href="#Generator-2674"><span class="linenos">2674</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> +</span><span id="Generator-2675"><a href="#Generator-2675"><span class="linenos">2675</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> </span><span id="Generator-2676"><a href="#Generator-2676"><span class="linenos">2676</span></a> -</span><span id="Generator-2677"><a href="#Generator-2677"><span class="linenos">2677</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator-2678"><a href="#Generator-2678"><span class="linenos">2678</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> -</span><span id="Generator-2679"><a href="#Generator-2679"><span class="linenos">2679</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-2680"><a href="#Generator-2680"><span class="linenos">2680</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2681"><a href="#Generator-2681"><span class="linenos">2681</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Generator-2682"><a href="#Generator-2682"><span class="linenos">2682</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2683"><a href="#Generator-2683"><span class="linenos">2683</span></a> <span class="p">)</span> -</span><span id="Generator-2684"><a href="#Generator-2684"><span class="linenos">2684</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2685"><a href="#Generator-2685"><span class="linenos">2685</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-2686"><a href="#Generator-2686"><span class="linenos">2686</span></a> -</span><span id="Generator-2687"><a href="#Generator-2687"><span class="linenos">2687</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> -</span><span id="Generator-2688"><a href="#Generator-2688"><span class="linenos">2688</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="n">skip_first</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> -</span><span id="Generator-2689"><a href="#Generator-2689"><span class="linenos">2689</span></a> -</span><span id="Generator-2690"><a href="#Generator-2690"><span class="linenos">2690</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</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">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2691"><a href="#Generator-2691"><span class="linenos">2691</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> -</span><span id="Generator-2692"><a href="#Generator-2692"><span class="linenos">2692</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> -</span><span id="Generator-2693"><a href="#Generator-2693"><span class="linenos">2693</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator-2694"><a href="#Generator-2694"><span class="linenos">2694</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2695"><a href="#Generator-2695"><span class="linenos">2695</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2696"><a href="#Generator-2696"><span class="linenos">2696</span></a> -</span><span id="Generator-2697"><a href="#Generator-2697"><span class="linenos">2697</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</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">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2698"><a href="#Generator-2698"><span class="linenos">2698</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="Generator-2699"><a href="#Generator-2699"><span class="linenos">2699</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="Generator-2700"><a href="#Generator-2700"><span class="linenos">2700</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator-2701"><a href="#Generator-2701"><span class="linenos">2701</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2702"><a href="#Generator-2702"><span class="linenos">2702</span></a> -</span><span id="Generator-2703"><a href="#Generator-2703"><span class="linenos">2703</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2704"><a href="#Generator-2704"><span class="linenos">2704</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2705"><a href="#Generator-2705"><span class="linenos">2705</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> -</span><span id="Generator-2706"><a href="#Generator-2706"><span class="linenos">2706</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="Generator-2707"><a href="#Generator-2707"><span class="linenos">2707</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2708"><a href="#Generator-2708"><span class="linenos">2708</span></a> <span class="p">)</span> -</span><span id="Generator-2709"><a href="#Generator-2709"><span class="linenos">2709</span></a> -</span><span id="Generator-2710"><a href="#Generator-2710"><span class="linenos">2710</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</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">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2711"><a href="#Generator-2711"><span class="linenos">2711</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</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="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</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="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2712"><a href="#Generator-2712"><span class="linenos">2712</span></a> -</span><span id="Generator-2713"><a href="#Generator-2713"><span class="linenos">2713</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2714"><a href="#Generator-2714"><span class="linenos">2714</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> -</span><span id="Generator-2715"><a href="#Generator-2715"><span class="linenos">2715</span></a> -</span><span id="Generator-2716"><a href="#Generator-2716"><span class="linenos">2716</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</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">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2717"><a href="#Generator-2717"><span class="linenos">2717</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2718"><a href="#Generator-2718"><span class="linenos">2718</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2719"><a href="#Generator-2719"><span class="linenos">2719</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator-2720"><a href="#Generator-2720"><span class="linenos">2720</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</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">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2721"><a href="#Generator-2721"><span class="linenos">2721</span></a> <span class="p">)</span> -</span><span id="Generator-2722"><a href="#Generator-2722"><span class="linenos">2722</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2677"><a href="#Generator-2677"><span class="linenos">2677</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator-2678"><a href="#Generator-2678"><span class="linenos">2678</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="Generator-2679"><a href="#Generator-2679"><span class="linenos">2679</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-2680"><a href="#Generator-2680"><span class="linenos">2680</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">sql</span><span class="p">:</span> +</span><span id="Generator-2681"><a href="#Generator-2681"><span class="linenos">2681</span></a> <span class="k">continue</span> +</span><span id="Generator-2682"><a href="#Generator-2682"><span class="linenos">2682</span></a> +</span><span id="Generator-2683"><a href="#Generator-2683"><span class="linenos">2683</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2684"><a href="#Generator-2684"><span class="linenos">2684</span></a> +</span><span id="Generator-2685"><a href="#Generator-2685"><span class="linenos">2685</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator-2686"><a href="#Generator-2686"><span class="linenos">2686</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> +</span><span id="Generator-2687"><a href="#Generator-2687"><span class="linenos">2687</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-2688"><a href="#Generator-2688"><span class="linenos">2688</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2689"><a href="#Generator-2689"><span class="linenos">2689</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Generator-2690"><a href="#Generator-2690"><span class="linenos">2690</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2691"><a href="#Generator-2691"><span class="linenos">2691</span></a> <span class="p">)</span> +</span><span id="Generator-2692"><a href="#Generator-2692"><span class="linenos">2692</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2693"><a href="#Generator-2693"><span class="linenos">2693</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-2694"><a href="#Generator-2694"><span class="linenos">2694</span></a> +</span><span id="Generator-2695"><a href="#Generator-2695"><span class="linenos">2695</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> +</span><span id="Generator-2696"><a href="#Generator-2696"><span class="linenos">2696</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="n">skip_first</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> +</span><span id="Generator-2697"><a href="#Generator-2697"><span class="linenos">2697</span></a> +</span><span id="Generator-2698"><a href="#Generator-2698"><span class="linenos">2698</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</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">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2699"><a href="#Generator-2699"><span class="linenos">2699</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> +</span><span id="Generator-2700"><a href="#Generator-2700"><span class="linenos">2700</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> +</span><span id="Generator-2701"><a href="#Generator-2701"><span class="linenos">2701</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator-2702"><a href="#Generator-2702"><span class="linenos">2702</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2703"><a href="#Generator-2703"><span class="linenos">2703</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2704"><a href="#Generator-2704"><span class="linenos">2704</span></a> +</span><span id="Generator-2705"><a href="#Generator-2705"><span class="linenos">2705</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</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">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2706"><a href="#Generator-2706"><span class="linenos">2706</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> +</span><span id="Generator-2707"><a href="#Generator-2707"><span class="linenos">2707</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="Generator-2708"><a href="#Generator-2708"><span class="linenos">2708</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator-2709"><a href="#Generator-2709"><span class="linenos">2709</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2710"><a href="#Generator-2710"><span class="linenos">2710</span></a> +</span><span id="Generator-2711"><a href="#Generator-2711"><span class="linenos">2711</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2712"><a href="#Generator-2712"><span class="linenos">2712</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2713"><a href="#Generator-2713"><span class="linenos">2713</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> +</span><span id="Generator-2714"><a href="#Generator-2714"><span class="linenos">2714</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="Generator-2715"><a href="#Generator-2715"><span class="linenos">2715</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2716"><a href="#Generator-2716"><span class="linenos">2716</span></a> <span class="p">)</span> +</span><span id="Generator-2717"><a href="#Generator-2717"><span class="linenos">2717</span></a> +</span><span id="Generator-2718"><a href="#Generator-2718"><span class="linenos">2718</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</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">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2719"><a href="#Generator-2719"><span class="linenos">2719</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</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="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</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="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2720"><a href="#Generator-2720"><span class="linenos">2720</span></a> +</span><span id="Generator-2721"><a href="#Generator-2721"><span class="linenos">2721</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2722"><a href="#Generator-2722"><span class="linenos">2722</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> </span><span id="Generator-2723"><a href="#Generator-2723"><span class="linenos">2723</span></a> -</span><span id="Generator-2724"><a href="#Generator-2724"><span class="linenos">2724</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</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">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2724"><a href="#Generator-2724"><span class="linenos">2724</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</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">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> </span><span id="Generator-2725"><a href="#Generator-2725"><span class="linenos">2725</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2726"><a href="#Generator-2726"><span class="linenos">2726</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2727"><a href="#Generator-2727"><span class="linenos">2727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2728"><a href="#Generator-2728"><span class="linenos">2728</span></a> -</span><span id="Generator-2729"><a href="#Generator-2729"><span class="linenos">2729</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</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">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2730"><a href="#Generator-2730"><span class="linenos">2730</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> +</span><span id="Generator-2726"><a href="#Generator-2726"><span class="linenos">2726</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2727"><a href="#Generator-2727"><span class="linenos">2727</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator-2728"><a href="#Generator-2728"><span class="linenos">2728</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</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">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2729"><a href="#Generator-2729"><span class="linenos">2729</span></a> <span class="p">)</span> +</span><span id="Generator-2730"><a href="#Generator-2730"><span class="linenos">2730</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2731"><a href="#Generator-2731"><span class="linenos">2731</span></a> -</span><span id="Generator-2732"><a href="#Generator-2732"><span class="linenos">2732</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</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">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2733"><a href="#Generator-2733"><span class="linenos">2733</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> -</span><span id="Generator-2734"><a href="#Generator-2734"><span class="linenos">2734</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</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">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2735"><a href="#Generator-2735"><span class="linenos">2735</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="Generator-2736"><a href="#Generator-2736"><span class="linenos">2736</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2737"><a href="#Generator-2737"><span class="linenos">2737</span></a> -</span><span id="Generator-2738"><a href="#Generator-2738"><span class="linenos">2738</span></a> <span class="n">then_expression</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">"then"</span><span class="p">)</span> -</span><span id="Generator-2739"><a href="#Generator-2739"><span class="linenos">2739</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> -</span><span id="Generator-2740"><a href="#Generator-2740"><span class="linenos">2740</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2741"><a href="#Generator-2741"><span class="linenos">2741</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> -</span><span id="Generator-2742"><a href="#Generator-2742"><span class="linenos">2742</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2743"><a href="#Generator-2743"><span class="linenos">2743</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="Generator-2744"><a href="#Generator-2744"><span class="linenos">2744</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_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">"expressions"</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="Generator-2745"><a href="#Generator-2745"><span class="linenos">2745</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2746"><a href="#Generator-2746"><span class="linenos">2746</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2747"><a href="#Generator-2747"><span class="linenos">2747</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2748"><a href="#Generator-2748"><span class="linenos">2748</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator-2749"><a href="#Generator-2749"><span class="linenos">2749</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> -</span><span id="Generator-2750"><a href="#Generator-2750"><span class="linenos">2750</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2751"><a href="#Generator-2751"><span class="linenos">2751</span></a> -</span><span id="Generator-2752"><a href="#Generator-2752"><span class="linenos">2752</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</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">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2753"><a href="#Generator-2753"><span class="linenos">2753</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator-2754"><a href="#Generator-2754"><span class="linenos">2754</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator-2755"><a href="#Generator-2755"><span class="linenos">2755</span></a> -</span><span id="Generator-2756"><a href="#Generator-2756"><span class="linenos">2756</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="n">table</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">"hints"</span><span class="p">)</span> -</span><span id="Generator-2757"><a href="#Generator-2757"><span class="linenos">2757</span></a> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="n">table</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">hints</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">):</span> -</span><span id="Generator-2758"><a href="#Generator-2758"><span class="linenos">2758</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> -</span><span id="Generator-2759"><a href="#Generator-2759"><span class="linenos">2759</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Generator-2760"><a href="#Generator-2760"><span class="linenos">2760</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'alias'</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">())</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2761"><a href="#Generator-2761"><span class="linenos">2761</span></a> -</span><span id="Generator-2762"><a href="#Generator-2762"><span class="linenos">2762</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="Generator-2763"><a href="#Generator-2763"><span class="linenos">2763</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2764"><a href="#Generator-2764"><span class="linenos">2764</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2765"><a href="#Generator-2765"><span class="linenos">2765</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-2766"><a href="#Generator-2766"><span class="linenos">2766</span></a> -</span><span id="Generator-2767"><a href="#Generator-2767"><span class="linenos">2767</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">table_alias</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2768"><a href="#Generator-2768"><span class="linenos">2768</span></a> -</span><span id="Generator-2769"><a href="#Generator-2769"><span class="linenos">2769</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</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">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2770"><a href="#Generator-2770"><span class="linenos">2770</span></a> <span class="k">if</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">"format"</span><span class="p">):</span> -</span><span id="Generator-2771"><a href="#Generator-2771"><span class="linenos">2771</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> -</span><span id="Generator-2772"><a href="#Generator-2772"><span class="linenos">2772</span></a> -</span><span id="Generator-2773"><a href="#Generator-2773"><span class="linenos">2773</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> +</span><span id="Generator-2732"><a href="#Generator-2732"><span class="linenos">2732</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</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">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2733"><a href="#Generator-2733"><span class="linenos">2733</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2734"><a href="#Generator-2734"><span class="linenos">2734</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2735"><a href="#Generator-2735"><span class="linenos">2735</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2736"><a href="#Generator-2736"><span class="linenos">2736</span></a> +</span><span id="Generator-2737"><a href="#Generator-2737"><span class="linenos">2737</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</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">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2738"><a href="#Generator-2738"><span class="linenos">2738</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> +</span><span id="Generator-2739"><a href="#Generator-2739"><span class="linenos">2739</span></a> +</span><span id="Generator-2740"><a href="#Generator-2740"><span class="linenos">2740</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</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">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2741"><a href="#Generator-2741"><span class="linenos">2741</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> +</span><span id="Generator-2742"><a href="#Generator-2742"><span class="linenos">2742</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</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">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2743"><a href="#Generator-2743"><span class="linenos">2743</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="Generator-2744"><a href="#Generator-2744"><span class="linenos">2744</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2745"><a href="#Generator-2745"><span class="linenos">2745</span></a> +</span><span id="Generator-2746"><a href="#Generator-2746"><span class="linenos">2746</span></a> <span class="n">then_expression</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">"then"</span><span class="p">)</span> +</span><span id="Generator-2747"><a href="#Generator-2747"><span class="linenos">2747</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> +</span><span id="Generator-2748"><a href="#Generator-2748"><span class="linenos">2748</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2749"><a href="#Generator-2749"><span class="linenos">2749</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> +</span><span id="Generator-2750"><a href="#Generator-2750"><span class="linenos">2750</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2751"><a href="#Generator-2751"><span class="linenos">2751</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="Generator-2752"><a href="#Generator-2752"><span class="linenos">2752</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_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">"expressions"</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="Generator-2753"><a href="#Generator-2753"><span class="linenos">2753</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2754"><a href="#Generator-2754"><span class="linenos">2754</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2755"><a href="#Generator-2755"><span class="linenos">2755</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2756"><a href="#Generator-2756"><span class="linenos">2756</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator-2757"><a href="#Generator-2757"><span class="linenos">2757</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> +</span><span id="Generator-2758"><a href="#Generator-2758"><span class="linenos">2758</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2759"><a href="#Generator-2759"><span class="linenos">2759</span></a> +</span><span id="Generator-2760"><a href="#Generator-2760"><span class="linenos">2760</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</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">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2761"><a href="#Generator-2761"><span class="linenos">2761</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator-2762"><a href="#Generator-2762"><span class="linenos">2762</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator-2763"><a href="#Generator-2763"><span class="linenos">2763</span></a> +</span><span id="Generator-2764"><a href="#Generator-2764"><span class="linenos">2764</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="n">table</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">"hints"</span><span class="p">)</span> +</span><span id="Generator-2765"><a href="#Generator-2765"><span class="linenos">2765</span></a> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="n">table</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">hints</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">):</span> +</span><span id="Generator-2766"><a href="#Generator-2766"><span class="linenos">2766</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> +</span><span id="Generator-2767"><a href="#Generator-2767"><span class="linenos">2767</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Generator-2768"><a href="#Generator-2768"><span class="linenos">2768</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'alias'</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">())</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2769"><a href="#Generator-2769"><span class="linenos">2769</span></a> +</span><span id="Generator-2770"><a href="#Generator-2770"><span class="linenos">2770</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="Generator-2771"><a href="#Generator-2771"><span class="linenos">2771</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2772"><a href="#Generator-2772"><span class="linenos">2772</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2773"><a href="#Generator-2773"><span class="linenos">2773</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> </span><span id="Generator-2774"><a href="#Generator-2774"><span class="linenos">2774</span></a> -</span><span id="Generator-2775"><a href="#Generator-2775"><span class="linenos">2775</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2776"><a href="#Generator-2776"><span class="linenos">2776</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2777"><a href="#Generator-2777"><span class="linenos">2777</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-2778"><a href="#Generator-2778"><span class="linenos">2778</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-2779"><a href="#Generator-2779"><span class="linenos">2779</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> -</span><span id="Generator-2780"><a href="#Generator-2780"><span class="linenos">2780</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2781"><a href="#Generator-2781"><span class="linenos">2781</span></a> -</span><span id="Generator-2782"><a href="#Generator-2782"><span class="linenos">2782</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</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">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2783"><a href="#Generator-2783"><span class="linenos">2783</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2784"><a href="#Generator-2784"><span class="linenos">2784</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> -</span><span id="Generator-2785"><a href="#Generator-2785"><span class="linenos">2785</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> -</span><span id="Generator-2786"><a href="#Generator-2786"><span class="linenos">2786</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2787"><a href="#Generator-2787"><span class="linenos">2787</span></a> -</span><span id="Generator-2788"><a href="#Generator-2788"><span class="linenos">2788</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2789"><a href="#Generator-2789"><span class="linenos">2789</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2790"><a href="#Generator-2790"><span class="linenos">2790</span></a> -</span><span id="Generator-2791"><a href="#Generator-2791"><span class="linenos">2791</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</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">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2792"><a href="#Generator-2792"><span class="linenos">2792</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-2793"><a href="#Generator-2793"><span class="linenos">2793</span></a> -</span><span id="Generator-2794"><a href="#Generator-2794"><span class="linenos">2794</span></a> <span class="k">def</span> <span class="nf">clusteredbyproperty_sql</span><span class="p">(</span><span class="bp">self</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">ClusteredByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2795"><a href="#Generator-2795"><span class="linenos">2795</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2796"><a href="#Generator-2796"><span class="linenos">2796</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"sorted_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator-2797"><a href="#Generator-2797"><span class="linenos">2797</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SORTED BY (</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">sorted_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2798"><a href="#Generator-2798"><span class="linenos">2798</span></a> <span class="n">buckets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"buckets"</span><span class="p">)</span> -</span><span id="Generator-2799"><a href="#Generator-2799"><span class="linenos">2799</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLUSTERED BY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2"> INTO </span><span class="si">{</span><span class="n">buckets</span><span class="si">}</span><span class="s2"> BUCKETS"</span> -</span><span id="Generator-2800"><a href="#Generator-2800"><span class="linenos">2800</span></a> -</span><span id="Generator-2801"><a href="#Generator-2801"><span class="linenos">2801</span></a> <span class="k">def</span> <span class="nf">anyvalue_sql</span><span class="p">(</span><span class="bp">self</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">AnyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2802"><a href="#Generator-2802"><span class="linenos">2802</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2803"><a href="#Generator-2803"><span class="linenos">2803</span></a> <span class="n">having</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">)</span> -</span><span id="Generator-2804"><a href="#Generator-2804"><span class="linenos">2804</span></a> -</span><span id="Generator-2805"><a href="#Generator-2805"><span class="linenos">2805</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> -</span><span id="Generator-2806"><a href="#Generator-2806"><span class="linenos">2806</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> HAVING </span><span class="si">{</span><span class="s1">'MAX'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="s1">'max'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'MIN'</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">having</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2807"><a href="#Generator-2807"><span class="linenos">2807</span></a> -</span><span id="Generator-2808"><a href="#Generator-2808"><span class="linenos">2808</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ANY_VALUE"</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> -</span><span id="Generator-2809"><a href="#Generator-2809"><span class="linenos">2809</span></a> -</span><span id="Generator-2810"><a href="#Generator-2810"><span class="linenos">2810</span></a> <span class="k">def</span> <span class="nf">querytransform_sql</span><span class="p">(</span><span class="bp">self</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">QueryTransform</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2811"><a href="#Generator-2811"><span class="linenos">2811</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRANSFORM"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator-2812"><a href="#Generator-2812"><span class="linenos">2812</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_before"</span><span class="p">)</span> -</span><span id="Generator-2813"><a href="#Generator-2813"><span class="linenos">2813</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_before</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_before</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2814"><a href="#Generator-2814"><span class="linenos">2814</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_writer"</span><span class="p">)</span> -</span><span id="Generator-2815"><a href="#Generator-2815"><span class="linenos">2815</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDWRITER </span><span class="si">{</span><span class="n">record_writer</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_writer</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2816"><a href="#Generator-2816"><span class="linenos">2816</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'command_script'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2817"><a href="#Generator-2817"><span class="linenos">2817</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> -</span><span id="Generator-2818"><a href="#Generator-2818"><span class="linenos">2818</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2819"><a href="#Generator-2819"><span class="linenos">2819</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_after"</span><span class="p">)</span> -</span><span id="Generator-2820"><a href="#Generator-2820"><span class="linenos">2820</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_after</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2821"><a href="#Generator-2821"><span class="linenos">2821</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_reader"</span><span class="p">)</span> -</span><span id="Generator-2822"><a href="#Generator-2822"><span class="linenos">2822</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDREADER </span><span class="si">{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_reader</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2823"><a href="#Generator-2823"><span class="linenos">2823</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">transform</span><span class="si">}{</span><span class="n">row_format_before</span><span class="si">}{</span><span class="n">record_writer</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">row_format_after</span><span class="si">}{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2824"><a href="#Generator-2824"><span class="linenos">2824</span></a> -</span><span id="Generator-2825"><a href="#Generator-2825"><span class="linenos">2825</span></a> <span class="k">def</span> <span class="nf">indexconstraintoption_sql</span><span class="p">(</span><span class="bp">self</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">IndexConstraintOption</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2826"><a href="#Generator-2826"><span class="linenos">2826</span></a> <span class="n">key_block_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"key_block_size"</span><span class="p">)</span> -</span><span id="Generator-2827"><a href="#Generator-2827"><span class="linenos">2827</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> -</span><span id="Generator-2828"><a href="#Generator-2828"><span class="linenos">2828</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KEY_BLOCK_SIZE = </span><span class="si">{</span><span class="n">key_block_size</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2829"><a href="#Generator-2829"><span class="linenos">2829</span></a> -</span><span id="Generator-2830"><a href="#Generator-2830"><span class="linenos">2830</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator-2831"><a href="#Generator-2831"><span class="linenos">2831</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator-2832"><a href="#Generator-2832"><span class="linenos">2832</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2833"><a href="#Generator-2833"><span class="linenos">2833</span></a> -</span><span id="Generator-2834"><a href="#Generator-2834"><span class="linenos">2834</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"parser"</span><span class="p">)</span> -</span><span id="Generator-2835"><a href="#Generator-2835"><span class="linenos">2835</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Generator-2836"><a href="#Generator-2836"><span class="linenos">2836</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH PARSER </span><span class="si">{</span><span class="n">parser</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2775"><a href="#Generator-2775"><span class="linenos">2775</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">table_alias</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2776"><a href="#Generator-2776"><span class="linenos">2776</span></a> +</span><span id="Generator-2777"><a href="#Generator-2777"><span class="linenos">2777</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</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">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2778"><a href="#Generator-2778"><span class="linenos">2778</span></a> <span class="k">if</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">"format"</span><span class="p">):</span> +</span><span id="Generator-2779"><a href="#Generator-2779"><span class="linenos">2779</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> +</span><span id="Generator-2780"><a href="#Generator-2780"><span class="linenos">2780</span></a> +</span><span id="Generator-2781"><a href="#Generator-2781"><span class="linenos">2781</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> +</span><span id="Generator-2782"><a href="#Generator-2782"><span class="linenos">2782</span></a> +</span><span id="Generator-2783"><a href="#Generator-2783"><span class="linenos">2783</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2784"><a href="#Generator-2784"><span class="linenos">2784</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2785"><a href="#Generator-2785"><span class="linenos">2785</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-2786"><a href="#Generator-2786"><span class="linenos">2786</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-2787"><a href="#Generator-2787"><span class="linenos">2787</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> +</span><span id="Generator-2788"><a href="#Generator-2788"><span class="linenos">2788</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2789"><a href="#Generator-2789"><span class="linenos">2789</span></a> +</span><span id="Generator-2790"><a href="#Generator-2790"><span class="linenos">2790</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</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">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2791"><a href="#Generator-2791"><span class="linenos">2791</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2792"><a href="#Generator-2792"><span class="linenos">2792</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> +</span><span id="Generator-2793"><a href="#Generator-2793"><span class="linenos">2793</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> +</span><span id="Generator-2794"><a href="#Generator-2794"><span class="linenos">2794</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2795"><a href="#Generator-2795"><span class="linenos">2795</span></a> +</span><span id="Generator-2796"><a href="#Generator-2796"><span class="linenos">2796</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2797"><a href="#Generator-2797"><span class="linenos">2797</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2798"><a href="#Generator-2798"><span class="linenos">2798</span></a> +</span><span id="Generator-2799"><a href="#Generator-2799"><span class="linenos">2799</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</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">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2800"><a href="#Generator-2800"><span class="linenos">2800</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-2801"><a href="#Generator-2801"><span class="linenos">2801</span></a> +</span><span id="Generator-2802"><a href="#Generator-2802"><span class="linenos">2802</span></a> <span class="k">def</span> <span class="nf">clusteredbyproperty_sql</span><span class="p">(</span><span class="bp">self</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">ClusteredByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2803"><a href="#Generator-2803"><span class="linenos">2803</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2804"><a href="#Generator-2804"><span class="linenos">2804</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"sorted_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator-2805"><a href="#Generator-2805"><span class="linenos">2805</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SORTED BY (</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">sorted_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2806"><a href="#Generator-2806"><span class="linenos">2806</span></a> <span class="n">buckets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"buckets"</span><span class="p">)</span> +</span><span id="Generator-2807"><a href="#Generator-2807"><span class="linenos">2807</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLUSTERED BY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2"> INTO </span><span class="si">{</span><span class="n">buckets</span><span class="si">}</span><span class="s2"> BUCKETS"</span> +</span><span id="Generator-2808"><a href="#Generator-2808"><span class="linenos">2808</span></a> +</span><span id="Generator-2809"><a href="#Generator-2809"><span class="linenos">2809</span></a> <span class="k">def</span> <span class="nf">anyvalue_sql</span><span class="p">(</span><span class="bp">self</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">AnyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2810"><a href="#Generator-2810"><span class="linenos">2810</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2811"><a href="#Generator-2811"><span class="linenos">2811</span></a> <span class="n">having</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">)</span> +</span><span id="Generator-2812"><a href="#Generator-2812"><span class="linenos">2812</span></a> +</span><span id="Generator-2813"><a href="#Generator-2813"><span class="linenos">2813</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> +</span><span id="Generator-2814"><a href="#Generator-2814"><span class="linenos">2814</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> HAVING </span><span class="si">{</span><span class="s1">'MAX'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="s1">'max'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'MIN'</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">having</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2815"><a href="#Generator-2815"><span class="linenos">2815</span></a> +</span><span id="Generator-2816"><a href="#Generator-2816"><span class="linenos">2816</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ANY_VALUE"</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> +</span><span id="Generator-2817"><a href="#Generator-2817"><span class="linenos">2817</span></a> +</span><span id="Generator-2818"><a href="#Generator-2818"><span class="linenos">2818</span></a> <span class="k">def</span> <span class="nf">querytransform_sql</span><span class="p">(</span><span class="bp">self</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">QueryTransform</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2819"><a href="#Generator-2819"><span class="linenos">2819</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRANSFORM"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator-2820"><a href="#Generator-2820"><span class="linenos">2820</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_before"</span><span class="p">)</span> +</span><span id="Generator-2821"><a href="#Generator-2821"><span class="linenos">2821</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_before</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_before</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2822"><a href="#Generator-2822"><span class="linenos">2822</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_writer"</span><span class="p">)</span> +</span><span id="Generator-2823"><a href="#Generator-2823"><span class="linenos">2823</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDWRITER </span><span class="si">{</span><span class="n">record_writer</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_writer</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2824"><a href="#Generator-2824"><span class="linenos">2824</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'command_script'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2825"><a href="#Generator-2825"><span class="linenos">2825</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="Generator-2826"><a href="#Generator-2826"><span class="linenos">2826</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2827"><a href="#Generator-2827"><span class="linenos">2827</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_after"</span><span class="p">)</span> +</span><span id="Generator-2828"><a href="#Generator-2828"><span class="linenos">2828</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_after</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2829"><a href="#Generator-2829"><span class="linenos">2829</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_reader"</span><span class="p">)</span> +</span><span id="Generator-2830"><a href="#Generator-2830"><span class="linenos">2830</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDREADER </span><span class="si">{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_reader</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2831"><a href="#Generator-2831"><span class="linenos">2831</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">transform</span><span class="si">}{</span><span class="n">row_format_before</span><span class="si">}{</span><span class="n">record_writer</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">row_format_after</span><span class="si">}{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2832"><a href="#Generator-2832"><span class="linenos">2832</span></a> +</span><span id="Generator-2833"><a href="#Generator-2833"><span class="linenos">2833</span></a> <span class="k">def</span> <span class="nf">indexconstraintoption_sql</span><span class="p">(</span><span class="bp">self</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">IndexConstraintOption</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2834"><a href="#Generator-2834"><span class="linenos">2834</span></a> <span class="n">key_block_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"key_block_size"</span><span class="p">)</span> +</span><span id="Generator-2835"><a href="#Generator-2835"><span class="linenos">2835</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> +</span><span id="Generator-2836"><a href="#Generator-2836"><span class="linenos">2836</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KEY_BLOCK_SIZE = </span><span class="si">{</span><span class="n">key_block_size</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2837"><a href="#Generator-2837"><span class="linenos">2837</span></a> -</span><span id="Generator-2838"><a href="#Generator-2838"><span class="linenos">2838</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"comment"</span><span class="p">)</span> -</span><span id="Generator-2839"><a href="#Generator-2839"><span class="linenos">2839</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> -</span><span id="Generator-2840"><a href="#Generator-2840"><span class="linenos">2840</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT </span><span class="si">{</span><span class="n">comment</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2838"><a href="#Generator-2838"><span class="linenos">2838</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator-2839"><a href="#Generator-2839"><span class="linenos">2839</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator-2840"><a href="#Generator-2840"><span class="linenos">2840</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2841"><a href="#Generator-2841"><span class="linenos">2841</span></a> -</span><span id="Generator-2842"><a href="#Generator-2842"><span class="linenos">2842</span></a> <span class="n">visible</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">"visible"</span><span class="p">)</span> -</span><span id="Generator-2843"><a href="#Generator-2843"><span class="linenos">2843</span></a> <span class="k">if</span> <span class="n">visible</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator-2844"><a href="#Generator-2844"><span class="linenos">2844</span></a> <span class="k">return</span> <span class="s2">"VISIBLE"</span> <span class="k">if</span> <span class="n">visible</span> <span class="k">else</span> <span class="s2">"INVISIBLE"</span> +</span><span id="Generator-2842"><a href="#Generator-2842"><span class="linenos">2842</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"parser"</span><span class="p">)</span> +</span><span id="Generator-2843"><a href="#Generator-2843"><span class="linenos">2843</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Generator-2844"><a href="#Generator-2844"><span class="linenos">2844</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH PARSER </span><span class="si">{</span><span class="n">parser</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2845"><a href="#Generator-2845"><span class="linenos">2845</span></a> -</span><span id="Generator-2846"><a href="#Generator-2846"><span class="linenos">2846</span></a> <span class="n">engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"engine_attr"</span><span class="p">)</span> -</span><span id="Generator-2847"><a href="#Generator-2847"><span class="linenos">2847</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> -</span><span id="Generator-2848"><a href="#Generator-2848"><span class="linenos">2848</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2846"><a href="#Generator-2846"><span class="linenos">2846</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"comment"</span><span class="p">)</span> +</span><span id="Generator-2847"><a href="#Generator-2847"><span class="linenos">2847</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> +</span><span id="Generator-2848"><a href="#Generator-2848"><span class="linenos">2848</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT </span><span class="si">{</span><span class="n">comment</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator-2849"><a href="#Generator-2849"><span class="linenos">2849</span></a> -</span><span id="Generator-2850"><a href="#Generator-2850"><span class="linenos">2850</span></a> <span class="n">secondary_engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"secondary_engine_attr"</span><span class="p">)</span> -</span><span id="Generator-2851"><a href="#Generator-2851"><span class="linenos">2851</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> -</span><span id="Generator-2852"><a href="#Generator-2852"><span class="linenos">2852</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SECONDARY_ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">secondary_engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2850"><a href="#Generator-2850"><span class="linenos">2850</span></a> <span class="n">visible</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">"visible"</span><span class="p">)</span> +</span><span id="Generator-2851"><a href="#Generator-2851"><span class="linenos">2851</span></a> <span class="k">if</span> <span class="n">visible</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator-2852"><a href="#Generator-2852"><span class="linenos">2852</span></a> <span class="k">return</span> <span class="s2">"VISIBLE"</span> <span class="k">if</span> <span class="n">visible</span> <span class="k">else</span> <span class="s2">"INVISIBLE"</span> </span><span id="Generator-2853"><a href="#Generator-2853"><span class="linenos">2853</span></a> -</span><span id="Generator-2854"><a href="#Generator-2854"><span class="linenos">2854</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported index constraint option."</span><span class="p">)</span> -</span><span id="Generator-2855"><a href="#Generator-2855"><span class="linenos">2855</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator-2856"><a href="#Generator-2856"><span class="linenos">2856</span></a> -</span><span id="Generator-2857"><a href="#Generator-2857"><span class="linenos">2857</span></a> <span class="k">def</span> <span class="nf">indexcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</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">IndexColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2858"><a href="#Generator-2858"><span class="linenos">2858</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator-2859"><a href="#Generator-2859"><span class="linenos">2859</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> INDEX"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">"INDEX"</span> -</span><span id="Generator-2860"><a href="#Generator-2860"><span class="linenos">2860</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2861"><a href="#Generator-2861"><span class="linenos">2861</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2862"><a href="#Generator-2862"><span class="linenos">2862</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"index_type"</span><span class="p">)</span> -</span><span id="Generator-2863"><a href="#Generator-2863"><span class="linenos">2863</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">index_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2864"><a href="#Generator-2864"><span class="linenos">2864</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> -</span><span id="Generator-2865"><a href="#Generator-2865"><span class="linenos">2865</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2866"><a href="#Generator-2866"><span class="linenos">2866</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator-2867"><a href="#Generator-2867"><span class="linenos">2867</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2868"><a href="#Generator-2868"><span class="linenos">2868</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">index_type</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2869"><a href="#Generator-2869"><span class="linenos">2869</span></a> -</span><span id="Generator-2870"><a href="#Generator-2870"><span class="linenos">2870</span></a> <span class="k">def</span> <span class="nf">nvl2_sql</span><span class="p">(</span><span class="bp">self</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">Nvl2</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2871"><a href="#Generator-2871"><span class="linenos">2871</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">NVL2_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator-2872"><a href="#Generator-2872"><span class="linenos">2872</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator-2873"><a href="#Generator-2873"><span class="linenos">2873</span></a> -</span><span id="Generator-2874"><a href="#Generator-2874"><span class="linenos">2874</span></a> <span class="n">case</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span> -</span><span id="Generator-2875"><a href="#Generator-2875"><span class="linenos">2875</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">())</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Generator-2876"><a href="#Generator-2876"><span class="linenos">2876</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"true"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> -</span><span id="Generator-2877"><a href="#Generator-2877"><span class="linenos">2877</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator-2878"><a href="#Generator-2878"><span class="linenos">2878</span></a> <span class="p">)</span> -</span><span id="Generator-2879"><a href="#Generator-2879"><span class="linenos">2879</span></a> <span class="n">else_cond</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">"false"</span><span class="p">)</span> -</span><span id="Generator-2880"><a href="#Generator-2880"><span class="linenos">2880</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> -</span><span id="Generator-2881"><a href="#Generator-2881"><span class="linenos">2881</span></a> <span class="k">case</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">else_cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator-2882"><a href="#Generator-2882"><span class="linenos">2882</span></a> -</span><span id="Generator-2883"><a href="#Generator-2883"><span class="linenos">2883</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> -</span><span id="Generator-2884"><a href="#Generator-2884"><span class="linenos">2884</span></a> -</span><span id="Generator-2885"><a href="#Generator-2885"><span class="linenos">2885</span></a> <span class="k">def</span> <span class="nf">comprehension_sql</span><span class="p">(</span><span class="bp">self</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">Comprehension</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2886"><a href="#Generator-2886"><span class="linenos">2886</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2887"><a href="#Generator-2887"><span class="linenos">2887</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-2888"><a href="#Generator-2888"><span class="linenos">2888</span></a> <span class="n">iterator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"iterator"</span><span class="p">)</span> -</span><span id="Generator-2889"><a href="#Generator-2889"><span class="linenos">2889</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="Generator-2890"><a href="#Generator-2890"><span class="linenos">2890</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" IF </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator-2891"><a href="#Generator-2891"><span class="linenos">2891</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">iterator</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2854"><a href="#Generator-2854"><span class="linenos">2854</span></a> <span class="n">engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"engine_attr"</span><span class="p">)</span> +</span><span id="Generator-2855"><a href="#Generator-2855"><span class="linenos">2855</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> +</span><span id="Generator-2856"><a href="#Generator-2856"><span class="linenos">2856</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2857"><a href="#Generator-2857"><span class="linenos">2857</span></a> +</span><span id="Generator-2858"><a href="#Generator-2858"><span class="linenos">2858</span></a> <span class="n">secondary_engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"secondary_engine_attr"</span><span class="p">)</span> +</span><span id="Generator-2859"><a href="#Generator-2859"><span class="linenos">2859</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> +</span><span id="Generator-2860"><a href="#Generator-2860"><span class="linenos">2860</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SECONDARY_ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">secondary_engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2861"><a href="#Generator-2861"><span class="linenos">2861</span></a> +</span><span id="Generator-2862"><a href="#Generator-2862"><span class="linenos">2862</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported index constraint option."</span><span class="p">)</span> +</span><span id="Generator-2863"><a href="#Generator-2863"><span class="linenos">2863</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator-2864"><a href="#Generator-2864"><span class="linenos">2864</span></a> +</span><span id="Generator-2865"><a href="#Generator-2865"><span class="linenos">2865</span></a> <span class="k">def</span> <span class="nf">indexcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</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">IndexColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2866"><a href="#Generator-2866"><span class="linenos">2866</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator-2867"><a href="#Generator-2867"><span class="linenos">2867</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> INDEX"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">"INDEX"</span> +</span><span id="Generator-2868"><a href="#Generator-2868"><span class="linenos">2868</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2869"><a href="#Generator-2869"><span class="linenos">2869</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2870"><a href="#Generator-2870"><span class="linenos">2870</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"index_type"</span><span class="p">)</span> +</span><span id="Generator-2871"><a href="#Generator-2871"><span class="linenos">2871</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">index_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2872"><a href="#Generator-2872"><span class="linenos">2872</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="Generator-2873"><a href="#Generator-2873"><span class="linenos">2873</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2874"><a href="#Generator-2874"><span class="linenos">2874</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator-2875"><a href="#Generator-2875"><span class="linenos">2875</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2876"><a href="#Generator-2876"><span class="linenos">2876</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">index_type</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2877"><a href="#Generator-2877"><span class="linenos">2877</span></a> +</span><span id="Generator-2878"><a href="#Generator-2878"><span class="linenos">2878</span></a> <span class="k">def</span> <span class="nf">nvl2_sql</span><span class="p">(</span><span class="bp">self</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">Nvl2</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2879"><a href="#Generator-2879"><span class="linenos">2879</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">NVL2_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator-2880"><a href="#Generator-2880"><span class="linenos">2880</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator-2881"><a href="#Generator-2881"><span class="linenos">2881</span></a> +</span><span id="Generator-2882"><a href="#Generator-2882"><span class="linenos">2882</span></a> <span class="n">case</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span> +</span><span id="Generator-2883"><a href="#Generator-2883"><span class="linenos">2883</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">())</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Generator-2884"><a href="#Generator-2884"><span class="linenos">2884</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"true"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> +</span><span id="Generator-2885"><a href="#Generator-2885"><span class="linenos">2885</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator-2886"><a href="#Generator-2886"><span class="linenos">2886</span></a> <span class="p">)</span> +</span><span id="Generator-2887"><a href="#Generator-2887"><span class="linenos">2887</span></a> <span class="n">else_cond</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">"false"</span><span class="p">)</span> +</span><span id="Generator-2888"><a href="#Generator-2888"><span class="linenos">2888</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> +</span><span id="Generator-2889"><a href="#Generator-2889"><span class="linenos">2889</span></a> <span class="k">case</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">else_cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator-2890"><a href="#Generator-2890"><span class="linenos">2890</span></a> +</span><span id="Generator-2891"><a href="#Generator-2891"><span class="linenos">2891</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> </span><span id="Generator-2892"><a href="#Generator-2892"><span class="linenos">2892</span></a> -</span><span id="Generator-2893"><a href="#Generator-2893"><span class="linenos">2893</span></a> <span class="k">def</span> <span class="nf">columnprefix_sql</span><span class="p">(</span><span class="bp">self</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">ColumnPrefix</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2894"><a href="#Generator-2894"><span class="linenos">2894</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator-2895"><a href="#Generator-2895"><span class="linenos">2895</span></a> -</span><span id="Generator-2896"><a href="#Generator-2896"><span class="linenos">2896</span></a> <span class="k">def</span> <span class="nf">opclass_sql</span><span class="p">(</span><span class="bp">self</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">Opclass</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2897"><a href="#Generator-2897"><span class="linenos">2897</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2898"><a href="#Generator-2898"><span class="linenos">2898</span></a> -</span><span id="Generator-2899"><a href="#Generator-2899"><span class="linenos">2899</span></a> <span class="k">def</span> <span class="nf">predict_sql</span><span class="p">(</span><span class="bp">self</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">Predict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator-2900"><a href="#Generator-2900"><span class="linenos">2900</span></a> <span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator-2901"><a href="#Generator-2901"><span class="linenos">2901</span></a> <span class="n">model</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"MODEL </span><span class="si">{</span><span class="n">model</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator-2902"><a href="#Generator-2902"><span class="linenos">2902</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator-2903"><a href="#Generator-2903"><span class="linenos">2903</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Subquery</span><span class="p">)</span> <span class="k">else</span> <span class="n">table</span> -</span><span id="Generator-2904"><a href="#Generator-2904"><span class="linenos">2904</span></a> <span class="n">parameters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"params_struct"</span><span class="p">)</span> -</span><span id="Generator-2905"><a href="#Generator-2905"><span class="linenos">2905</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"PREDICT"</span><span class="p">,</span> <span class="n">model</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">parameters</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator-2893"><a href="#Generator-2893"><span class="linenos">2893</span></a> <span class="k">def</span> <span class="nf">comprehension_sql</span><span class="p">(</span><span class="bp">self</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">Comprehension</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2894"><a href="#Generator-2894"><span class="linenos">2894</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2895"><a href="#Generator-2895"><span class="linenos">2895</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-2896"><a href="#Generator-2896"><span class="linenos">2896</span></a> <span class="n">iterator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"iterator"</span><span class="p">)</span> +</span><span id="Generator-2897"><a href="#Generator-2897"><span class="linenos">2897</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="Generator-2898"><a href="#Generator-2898"><span class="linenos">2898</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" IF </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator-2899"><a href="#Generator-2899"><span class="linenos">2899</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">iterator</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2900"><a href="#Generator-2900"><span class="linenos">2900</span></a> +</span><span id="Generator-2901"><a href="#Generator-2901"><span class="linenos">2901</span></a> <span class="k">def</span> <span class="nf">columnprefix_sql</span><span class="p">(</span><span class="bp">self</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">ColumnPrefix</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2902"><a href="#Generator-2902"><span class="linenos">2902</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator-2903"><a href="#Generator-2903"><span class="linenos">2903</span></a> +</span><span id="Generator-2904"><a href="#Generator-2904"><span class="linenos">2904</span></a> <span class="k">def</span> <span class="nf">opclass_sql</span><span class="p">(</span><span class="bp">self</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">Opclass</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2905"><a href="#Generator-2905"><span class="linenos">2905</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2906"><a href="#Generator-2906"><span class="linenos">2906</span></a> +</span><span id="Generator-2907"><a href="#Generator-2907"><span class="linenos">2907</span></a> <span class="k">def</span> <span class="nf">predict_sql</span><span class="p">(</span><span class="bp">self</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">Predict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator-2908"><a href="#Generator-2908"><span class="linenos">2908</span></a> <span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator-2909"><a href="#Generator-2909"><span class="linenos">2909</span></a> <span class="n">model</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"MODEL </span><span class="si">{</span><span class="n">model</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator-2910"><a href="#Generator-2910"><span class="linenos">2910</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator-2911"><a href="#Generator-2911"><span class="linenos">2911</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Subquery</span><span class="p">)</span> <span class="k">else</span> <span class="n">table</span> +</span><span id="Generator-2912"><a href="#Generator-2912"><span class="linenos">2912</span></a> <span class="n">parameters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"params_struct"</span><span class="p">)</span> +</span><span id="Generator-2913"><a href="#Generator-2913"><span class="linenos">2913</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"PREDICT"</span><span class="p">,</span> <span class="n">model</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">parameters</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> </span></pre></div> @@ -12400,12 +12419,36 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.jsoncolumndef_sql"></a> <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsoncolumndef_sql-2182"><a href="#Generator.jsoncolumndef_sql-2182"><span class="linenos">2182</span></a> <span class="k">def</span> <span class="nf">jsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">JSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.jsoncolumndef_sql-2183"><a href="#Generator.jsoncolumndef_sql-2183"><span class="linenos">2183</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.jsoncolumndef_sql-2184"><a href="#Generator.jsoncolumndef_sql-2184"><span class="linenos">2184</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.jsoncolumndef_sql-2185"><a href="#Generator.jsoncolumndef_sql-2185"><span class="linenos">2185</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsoncolumndef_sql-2186"><a href="#Generator.jsoncolumndef_sql-2186"><span class="linenos">2186</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator.jsoncolumndef_sql-2187"><a href="#Generator.jsoncolumndef_sql-2187"><span class="linenos">2187</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PATH </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsoncolumndef_sql-2188"><a href="#Generator.jsoncolumndef_sql-2188"><span class="linenos">2188</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.jsoncolumndef_sql-2183"><a href="#Generator.jsoncolumndef_sql-2183"><span class="linenos">2183</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator.jsoncolumndef_sql-2184"><a href="#Generator.jsoncolumndef_sql-2184"><span class="linenos">2184</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" PATH </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsoncolumndef_sql-2185"><a href="#Generator.jsoncolumndef_sql-2185"><span class="linenos">2185</span></a> <span class="n">nested_schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"nested_schema"</span><span class="p">)</span> +</span><span id="Generator.jsoncolumndef_sql-2186"><a href="#Generator.jsoncolumndef_sql-2186"><span class="linenos">2186</span></a> +</span><span id="Generator.jsoncolumndef_sql-2187"><a href="#Generator.jsoncolumndef_sql-2187"><span class="linenos">2187</span></a> <span class="k">if</span> <span class="n">nested_schema</span><span class="p">:</span> +</span><span id="Generator.jsoncolumndef_sql-2188"><a href="#Generator.jsoncolumndef_sql-2188"><span class="linenos">2188</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NESTED</span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">nested_schema</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.jsoncolumndef_sql-2189"><a href="#Generator.jsoncolumndef_sql-2189"><span class="linenos">2189</span></a> +</span><span id="Generator.jsoncolumndef_sql-2190"><a href="#Generator.jsoncolumndef_sql-2190"><span class="linenos">2190</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.jsoncolumndef_sql-2191"><a href="#Generator.jsoncolumndef_sql-2191"><span class="linenos">2191</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.jsoncolumndef_sql-2192"><a href="#Generator.jsoncolumndef_sql-2192"><span class="linenos">2192</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsoncolumndef_sql-2193"><a href="#Generator.jsoncolumndef_sql-2193"><span class="linenos">2193</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> +</span></pre></div> + + + + + </div> + <div id="Generator.jsonschema_sql" class="classattr"> + <input id="Generator.jsonschema_sql-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1"> +<div class="attr function"> + + <span class="def">def</span> + <span class="name">jsonschema_sql</span><span class="signature pdoc-code condensed">(<span class="param"><span class="bp">self</span>, </span><span class="param"><span class="n">expression</span><span class="p">:</span> <span class="n"><a href="expressions.html#JSONSchema">sqlglot.expressions.JSONSchema</a></span></span><span class="return-annotation">) -> <span class="nb">str</span>:</span></span> + + <label class="view-source-button" for="Generator.jsonschema_sql-view-source"><span>View Source</span></label> + + </div> + <a class="headerlink" href="#Generator.jsonschema_sql"></a> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsonschema_sql-2195"><a href="#Generator.jsonschema_sql-2195"><span class="linenos">2195</span></a> <span class="k">def</span> <span class="nf">jsonschema_sql</span><span class="p">(</span><span class="bp">self</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">JSONSchema</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.jsonschema_sql-2196"><a href="#Generator.jsonschema_sql-2196"><span class="linenos">2196</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"COLUMNS"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> </span></pre></div> @@ -12423,18 +12466,18 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.jsontable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsontable_sql-2190"><a href="#Generator.jsontable_sql-2190"><span class="linenos">2190</span></a> <span class="k">def</span> <span class="nf">jsontable_sql</span><span class="p">(</span><span class="bp">self</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">JSONTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.jsontable_sql-2191"><a href="#Generator.jsontable_sql-2191"><span class="linenos">2191</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.jsontable_sql-2192"><a href="#Generator.jsontable_sql-2192"><span class="linenos">2192</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator.jsontable_sql-2193"><a href="#Generator.jsontable_sql-2193"><span class="linenos">2193</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsontable_sql-2194"><a href="#Generator.jsontable_sql-2194"><span class="linenos">2194</span></a> <span class="n">error_handling</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">"error_handling"</span><span class="p">)</span> -</span><span id="Generator.jsontable_sql-2195"><a href="#Generator.jsontable_sql-2195"><span class="linenos">2195</span></a> <span class="n">error_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">error_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">error_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsontable_sql-2196"><a href="#Generator.jsontable_sql-2196"><span class="linenos">2196</span></a> <span class="n">empty_handling</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">"empty_handling"</span><span class="p">)</span> -</span><span id="Generator.jsontable_sql-2197"><a href="#Generator.jsontable_sql-2197"><span class="linenos">2197</span></a> <span class="n">empty_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">empty_handling</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.jsontable_sql-2198"><a href="#Generator.jsontable_sql-2198"><span class="linenos">2198</span></a> <span class="n">columns</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLUMNS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.jsontable_sql-2199"><a href="#Generator.jsontable_sql-2199"><span class="linenos">2199</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> -</span><span id="Generator.jsontable_sql-2200"><a href="#Generator.jsontable_sql-2200"><span class="linenos">2200</span></a> <span class="s2">"JSON_TABLE"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">path</span><span class="si">}{</span><span class="n">error_handling</span><span class="si">}{</span><span class="n">empty_handling</span><span class="si">}{</span><span class="n">columns</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.jsontable_sql-2201"><a href="#Generator.jsontable_sql-2201"><span class="linenos">2201</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.jsontable_sql-2198"><a href="#Generator.jsontable_sql-2198"><span class="linenos">2198</span></a> <span class="k">def</span> <span class="nf">jsontable_sql</span><span class="p">(</span><span class="bp">self</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">JSONTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.jsontable_sql-2199"><a href="#Generator.jsontable_sql-2199"><span class="linenos">2199</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.jsontable_sql-2200"><a href="#Generator.jsontable_sql-2200"><span class="linenos">2200</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator.jsontable_sql-2201"><a href="#Generator.jsontable_sql-2201"><span class="linenos">2201</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsontable_sql-2202"><a href="#Generator.jsontable_sql-2202"><span class="linenos">2202</span></a> <span class="n">error_handling</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">"error_handling"</span><span class="p">)</span> +</span><span id="Generator.jsontable_sql-2203"><a href="#Generator.jsontable_sql-2203"><span class="linenos">2203</span></a> <span class="n">error_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">error_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">error_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsontable_sql-2204"><a href="#Generator.jsontable_sql-2204"><span class="linenos">2204</span></a> <span class="n">empty_handling</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">"empty_handling"</span><span class="p">)</span> +</span><span id="Generator.jsontable_sql-2205"><a href="#Generator.jsontable_sql-2205"><span class="linenos">2205</span></a> <span class="n">empty_handling</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">empty_handling</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.jsontable_sql-2206"><a href="#Generator.jsontable_sql-2206"><span class="linenos">2206</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="Generator.jsontable_sql-2207"><a href="#Generator.jsontable_sql-2207"><span class="linenos">2207</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span> +</span><span id="Generator.jsontable_sql-2208"><a href="#Generator.jsontable_sql-2208"><span class="linenos">2208</span></a> <span class="s2">"JSON_TABLE"</span><span class="p">,</span> <span class="n">this</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">path</span><span class="si">}{</span><span class="n">error_handling</span><span class="si">}{</span><span class="n">empty_handling</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.jsontable_sql-2209"><a href="#Generator.jsontable_sql-2209"><span class="linenos">2209</span></a> <span class="p">)</span> </span></pre></div> @@ -12452,13 +12495,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.openjsoncolumndef_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjsoncolumndef_sql-2203"><a href="#Generator.openjsoncolumndef_sql-2203"><span class="linenos">2203</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.openjsoncolumndef_sql-2204"><a href="#Generator.openjsoncolumndef_sql-2204"><span class="linenos">2204</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.openjsoncolumndef_sql-2205"><a href="#Generator.openjsoncolumndef_sql-2205"><span class="linenos">2205</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.openjsoncolumndef_sql-2206"><a href="#Generator.openjsoncolumndef_sql-2206"><span class="linenos">2206</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator.openjsoncolumndef_sql-2207"><a href="#Generator.openjsoncolumndef_sql-2207"><span class="linenos">2207</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjsoncolumndef_sql-2208"><a href="#Generator.openjsoncolumndef_sql-2208"><span class="linenos">2208</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</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">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjsoncolumndef_sql-2209"><a href="#Generator.openjsoncolumndef_sql-2209"><span class="linenos">2209</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjsoncolumndef_sql-2211"><a href="#Generator.openjsoncolumndef_sql-2211"><span class="linenos">2211</span></a> <span class="k">def</span> <span class="nf">openjsoncolumndef_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSONColumnDef</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.openjsoncolumndef_sql-2212"><a href="#Generator.openjsoncolumndef_sql-2212"><span class="linenos">2212</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.openjsoncolumndef_sql-2213"><a href="#Generator.openjsoncolumndef_sql-2213"><span class="linenos">2213</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.openjsoncolumndef_sql-2214"><a href="#Generator.openjsoncolumndef_sql-2214"><span class="linenos">2214</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator.openjsoncolumndef_sql-2215"><a href="#Generator.openjsoncolumndef_sql-2215"><span class="linenos">2215</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjsoncolumndef_sql-2216"><a href="#Generator.openjsoncolumndef_sql-2216"><span class="linenos">2216</span></a> <span class="n">as_json</span> <span class="o">=</span> <span class="s2">" AS JSON"</span> <span class="k">if</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">"as_json"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjsoncolumndef_sql-2217"><a href="#Generator.openjsoncolumndef_sql-2217"><span class="linenos">2217</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">path</span><span class="si">}{</span><span class="n">as_json</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12476,17 +12519,17 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.openjson_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjson_sql-2211"><a href="#Generator.openjson_sql-2211"><span class="linenos">2211</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.openjson_sql-2212"><a href="#Generator.openjson_sql-2212"><span class="linenos">2212</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.openjson_sql-2213"><a href="#Generator.openjson_sql-2213"><span class="linenos">2213</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> -</span><span id="Generator.openjson_sql-2214"><a href="#Generator.openjson_sql-2214"><span class="linenos">2214</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjson_sql-2215"><a href="#Generator.openjson_sql-2215"><span class="linenos">2215</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.openjson_sql-2216"><a href="#Generator.openjson_sql-2216"><span class="linenos">2216</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.openjson_sql-2217"><a href="#Generator.openjson_sql-2217"><span class="linenos">2217</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.openjson_sql-2218"><a href="#Generator.openjson_sql-2218"><span class="linenos">2218</span></a> <span class="k">if</span> <span class="n">expressions</span> -</span><span id="Generator.openjson_sql-2219"><a href="#Generator.openjson_sql-2219"><span class="linenos">2219</span></a> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.openjson_sql-2220"><a href="#Generator.openjson_sql-2220"><span class="linenos">2220</span></a> <span class="p">)</span> -</span><span id="Generator.openjson_sql-2221"><a href="#Generator.openjson_sql-2221"><span class="linenos">2221</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.openjson_sql-2219"><a href="#Generator.openjson_sql-2219"><span class="linenos">2219</span></a> <span class="k">def</span> <span class="nf">openjson_sql</span><span class="p">(</span><span class="bp">self</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">OpenJSON</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.openjson_sql-2220"><a href="#Generator.openjson_sql-2220"><span class="linenos">2220</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.openjson_sql-2221"><a href="#Generator.openjson_sql-2221"><span class="linenos">2221</span></a> <span class="n">path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"path"</span><span class="p">)</span> +</span><span id="Generator.openjson_sql-2222"><a href="#Generator.openjson_sql-2222"><span class="linenos">2222</span></a> <span class="n">path</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">", </span><span class="si">{</span><span class="n">path</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">path</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjson_sql-2223"><a href="#Generator.openjson_sql-2223"><span class="linenos">2223</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.openjson_sql-2224"><a href="#Generator.openjson_sql-2224"><span class="linenos">2224</span></a> <span class="n">with_</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.openjson_sql-2225"><a href="#Generator.openjson_sql-2225"><span class="linenos">2225</span></a> <span class="sa">f</span><span class="s2">" WITH (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">expressions</span><span class="p">),</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.openjson_sql-2226"><a href="#Generator.openjson_sql-2226"><span class="linenos">2226</span></a> <span class="k">if</span> <span class="n">expressions</span> +</span><span id="Generator.openjson_sql-2227"><a href="#Generator.openjson_sql-2227"><span class="linenos">2227</span></a> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.openjson_sql-2228"><a href="#Generator.openjson_sql-2228"><span class="linenos">2228</span></a> <span class="p">)</span> +</span><span id="Generator.openjson_sql-2229"><a href="#Generator.openjson_sql-2229"><span class="linenos">2229</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"OPENJSON(</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">path</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">with_</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12504,22 +12547,22 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.in_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_sql-2223"><a href="#Generator.in_sql-2223"><span class="linenos">2223</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</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">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.in_sql-2224"><a href="#Generator.in_sql-2224"><span class="linenos">2224</span></a> <span class="n">query</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">"query"</span><span class="p">)</span> -</span><span id="Generator.in_sql-2225"><a href="#Generator.in_sql-2225"><span class="linenos">2225</span></a> <span class="n">unnest</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">"unnest"</span><span class="p">)</span> -</span><span id="Generator.in_sql-2226"><a href="#Generator.in_sql-2226"><span class="linenos">2226</span></a> <span class="n">field</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">"field"</span><span class="p">)</span> -</span><span id="Generator.in_sql-2227"><a href="#Generator.in_sql-2227"><span class="linenos">2227</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</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">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.in_sql-2228"><a href="#Generator.in_sql-2228"><span class="linenos">2228</span></a> -</span><span id="Generator.in_sql-2229"><a href="#Generator.in_sql-2229"><span class="linenos">2229</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> -</span><span id="Generator.in_sql-2230"><a href="#Generator.in_sql-2230"><span class="linenos">2230</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> -</span><span id="Generator.in_sql-2231"><a href="#Generator.in_sql-2231"><span class="linenos">2231</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> -</span><span id="Generator.in_sql-2232"><a href="#Generator.in_sql-2232"><span class="linenos">2232</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> -</span><span id="Generator.in_sql-2233"><a href="#Generator.in_sql-2233"><span class="linenos">2233</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> -</span><span id="Generator.in_sql-2234"><a href="#Generator.in_sql-2234"><span class="linenos">2234</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> -</span><span id="Generator.in_sql-2235"><a href="#Generator.in_sql-2235"><span class="linenos">2235</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.in_sql-2236"><a href="#Generator.in_sql-2236"><span class="linenos">2236</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.in_sql-2237"><a href="#Generator.in_sql-2237"><span class="linenos">2237</span></a> -</span><span id="Generator.in_sql-2238"><a href="#Generator.in_sql-2238"><span class="linenos">2238</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_sql-2231"><a href="#Generator.in_sql-2231"><span class="linenos">2231</span></a> <span class="k">def</span> <span class="nf">in_sql</span><span class="p">(</span><span class="bp">self</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">In</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.in_sql-2232"><a href="#Generator.in_sql-2232"><span class="linenos">2232</span></a> <span class="n">query</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">"query"</span><span class="p">)</span> +</span><span id="Generator.in_sql-2233"><a href="#Generator.in_sql-2233"><span class="linenos">2233</span></a> <span class="n">unnest</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">"unnest"</span><span class="p">)</span> +</span><span id="Generator.in_sql-2234"><a href="#Generator.in_sql-2234"><span class="linenos">2234</span></a> <span class="n">field</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">"field"</span><span class="p">)</span> +</span><span id="Generator.in_sql-2235"><a href="#Generator.in_sql-2235"><span class="linenos">2235</span></a> <span class="n">is_global</span> <span class="o">=</span> <span class="s2">" GLOBAL"</span> <span class="k">if</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">"is_global"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.in_sql-2236"><a href="#Generator.in_sql-2236"><span class="linenos">2236</span></a> +</span><span id="Generator.in_sql-2237"><a href="#Generator.in_sql-2237"><span class="linenos">2237</span></a> <span class="k">if</span> <span class="n">query</span><span class="p">:</span> +</span><span id="Generator.in_sql-2238"><a href="#Generator.in_sql-2238"><span class="linenos">2238</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">query</span><span class="p">)</span> +</span><span id="Generator.in_sql-2239"><a href="#Generator.in_sql-2239"><span class="linenos">2239</span></a> <span class="k">elif</span> <span class="n">unnest</span><span class="p">:</span> +</span><span id="Generator.in_sql-2240"><a href="#Generator.in_sql-2240"><span class="linenos">2240</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">in_unnest_op</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span> +</span><span id="Generator.in_sql-2241"><a href="#Generator.in_sql-2241"><span class="linenos">2241</span></a> <span class="k">elif</span> <span class="n">field</span><span class="p">:</span> +</span><span id="Generator.in_sql-2242"><a href="#Generator.in_sql-2242"><span class="linenos">2242</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">field</span><span class="p">)</span> +</span><span id="Generator.in_sql-2243"><a href="#Generator.in_sql-2243"><span class="linenos">2243</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.in_sql-2244"><a href="#Generator.in_sql-2244"><span class="linenos">2244</span></a> <span class="n">in_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.in_sql-2245"><a href="#Generator.in_sql-2245"><span class="linenos">2245</span></a> +</span><span id="Generator.in_sql-2246"><a href="#Generator.in_sql-2246"><span class="linenos">2246</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">is_global</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">in_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12537,8 +12580,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.in_unnest_op"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_unnest_op-2240"><a href="#Generator.in_unnest_op-2240"><span class="linenos">2240</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.in_unnest_op-2241"><a href="#Generator.in_unnest_op-2241"><span class="linenos">2241</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.in_unnest_op-2248"><a href="#Generator.in_unnest_op-2248"><span class="linenos">2248</span></a> <span class="k">def</span> <span class="nf">in_unnest_op</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">unnest</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">Unnest</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.in_unnest_op-2249"><a href="#Generator.in_unnest_op-2249"><span class="linenos">2249</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"(SELECT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">unnest</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -12556,22 +12599,22 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.interval_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.interval_sql-2243"><a href="#Generator.interval_sql-2243"><span class="linenos">2243</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.interval_sql-2244"><a href="#Generator.interval_sql-2244"><span class="linenos">2244</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> -</span><span id="Generator.interval_sql-2245"><a href="#Generator.interval_sql-2245"><span class="linenos">2245</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> -</span><span id="Generator.interval_sql-2246"><a href="#Generator.interval_sql-2246"><span class="linenos">2246</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> -</span><span id="Generator.interval_sql-2247"><a href="#Generator.interval_sql-2247"><span class="linenos">2247</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.interval_sql-2248"><a href="#Generator.interval_sql-2248"><span class="linenos">2248</span></a> -</span><span id="Generator.interval_sql-2249"><a href="#Generator.interval_sql-2249"><span class="linenos">2249</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> -</span><span id="Generator.interval_sql-2250"><a href="#Generator.interval_sql-2250"><span class="linenos">2250</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.interval_sql-2251"><a href="#Generator.interval_sql-2251"><span class="linenos">2251</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.interval_sql-2252"><a href="#Generator.interval_sql-2252"><span class="linenos">2252</span></a> -</span><span id="Generator.interval_sql-2253"><a href="#Generator.interval_sql-2253"><span class="linenos">2253</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.interval_sql-2254"><a href="#Generator.interval_sql-2254"><span class="linenos">2254</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> -</span><span id="Generator.interval_sql-2255"><a href="#Generator.interval_sql-2255"><span class="linenos">2255</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> -</span><span id="Generator.interval_sql-2256"><a href="#Generator.interval_sql-2256"><span class="linenos">2256</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> -</span><span id="Generator.interval_sql-2257"><a href="#Generator.interval_sql-2257"><span class="linenos">2257</span></a> -</span><span id="Generator.interval_sql-2258"><a href="#Generator.interval_sql-2258"><span class="linenos">2258</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.interval_sql-2251"><a href="#Generator.interval_sql-2251"><span class="linenos">2251</span></a> <span class="k">def</span> <span class="nf">interval_sql</span><span class="p">(</span><span class="bp">self</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">Interval</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.interval_sql-2252"><a href="#Generator.interval_sql-2252"><span class="linenos">2252</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"unit"</span><span class="p">)</span> +</span><span id="Generator.interval_sql-2253"><a href="#Generator.interval_sql-2253"><span class="linenos">2253</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">INTERVAL_ALLOWS_PLURAL_FORM</span><span class="p">:</span> +</span><span id="Generator.interval_sql-2254"><a href="#Generator.interval_sql-2254"><span class="linenos">2254</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TIME_PART_SINGULARS</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">unit</span><span class="o">.</span><span class="n">lower</span><span class="p">(),</span> <span class="n">unit</span><span class="p">)</span> +</span><span id="Generator.interval_sql-2255"><a href="#Generator.interval_sql-2255"><span class="linenos">2255</span></a> <span class="n">unit</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unit</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.interval_sql-2256"><a href="#Generator.interval_sql-2256"><span class="linenos">2256</span></a> +</span><span id="Generator.interval_sql-2257"><a href="#Generator.interval_sql-2257"><span class="linenos">2257</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">SINGLE_STRING_INTERVAL</span><span class="p">:</span> +</span><span id="Generator.interval_sql-2258"><a href="#Generator.interval_sql-2258"><span class="linenos">2258</span></a> <span class="n">this</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">name</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.interval_sql-2259"><a href="#Generator.interval_sql-2259"><span class="linenos">2259</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL '</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">'"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.interval_sql-2260"><a href="#Generator.interval_sql-2260"><span class="linenos">2260</span></a> +</span><span id="Generator.interval_sql-2261"><a href="#Generator.interval_sql-2261"><span class="linenos">2261</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.interval_sql-2262"><a href="#Generator.interval_sql-2262"><span class="linenos">2262</span></a> <span class="k">if</span> <span class="n">this</span><span class="p">:</span> +</span><span id="Generator.interval_sql-2263"><a href="#Generator.interval_sql-2263"><span class="linenos">2263</span></a> <span class="n">unwrapped</span> <span class="o">=</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UNWRAPPED_INTERVAL_VALUES</span><span class="p">)</span> +</span><span id="Generator.interval_sql-2264"><a href="#Generator.interval_sql-2264"><span class="linenos">2264</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">unwrapped</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" (</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">)"</span> +</span><span id="Generator.interval_sql-2265"><a href="#Generator.interval_sql-2265"><span class="linenos">2265</span></a> +</span><span id="Generator.interval_sql-2266"><a href="#Generator.interval_sql-2266"><span class="linenos">2266</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"INTERVAL</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">unit</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12589,8 +12632,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.return_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.return_sql-2260"><a href="#Generator.return_sql-2260"><span class="linenos">2260</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</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">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.return_sql-2261"><a href="#Generator.return_sql-2261"><span class="linenos">2261</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.return_sql-2268"><a href="#Generator.return_sql-2268"><span class="linenos">2268</span></a> <span class="k">def</span> <span class="nf">return_sql</span><span class="p">(</span><span class="bp">self</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">Return</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.return_sql-2269"><a href="#Generator.return_sql-2269"><span class="linenos">2269</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RETURN </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12608,13 +12651,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.reference_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.reference_sql-2263"><a href="#Generator.reference_sql-2263"><span class="linenos">2263</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</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">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.reference_sql-2264"><a href="#Generator.reference_sql-2264"><span class="linenos">2264</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.reference_sql-2265"><a href="#Generator.reference_sql-2265"><span class="linenos">2265</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.reference_sql-2266"><a href="#Generator.reference_sql-2266"><span class="linenos">2266</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.reference_sql-2267"><a href="#Generator.reference_sql-2267"><span class="linenos">2267</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.reference_sql-2268"><a href="#Generator.reference_sql-2268"><span class="linenos">2268</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.reference_sql-2269"><a href="#Generator.reference_sql-2269"><span class="linenos">2269</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.reference_sql-2271"><a href="#Generator.reference_sql-2271"><span class="linenos">2271</span></a> <span class="k">def</span> <span class="nf">reference_sql</span><span class="p">(</span><span class="bp">self</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">Reference</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.reference_sql-2272"><a href="#Generator.reference_sql-2272"><span class="linenos">2272</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.reference_sql-2273"><a href="#Generator.reference_sql-2273"><span class="linenos">2273</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.reference_sql-2274"><a href="#Generator.reference_sql-2274"><span class="linenos">2274</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">expressions</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.reference_sql-2275"><a href="#Generator.reference_sql-2275"><span class="linenos">2275</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.reference_sql-2276"><a href="#Generator.reference_sql-2276"><span class="linenos">2276</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.reference_sql-2277"><a href="#Generator.reference_sql-2277"><span class="linenos">2277</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"REFERENCES </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12632,8 +12675,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.anonymous_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.anonymous_sql-2271"><a href="#Generator.anonymous_sql-2271"><span class="linenos">2271</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</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">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.anonymous_sql-2272"><a href="#Generator.anonymous_sql-2272"><span class="linenos">2272</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.anonymous_sql-2279"><a href="#Generator.anonymous_sql-2279"><span class="linenos">2279</span></a> <span class="k">def</span> <span class="nf">anonymous_sql</span><span class="p">(</span><span class="bp">self</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">Anonymous</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.anonymous_sql-2280"><a href="#Generator.anonymous_sql-2280"><span class="linenos">2280</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> </span></pre></div> @@ -12651,14 +12694,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.paren_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.paren_sql-2274"><a href="#Generator.paren_sql-2274"><span class="linenos">2274</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</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">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.paren_sql-2275"><a href="#Generator.paren_sql-2275"><span class="linenos">2275</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</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="Generator.paren_sql-2276"><a href="#Generator.paren_sql-2276"><span class="linenos">2276</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.paren_sql-2277"><a href="#Generator.paren_sql-2277"><span class="linenos">2277</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.paren_sql-2278"><a href="#Generator.paren_sql-2278"><span class="linenos">2278</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> -</span><span id="Generator.paren_sql-2279"><a href="#Generator.paren_sql-2279"><span class="linenos">2279</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.paren_sql-2280"><a href="#Generator.paren_sql-2280"><span class="linenos">2280</span></a> -</span><span id="Generator.paren_sql-2281"><a href="#Generator.paren_sql-2281"><span class="linenos">2281</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.paren_sql-2282"><a href="#Generator.paren_sql-2282"><span class="linenos">2282</span></a> <span class="k">def</span> <span class="nf">paren_sql</span><span class="p">(</span><span class="bp">self</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">Paren</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.paren_sql-2283"><a href="#Generator.paren_sql-2283"><span class="linenos">2283</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">unnest</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="Generator.paren_sql-2284"><a href="#Generator.paren_sql-2284"><span class="linenos">2284</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.paren_sql-2285"><a href="#Generator.paren_sql-2285"><span class="linenos">2285</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.paren_sql-2286"><a href="#Generator.paren_sql-2286"><span class="linenos">2286</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)),</span> <span class="n">sep</span><span class="o">=</span><span class="s2">""</span><span class="p">)</span> +</span><span id="Generator.paren_sql-2287"><a href="#Generator.paren_sql-2287"><span class="linenos">2287</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="n">sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.paren_sql-2288"><a href="#Generator.paren_sql-2288"><span class="linenos">2288</span></a> +</span><span id="Generator.paren_sql-2289"><a href="#Generator.paren_sql-2289"><span class="linenos">2289</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prepend_ctes</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sql</span><span class="p">)</span> </span></pre></div> @@ -12676,11 +12719,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.neg_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neg_sql-2283"><a href="#Generator.neg_sql-2283"><span class="linenos">2283</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</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">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.neg_sql-2284"><a href="#Generator.neg_sql-2284"><span class="linenos">2284</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> -</span><span id="Generator.neg_sql-2285"><a href="#Generator.neg_sql-2285"><span class="linenos">2285</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.neg_sql-2286"><a href="#Generator.neg_sql-2286"><span class="linenos">2286</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.neg_sql-2287"><a href="#Generator.neg_sql-2287"><span class="linenos">2287</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neg_sql-2291"><a href="#Generator.neg_sql-2291"><span class="linenos">2291</span></a> <span class="k">def</span> <span class="nf">neg_sql</span><span class="p">(</span><span class="bp">self</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">Neg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.neg_sql-2292"><a href="#Generator.neg_sql-2292"><span class="linenos">2292</span></a> <span class="c1"># This makes sure we don't convert "- - 5" to "--5", which is a comment</span> +</span><span id="Generator.neg_sql-2293"><a href="#Generator.neg_sql-2293"><span class="linenos">2293</span></a> <span class="n">this_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.neg_sql-2294"><a href="#Generator.neg_sql-2294"><span class="linenos">2294</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">" "</span> <span class="k">if</span> <span class="n">this_sql</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"-"</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.neg_sql-2295"><a href="#Generator.neg_sql-2295"><span class="linenos">2295</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"-</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">this_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12698,8 +12741,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.not_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.not_sql-2289"><a href="#Generator.not_sql-2289"><span class="linenos">2289</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</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">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.not_sql-2290"><a href="#Generator.not_sql-2290"><span class="linenos">2290</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.not_sql-2297"><a href="#Generator.not_sql-2297"><span class="linenos">2297</span></a> <span class="k">def</span> <span class="nf">not_sql</span><span class="p">(</span><span class="bp">self</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">Not</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.not_sql-2298"><a href="#Generator.not_sql-2298"><span class="linenos">2298</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"NOT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12717,10 +12760,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.alias_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.alias_sql-2292"><a href="#Generator.alias_sql-2292"><span class="linenos">2292</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</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">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.alias_sql-2293"><a href="#Generator.alias_sql-2293"><span class="linenos">2293</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> -</span><span id="Generator.alias_sql-2294"><a href="#Generator.alias_sql-2294"><span class="linenos">2294</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.alias_sql-2295"><a href="#Generator.alias_sql-2295"><span class="linenos">2295</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.alias_sql-2300"><a href="#Generator.alias_sql-2300"><span class="linenos">2300</span></a> <span class="k">def</span> <span class="nf">alias_sql</span><span class="p">(</span><span class="bp">self</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">Alias</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.alias_sql-2301"><a href="#Generator.alias_sql-2301"><span class="linenos">2301</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"alias"</span><span class="p">)</span> +</span><span id="Generator.alias_sql-2302"><a href="#Generator.alias_sql-2302"><span class="linenos">2302</span></a> <span class="n">alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">alias</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.alias_sql-2303"><a href="#Generator.alias_sql-2303"><span class="linenos">2303</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}{</span><span class="n">alias</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12738,8 +12781,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.aliases_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.aliases_sql-2297"><a href="#Generator.aliases_sql-2297"><span class="linenos">2297</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</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">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.aliases_sql-2298"><a href="#Generator.aliases_sql-2298"><span class="linenos">2298</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.aliases_sql-2305"><a href="#Generator.aliases_sql-2305"><span class="linenos">2305</span></a> <span class="k">def</span> <span class="nf">aliases_sql</span><span class="p">(</span><span class="bp">self</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">Aliases</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.aliases_sql-2306"><a href="#Generator.aliases_sql-2306"><span class="linenos">2306</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS (</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -12757,10 +12800,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.attimezone_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.attimezone_sql-2300"><a href="#Generator.attimezone_sql-2300"><span class="linenos">2300</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</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">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.attimezone_sql-2301"><a href="#Generator.attimezone_sql-2301"><span class="linenos">2301</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.attimezone_sql-2302"><a href="#Generator.attimezone_sql-2302"><span class="linenos">2302</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> -</span><span id="Generator.attimezone_sql-2303"><a href="#Generator.attimezone_sql-2303"><span class="linenos">2303</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.attimezone_sql-2308"><a href="#Generator.attimezone_sql-2308"><span class="linenos">2308</span></a> <span class="k">def</span> <span class="nf">attimezone_sql</span><span class="p">(</span><span class="bp">self</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">AtTimeZone</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.attimezone_sql-2309"><a href="#Generator.attimezone_sql-2309"><span class="linenos">2309</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.attimezone_sql-2310"><a href="#Generator.attimezone_sql-2310"><span class="linenos">2310</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"zone"</span><span class="p">)</span> +</span><span id="Generator.attimezone_sql-2311"><a href="#Generator.attimezone_sql-2311"><span class="linenos">2311</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> AT TIME ZONE </span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12778,8 +12821,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.add_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.add_sql-2305"><a href="#Generator.add_sql-2305"><span class="linenos">2305</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</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">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.add_sql-2306"><a href="#Generator.add_sql-2306"><span class="linenos">2306</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.add_sql-2313"><a href="#Generator.add_sql-2313"><span class="linenos">2313</span></a> <span class="k">def</span> <span class="nf">add_sql</span><span class="p">(</span><span class="bp">self</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">Add</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.add_sql-2314"><a href="#Generator.add_sql-2314"><span class="linenos">2314</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"+"</span><span class="p">)</span> </span></pre></div> @@ -12797,8 +12840,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.and_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.and_sql-2308"><a href="#Generator.and_sql-2308"><span class="linenos">2308</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</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">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.and_sql-2309"><a href="#Generator.and_sql-2309"><span class="linenos">2309</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.and_sql-2316"><a href="#Generator.and_sql-2316"><span class="linenos">2316</span></a> <span class="k">def</span> <span class="nf">and_sql</span><span class="p">(</span><span class="bp">self</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">And</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.and_sql-2317"><a href="#Generator.and_sql-2317"><span class="linenos">2317</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"AND"</span><span class="p">)</span> </span></pre></div> @@ -12816,8 +12859,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.xor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.xor_sql-2311"><a href="#Generator.xor_sql-2311"><span class="linenos">2311</span></a> <span class="k">def</span> <span class="nf">xor_sql</span><span class="p">(</span><span class="bp">self</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">Xor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.xor_sql-2312"><a href="#Generator.xor_sql-2312"><span class="linenos">2312</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"XOR"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.xor_sql-2319"><a href="#Generator.xor_sql-2319"><span class="linenos">2319</span></a> <span class="k">def</span> <span class="nf">xor_sql</span><span class="p">(</span><span class="bp">self</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">Xor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.xor_sql-2320"><a href="#Generator.xor_sql-2320"><span class="linenos">2320</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"XOR"</span><span class="p">)</span> </span></pre></div> @@ -12835,17 +12878,17 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.connector_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.connector_sql-2314"><a href="#Generator.connector_sql-2314"><span class="linenos">2314</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</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">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.connector_sql-2315"><a href="#Generator.connector_sql-2315"><span class="linenos">2315</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator.connector_sql-2316"><a href="#Generator.connector_sql-2316"><span class="linenos">2316</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> -</span><span id="Generator.connector_sql-2317"><a href="#Generator.connector_sql-2317"><span class="linenos">2317</span></a> -</span><span id="Generator.connector_sql-2318"><a href="#Generator.connector_sql-2318"><span class="linenos">2318</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> -</span><span id="Generator.connector_sql-2319"><a href="#Generator.connector_sql-2319"><span class="linenos">2319</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> -</span><span id="Generator.connector_sql-2320"><a href="#Generator.connector_sql-2320"><span class="linenos">2320</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> -</span><span id="Generator.connector_sql-2321"><a href="#Generator.connector_sql-2321"><span class="linenos">2321</span></a> <span class="p">)</span> -</span><span id="Generator.connector_sql-2322"><a href="#Generator.connector_sql-2322"><span class="linenos">2322</span></a> -</span><span id="Generator.connector_sql-2323"><a href="#Generator.connector_sql-2323"><span class="linenos">2323</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.connector_sql-2324"><a href="#Generator.connector_sql-2324"><span class="linenos">2324</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.connector_sql-2322"><a href="#Generator.connector_sql-2322"><span class="linenos">2322</span></a> <span class="k">def</span> <span class="nf">connector_sql</span><span class="p">(</span><span class="bp">self</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">Connector</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.connector_sql-2323"><a href="#Generator.connector_sql-2323"><span class="linenos">2323</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator.connector_sql-2324"><a href="#Generator.connector_sql-2324"><span class="linenos">2324</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">op</span><span class="p">)</span> +</span><span id="Generator.connector_sql-2325"><a href="#Generator.connector_sql-2325"><span class="linenos">2325</span></a> +</span><span id="Generator.connector_sql-2326"><a href="#Generator.connector_sql-2326"><span class="linenos">2326</span></a> <span class="n">sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span> +</span><span id="Generator.connector_sql-2327"><a href="#Generator.connector_sql-2327"><span class="linenos">2327</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">),</span> <span class="n">e</span><span class="p">,</span> <span class="n">e</span><span class="o">.</span><span class="n">parent</span><span class="o">.</span><span class="n">comments</span> <span class="ow">or</span> <span class="p">[])</span> <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">1</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> +</span><span id="Generator.connector_sql-2328"><a href="#Generator.connector_sql-2328"><span class="linenos">2328</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">(</span><span class="n">unnest</span><span class="o">=</span><span class="kc">False</span><span class="p">))</span> +</span><span id="Generator.connector_sql-2329"><a href="#Generator.connector_sql-2329"><span class="linenos">2329</span></a> <span class="p">)</span> +</span><span id="Generator.connector_sql-2330"><a href="#Generator.connector_sql-2330"><span class="linenos">2330</span></a> +</span><span id="Generator.connector_sql-2331"><a href="#Generator.connector_sql-2331"><span class="linenos">2331</span></a> <span class="n">sep</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.connector_sql-2332"><a href="#Generator.connector_sql-2332"><span class="linenos">2332</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="si">}{</span><span class="n">op</span><span class="si">}</span><span class="s2"> "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sqls</span><span class="p">)</span> </span></pre></div> @@ -12863,8 +12906,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwiseand_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseand_sql-2326"><a href="#Generator.bitwiseand_sql-2326"><span class="linenos">2326</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwiseand_sql-2327"><a href="#Generator.bitwiseand_sql-2327"><span class="linenos">2327</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseand_sql-2334"><a href="#Generator.bitwiseand_sql-2334"><span class="linenos">2334</span></a> <span class="k">def</span> <span class="nf">bitwiseand_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseAnd</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwiseand_sql-2335"><a href="#Generator.bitwiseand_sql-2335"><span class="linenos">2335</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"&"</span><span class="p">)</span> </span></pre></div> @@ -12882,8 +12925,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwiseleftshift_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseleftshift_sql-2329"><a href="#Generator.bitwiseleftshift_sql-2329"><span class="linenos">2329</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwiseleftshift_sql-2330"><a href="#Generator.bitwiseleftshift_sql-2330"><span class="linenos">2330</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseleftshift_sql-2337"><a href="#Generator.bitwiseleftshift_sql-2337"><span class="linenos">2337</span></a> <span class="k">def</span> <span class="nf">bitwiseleftshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseLeftShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwiseleftshift_sql-2338"><a href="#Generator.bitwiseleftshift_sql-2338"><span class="linenos">2338</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<<"</span><span class="p">)</span> </span></pre></div> @@ -12901,8 +12944,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwisenot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisenot_sql-2332"><a href="#Generator.bitwisenot_sql-2332"><span class="linenos">2332</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwisenot_sql-2333"><a href="#Generator.bitwisenot_sql-2333"><span class="linenos">2333</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisenot_sql-2340"><a href="#Generator.bitwisenot_sql-2340"><span class="linenos">2340</span></a> <span class="k">def</span> <span class="nf">bitwisenot_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseNot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwisenot_sql-2341"><a href="#Generator.bitwisenot_sql-2341"><span class="linenos">2341</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"~</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -12920,8 +12963,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwiseor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseor_sql-2335"><a href="#Generator.bitwiseor_sql-2335"><span class="linenos">2335</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwiseor_sql-2336"><a href="#Generator.bitwiseor_sql-2336"><span class="linenos">2336</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiseor_sql-2343"><a href="#Generator.bitwiseor_sql-2343"><span class="linenos">2343</span></a> <span class="k">def</span> <span class="nf">bitwiseor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseOr</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwiseor_sql-2344"><a href="#Generator.bitwiseor_sql-2344"><span class="linenos">2344</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"|"</span><span class="p">)</span> </span></pre></div> @@ -12939,8 +12982,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwiserightshift_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiserightshift_sql-2338"><a href="#Generator.bitwiserightshift_sql-2338"><span class="linenos">2338</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwiserightshift_sql-2339"><a href="#Generator.bitwiserightshift_sql-2339"><span class="linenos">2339</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwiserightshift_sql-2346"><a href="#Generator.bitwiserightshift_sql-2346"><span class="linenos">2346</span></a> <span class="k">def</span> <span class="nf">bitwiserightshift_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseRightShift</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwiserightshift_sql-2347"><a href="#Generator.bitwiserightshift_sql-2347"><span class="linenos">2347</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">>"</span><span class="p">)</span> </span></pre></div> @@ -12958,8 +13001,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.bitwisexor_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisexor_sql-2341"><a href="#Generator.bitwisexor_sql-2341"><span class="linenos">2341</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.bitwisexor_sql-2342"><a href="#Generator.bitwisexor_sql-2342"><span class="linenos">2342</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.bitwisexor_sql-2349"><a href="#Generator.bitwisexor_sql-2349"><span class="linenos">2349</span></a> <span class="k">def</span> <span class="nf">bitwisexor_sql</span><span class="p">(</span><span class="bp">self</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">BitwiseXor</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.bitwisexor_sql-2350"><a href="#Generator.bitwisexor_sql-2350"><span class="linenos">2350</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"^"</span><span class="p">)</span> </span></pre></div> @@ -12977,10 +13020,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.cast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cast_sql-2344"><a href="#Generator.cast_sql-2344"><span class="linenos">2344</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</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">Cast</span><span class="p">,</span> <span class="n">safe_prefix</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.cast_sql-2345"><a href="#Generator.cast_sql-2345"><span class="linenos">2345</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">)</span> -</span><span id="Generator.cast_sql-2346"><a href="#Generator.cast_sql-2346"><span class="linenos">2346</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FORMAT </span><span class="si">{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">format_sql</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.cast_sql-2347"><a href="#Generator.cast_sql-2347"><span class="linenos">2347</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">safe_prefix</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.cast_sql-2352"><a href="#Generator.cast_sql-2352"><span class="linenos">2352</span></a> <span class="k">def</span> <span class="nf">cast_sql</span><span class="p">(</span><span class="bp">self</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">Cast</span><span class="p">,</span> <span class="n">safe_prefix</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.cast_sql-2353"><a href="#Generator.cast_sql-2353"><span class="linenos">2353</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">)</span> +</span><span id="Generator.cast_sql-2354"><a href="#Generator.cast_sql-2354"><span class="linenos">2354</span></a> <span class="n">format_sql</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" FORMAT </span><span class="si">{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">format_sql</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.cast_sql-2355"><a href="#Generator.cast_sql-2355"><span class="linenos">2355</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">safe_prefix</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">CAST(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'to'</span><span class="p">)</span><span class="si">}{</span><span class="n">format_sql</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -12998,9 +13041,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.currentdate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.currentdate_sql-2349"><a href="#Generator.currentdate_sql-2349"><span class="linenos">2349</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</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">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.currentdate_sql-2350"><a href="#Generator.currentdate_sql-2350"><span class="linenos">2350</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.currentdate_sql-2351"><a href="#Generator.currentdate_sql-2351"><span class="linenos">2351</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.currentdate_sql-2357"><a href="#Generator.currentdate_sql-2357"><span class="linenos">2357</span></a> <span class="k">def</span> <span class="nf">currentdate_sql</span><span class="p">(</span><span class="bp">self</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">CurrentDate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.currentdate_sql-2358"><a href="#Generator.currentdate_sql-2358"><span class="linenos">2358</span></a> <span class="n">zone</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.currentdate_sql-2359"><a href="#Generator.currentdate_sql-2359"><span class="linenos">2359</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CURRENT_DATE(</span><span class="si">{</span><span class="n">zone</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">zone</span> <span class="k">else</span> <span class="s2">"CURRENT_DATE"</span> </span></pre></div> @@ -13018,10 +13061,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.collate_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.collate_sql-2353"><a href="#Generator.collate_sql-2353"><span class="linenos">2353</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</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">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.collate_sql-2354"><a href="#Generator.collate_sql-2354"><span class="linenos">2354</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLLATE_IS_FUNC</span><span class="p">:</span> -</span><span id="Generator.collate_sql-2355"><a href="#Generator.collate_sql-2355"><span class="linenos">2355</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.collate_sql-2356"><a href="#Generator.collate_sql-2356"><span class="linenos">2356</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.collate_sql-2361"><a href="#Generator.collate_sql-2361"><span class="linenos">2361</span></a> <span class="k">def</span> <span class="nf">collate_sql</span><span class="p">(</span><span class="bp">self</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">Collate</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.collate_sql-2362"><a href="#Generator.collate_sql-2362"><span class="linenos">2362</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">COLLATE_IS_FUNC</span><span class="p">:</span> +</span><span id="Generator.collate_sql-2363"><a href="#Generator.collate_sql-2363"><span class="linenos">2363</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.collate_sql-2364"><a href="#Generator.collate_sql-2364"><span class="linenos">2364</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"COLLATE"</span><span class="p">)</span> </span></pre></div> @@ -13039,8 +13082,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.command_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.command_sql-2358"><a href="#Generator.command_sql-2358"><span class="linenos">2358</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</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">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.command_sql-2359"><a href="#Generator.command_sql-2359"><span class="linenos">2359</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.command_sql-2366"><a href="#Generator.command_sql-2366"><span class="linenos">2366</span></a> <span class="k">def</span> <span class="nf">command_sql</span><span class="p">(</span><span class="bp">self</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">Command</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.command_sql-2367"><a href="#Generator.command_sql-2367"><span class="linenos">2367</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="s1">'expression'</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13058,12 +13101,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.comment_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.comment_sql-2361"><a href="#Generator.comment_sql-2361"><span class="linenos">2361</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</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">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.comment_sql-2362"><a href="#Generator.comment_sql-2362"><span class="linenos">2362</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.comment_sql-2363"><a href="#Generator.comment_sql-2363"><span class="linenos">2363</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> -</span><span id="Generator.comment_sql-2364"><a href="#Generator.comment_sql-2364"><span class="linenos">2364</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.comment_sql-2365"><a href="#Generator.comment_sql-2365"><span class="linenos">2365</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.comment_sql-2366"><a href="#Generator.comment_sql-2366"><span class="linenos">2366</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.comment_sql-2369"><a href="#Generator.comment_sql-2369"><span class="linenos">2369</span></a> <span class="k">def</span> <span class="nf">comment_sql</span><span class="p">(</span><span class="bp">self</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">Comment</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.comment_sql-2370"><a href="#Generator.comment_sql-2370"><span class="linenos">2370</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.comment_sql-2371"><a href="#Generator.comment_sql-2371"><span class="linenos">2371</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"kind"</span><span class="p">]</span> +</span><span id="Generator.comment_sql-2372"><a href="#Generator.comment_sql-2372"><span class="linenos">2372</span></a> <span class="n">exists_sql</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.comment_sql-2373"><a href="#Generator.comment_sql-2373"><span class="linenos">2373</span></a> <span class="n">expression_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.comment_sql-2374"><a href="#Generator.comment_sql-2374"><span class="linenos">2374</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT</span><span class="si">{</span><span class="n">exists_sql</span><span class="si">}</span><span class="s2">ON </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> IS </span><span class="si">{</span><span class="n">expression_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13081,16 +13124,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mergetreettlaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettlaction_sql-2368"><a href="#Generator.mergetreettlaction_sql-2368"><span class="linenos">2368</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mergetreettlaction_sql-2369"><a href="#Generator.mergetreettlaction_sql-2369"><span class="linenos">2369</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.mergetreettlaction_sql-2370"><a href="#Generator.mergetreettlaction_sql-2370"><span class="linenos">2370</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</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">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettlaction_sql-2371"><a href="#Generator.mergetreettlaction_sql-2371"><span class="linenos">2371</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> -</span><span id="Generator.mergetreettlaction_sql-2372"><a href="#Generator.mergetreettlaction_sql-2372"><span class="linenos">2372</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettlaction_sql-2373"><a href="#Generator.mergetreettlaction_sql-2373"><span class="linenos">2373</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> -</span><span id="Generator.mergetreettlaction_sql-2374"><a href="#Generator.mergetreettlaction_sql-2374"><span class="linenos">2374</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettlaction_sql-2375"><a href="#Generator.mergetreettlaction_sql-2375"><span class="linenos">2375</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> -</span><span id="Generator.mergetreettlaction_sql-2376"><a href="#Generator.mergetreettlaction_sql-2376"><span class="linenos">2376</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettlaction_sql-2377"><a href="#Generator.mergetreettlaction_sql-2377"><span class="linenos">2377</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettlaction_sql-2376"><a href="#Generator.mergetreettlaction_sql-2376"><span class="linenos">2376</span></a> <span class="k">def</span> <span class="nf">mergetreettlaction_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTLAction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mergetreettlaction_sql-2377"><a href="#Generator.mergetreettlaction_sql-2377"><span class="linenos">2377</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.mergetreettlaction_sql-2378"><a href="#Generator.mergetreettlaction_sql-2378"><span class="linenos">2378</span></a> <span class="n">delete</span> <span class="o">=</span> <span class="s2">" DELETE"</span> <span class="k">if</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">"delete"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettlaction_sql-2379"><a href="#Generator.mergetreettlaction_sql-2379"><span class="linenos">2379</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"recompress"</span><span class="p">)</span> +</span><span id="Generator.mergetreettlaction_sql-2380"><a href="#Generator.mergetreettlaction_sql-2380"><span class="linenos">2380</span></a> <span class="n">recompress</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECOMPRESS </span><span class="si">{</span><span class="n">recompress</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">recompress</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettlaction_sql-2381"><a href="#Generator.mergetreettlaction_sql-2381"><span class="linenos">2381</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_disk"</span><span class="p">)</span> +</span><span id="Generator.mergetreettlaction_sql-2382"><a href="#Generator.mergetreettlaction_sql-2382"><span class="linenos">2382</span></a> <span class="n">to_disk</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO DISK </span><span class="si">{</span><span class="n">to_disk</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_disk</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettlaction_sql-2383"><a href="#Generator.mergetreettlaction_sql-2383"><span class="linenos">2383</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"to_volume"</span><span class="p">)</span> +</span><span id="Generator.mergetreettlaction_sql-2384"><a href="#Generator.mergetreettlaction_sql-2384"><span class="linenos">2384</span></a> <span class="n">to_volume</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO VOLUME </span><span class="si">{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">to_volume</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettlaction_sql-2385"><a href="#Generator.mergetreettlaction_sql-2385"><span class="linenos">2385</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">delete</span><span class="si">}{</span><span class="n">recompress</span><span class="si">}{</span><span class="n">to_disk</span><span class="si">}{</span><span class="n">to_volume</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13108,16 +13151,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mergetreettl_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettl_sql-2379"><a href="#Generator.mergetreettl_sql-2379"><span class="linenos">2379</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mergetreettl_sql-2380"><a href="#Generator.mergetreettl_sql-2380"><span class="linenos">2380</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> -</span><span id="Generator.mergetreettl_sql-2381"><a href="#Generator.mergetreettl_sql-2381"><span class="linenos">2381</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> -</span><span id="Generator.mergetreettl_sql-2382"><a href="#Generator.mergetreettl_sql-2382"><span class="linenos">2382</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> -</span><span id="Generator.mergetreettl_sql-2383"><a href="#Generator.mergetreettl_sql-2383"><span class="linenos">2383</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.mergetreettl_sql-2384"><a href="#Generator.mergetreettl_sql-2384"><span class="linenos">2384</span></a> -</span><span id="Generator.mergetreettl_sql-2385"><a href="#Generator.mergetreettl_sql-2385"><span class="linenos">2385</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> -</span><span id="Generator.mergetreettl_sql-2386"><a href="#Generator.mergetreettl_sql-2386"><span class="linenos">2386</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.mergetreettl_sql-2387"><a href="#Generator.mergetreettl_sql-2387"><span class="linenos">2387</span></a> -</span><span id="Generator.mergetreettl_sql-2388"><a href="#Generator.mergetreettl_sql-2388"><span class="linenos">2388</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mergetreettl_sql-2387"><a href="#Generator.mergetreettl_sql-2387"><span class="linenos">2387</span></a> <span class="k">def</span> <span class="nf">mergetreettl_sql</span><span class="p">(</span><span class="bp">self</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">MergeTreeTTL</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mergetreettl_sql-2388"><a href="#Generator.mergetreettl_sql-2388"><span class="linenos">2388</span></a> <span class="n">where</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"where"</span><span class="p">)</span> +</span><span id="Generator.mergetreettl_sql-2389"><a href="#Generator.mergetreettl_sql-2389"><span class="linenos">2389</span></a> <span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"group"</span><span class="p">)</span> +</span><span id="Generator.mergetreettl_sql-2390"><a href="#Generator.mergetreettl_sql-2390"><span class="linenos">2390</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"aggregates"</span><span class="p">)</span> +</span><span id="Generator.mergetreettl_sql-2391"><a href="#Generator.mergetreettl_sql-2391"><span class="linenos">2391</span></a> <span class="n">aggregates</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s2">"SET"</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">aggregates</span><span class="p">)</span> <span class="k">if</span> <span class="n">aggregates</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.mergetreettl_sql-2392"><a href="#Generator.mergetreettl_sql-2392"><span class="linenos">2392</span></a> +</span><span id="Generator.mergetreettl_sql-2393"><a href="#Generator.mergetreettl_sql-2393"><span class="linenos">2393</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">where</span> <span class="ow">or</span> <span class="n">group</span> <span class="ow">or</span> <span class="n">aggregates</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span> +</span><span id="Generator.mergetreettl_sql-2394"><a href="#Generator.mergetreettl_sql-2394"><span class="linenos">2394</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.mergetreettl_sql-2395"><a href="#Generator.mergetreettl_sql-2395"><span class="linenos">2395</span></a> +</span><span id="Generator.mergetreettl_sql-2396"><a href="#Generator.mergetreettl_sql-2396"><span class="linenos">2396</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"TTL</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">))</span><span class="si">}{</span><span class="n">where</span><span class="si">}{</span><span class="n">group</span><span class="si">}{</span><span class="n">aggregates</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13135,8 +13178,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.transaction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.transaction_sql-2390"><a href="#Generator.transaction_sql-2390"><span class="linenos">2390</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</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">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.transaction_sql-2391"><a href="#Generator.transaction_sql-2391"><span class="linenos">2391</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.transaction_sql-2398"><a href="#Generator.transaction_sql-2398"><span class="linenos">2398</span></a> <span class="k">def</span> <span class="nf">transaction_sql</span><span class="p">(</span><span class="bp">self</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">Transaction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.transaction_sql-2399"><a href="#Generator.transaction_sql-2399"><span class="linenos">2399</span></a> <span class="k">return</span> <span class="s2">"BEGIN"</span> </span></pre></div> @@ -13154,12 +13197,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.commit_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.commit_sql-2393"><a href="#Generator.commit_sql-2393"><span class="linenos">2393</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</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">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.commit_sql-2394"><a href="#Generator.commit_sql-2394"><span class="linenos">2394</span></a> <span class="n">chain</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">"chain"</span><span class="p">)</span> -</span><span id="Generator.commit_sql-2395"><a href="#Generator.commit_sql-2395"><span class="linenos">2395</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.commit_sql-2396"><a href="#Generator.commit_sql-2396"><span class="linenos">2396</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> -</span><span id="Generator.commit_sql-2397"><a href="#Generator.commit_sql-2397"><span class="linenos">2397</span></a> -</span><span id="Generator.commit_sql-2398"><a href="#Generator.commit_sql-2398"><span class="linenos">2398</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.commit_sql-2401"><a href="#Generator.commit_sql-2401"><span class="linenos">2401</span></a> <span class="k">def</span> <span class="nf">commit_sql</span><span class="p">(</span><span class="bp">self</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">Commit</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.commit_sql-2402"><a href="#Generator.commit_sql-2402"><span class="linenos">2402</span></a> <span class="n">chain</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">"chain"</span><span class="p">)</span> +</span><span id="Generator.commit_sql-2403"><a href="#Generator.commit_sql-2403"><span class="linenos">2403</span></a> <span class="k">if</span> <span class="n">chain</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.commit_sql-2404"><a href="#Generator.commit_sql-2404"><span class="linenos">2404</span></a> <span class="n">chain</span> <span class="o">=</span> <span class="s2">" AND CHAIN"</span> <span class="k">if</span> <span class="n">chain</span> <span class="k">else</span> <span class="s2">" AND NO CHAIN"</span> +</span><span id="Generator.commit_sql-2405"><a href="#Generator.commit_sql-2405"><span class="linenos">2405</span></a> +</span><span id="Generator.commit_sql-2406"><a href="#Generator.commit_sql-2406"><span class="linenos">2406</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMIT</span><span class="si">{</span><span class="n">chain</span><span class="w"> </span><span class="ow">or</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13177,10 +13220,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.rollback_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rollback_sql-2400"><a href="#Generator.rollback_sql-2400"><span class="linenos">2400</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</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">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.rollback_sql-2401"><a href="#Generator.rollback_sql-2401"><span class="linenos">2401</span></a> <span class="n">savepoint</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">"savepoint"</span><span class="p">)</span> -</span><span id="Generator.rollback_sql-2402"><a href="#Generator.rollback_sql-2402"><span class="linenos">2402</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.rollback_sql-2403"><a href="#Generator.rollback_sql-2403"><span class="linenos">2403</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.rollback_sql-2408"><a href="#Generator.rollback_sql-2408"><span class="linenos">2408</span></a> <span class="k">def</span> <span class="nf">rollback_sql</span><span class="p">(</span><span class="bp">self</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">Rollback</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.rollback_sql-2409"><a href="#Generator.rollback_sql-2409"><span class="linenos">2409</span></a> <span class="n">savepoint</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">"savepoint"</span><span class="p">)</span> +</span><span id="Generator.rollback_sql-2410"><a href="#Generator.rollback_sql-2410"><span class="linenos">2410</span></a> <span class="n">savepoint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" TO </span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">savepoint</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.rollback_sql-2411"><a href="#Generator.rollback_sql-2411"><span class="linenos">2411</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ROLLBACK</span><span class="si">{</span><span class="n">savepoint</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13198,25 +13241,25 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.altercolumn_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altercolumn_sql-2405"><a href="#Generator.altercolumn_sql-2405"><span class="linenos">2405</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</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">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.altercolumn_sql-2406"><a href="#Generator.altercolumn_sql-2406"><span class="linenos">2406</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2407"><a href="#Generator.altercolumn_sql-2407"><span class="linenos">2407</span></a> -</span><span id="Generator.altercolumn_sql-2408"><a href="#Generator.altercolumn_sql-2408"><span class="linenos">2408</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2409"><a href="#Generator.altercolumn_sql-2409"><span class="linenos">2409</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> -</span><span id="Generator.altercolumn_sql-2410"><a href="#Generator.altercolumn_sql-2410"><span class="linenos">2410</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2411"><a href="#Generator.altercolumn_sql-2411"><span class="linenos">2411</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.altercolumn_sql-2412"><a href="#Generator.altercolumn_sql-2412"><span class="linenos">2412</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2413"><a href="#Generator.altercolumn_sql-2413"><span class="linenos">2413</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.altercolumn_sql-2414"><a href="#Generator.altercolumn_sql-2414"><span class="linenos">2414</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DATA TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altercolumn_sql-2413"><a href="#Generator.altercolumn_sql-2413"><span class="linenos">2413</span></a> <span class="k">def</span> <span class="nf">altercolumn_sql</span><span class="p">(</span><span class="bp">self</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">AlterColumn</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.altercolumn_sql-2414"><a href="#Generator.altercolumn_sql-2414"><span class="linenos">2414</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> </span><span id="Generator.altercolumn_sql-2415"><a href="#Generator.altercolumn_sql-2415"><span class="linenos">2415</span></a> -</span><span id="Generator.altercolumn_sql-2416"><a href="#Generator.altercolumn_sql-2416"><span class="linenos">2416</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2417"><a href="#Generator.altercolumn_sql-2417"><span class="linenos">2417</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> -</span><span id="Generator.altercolumn_sql-2418"><a href="#Generator.altercolumn_sql-2418"><span class="linenos">2418</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.altercolumn_sql-2419"><a href="#Generator.altercolumn_sql-2419"><span class="linenos">2419</span></a> -</span><span id="Generator.altercolumn_sql-2420"><a href="#Generator.altercolumn_sql-2420"><span class="linenos">2420</span></a> <span class="k">if</span> <span class="ow">not</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">"drop"</span><span class="p">):</span> -</span><span id="Generator.altercolumn_sql-2421"><a href="#Generator.altercolumn_sql-2421"><span class="linenos">2421</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> -</span><span id="Generator.altercolumn_sql-2422"><a href="#Generator.altercolumn_sql-2422"><span class="linenos">2422</span></a> -</span><span id="Generator.altercolumn_sql-2423"><a href="#Generator.altercolumn_sql-2423"><span class="linenos">2423</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> +</span><span id="Generator.altercolumn_sql-2416"><a href="#Generator.altercolumn_sql-2416"><span class="linenos">2416</span></a> <span class="n">dtype</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"dtype"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2417"><a href="#Generator.altercolumn_sql-2417"><span class="linenos">2417</span></a> <span class="k">if</span> <span class="n">dtype</span><span class="p">:</span> +</span><span id="Generator.altercolumn_sql-2418"><a href="#Generator.altercolumn_sql-2418"><span class="linenos">2418</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"collate"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2419"><a href="#Generator.altercolumn_sql-2419"><span class="linenos">2419</span></a> <span class="n">collate</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" COLLATE </span><span class="si">{</span><span class="n">collate</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">collate</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.altercolumn_sql-2420"><a href="#Generator.altercolumn_sql-2420"><span class="linenos">2420</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2421"><a href="#Generator.altercolumn_sql-2421"><span class="linenos">2421</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">using</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.altercolumn_sql-2422"><a href="#Generator.altercolumn_sql-2422"><span class="linenos">2422</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DATA TYPE </span><span class="si">{</span><span class="n">dtype</span><span class="si">}{</span><span class="n">collate</span><span class="si">}{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.altercolumn_sql-2423"><a href="#Generator.altercolumn_sql-2423"><span class="linenos">2423</span></a> +</span><span id="Generator.altercolumn_sql-2424"><a href="#Generator.altercolumn_sql-2424"><span class="linenos">2424</span></a> <span class="n">default</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"default"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2425"><a href="#Generator.altercolumn_sql-2425"><span class="linenos">2425</span></a> <span class="k">if</span> <span class="n">default</span><span class="p">:</span> +</span><span id="Generator.altercolumn_sql-2426"><a href="#Generator.altercolumn_sql-2426"><span class="linenos">2426</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> SET DEFAULT </span><span class="si">{</span><span class="n">default</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.altercolumn_sql-2427"><a href="#Generator.altercolumn_sql-2427"><span class="linenos">2427</span></a> +</span><span id="Generator.altercolumn_sql-2428"><a href="#Generator.altercolumn_sql-2428"><span class="linenos">2428</span></a> <span class="k">if</span> <span class="ow">not</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">"drop"</span><span class="p">):</span> +</span><span id="Generator.altercolumn_sql-2429"><a href="#Generator.altercolumn_sql-2429"><span class="linenos">2429</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported ALTER COLUMN syntax"</span><span class="p">)</span> +</span><span id="Generator.altercolumn_sql-2430"><a href="#Generator.altercolumn_sql-2430"><span class="linenos">2430</span></a> +</span><span id="Generator.altercolumn_sql-2431"><a href="#Generator.altercolumn_sql-2431"><span class="linenos">2431</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER COLUMN </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> DROP DEFAULT"</span> </span></pre></div> @@ -13234,14 +13277,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.renametable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.renametable_sql-2425"><a href="#Generator.renametable_sql-2425"><span class="linenos">2425</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</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">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.renametable_sql-2426"><a href="#Generator.renametable_sql-2426"><span class="linenos">2426</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> -</span><span id="Generator.renametable_sql-2427"><a href="#Generator.renametable_sql-2427"><span class="linenos">2427</span></a> <span class="c1"># Remove db from tables</span> -</span><span id="Generator.renametable_sql-2428"><a href="#Generator.renametable_sql-2428"><span class="linenos">2428</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> -</span><span id="Generator.renametable_sql-2429"><a href="#Generator.renametable_sql-2429"><span class="linenos">2429</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> -</span><span id="Generator.renametable_sql-2430"><a href="#Generator.renametable_sql-2430"><span class="linenos">2430</span></a> <span class="p">)</span> -</span><span id="Generator.renametable_sql-2431"><a href="#Generator.renametable_sql-2431"><span class="linenos">2431</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.renametable_sql-2432"><a href="#Generator.renametable_sql-2432"><span class="linenos">2432</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.renametable_sql-2433"><a href="#Generator.renametable_sql-2433"><span class="linenos">2433</span></a> <span class="k">def</span> <span class="nf">renametable_sql</span><span class="p">(</span><span class="bp">self</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">RenameTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.renametable_sql-2434"><a href="#Generator.renametable_sql-2434"><span class="linenos">2434</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">RENAME_TABLE_WITH_DB</span><span class="p">:</span> +</span><span id="Generator.renametable_sql-2435"><a href="#Generator.renametable_sql-2435"><span class="linenos">2435</span></a> <span class="c1"># Remove db from tables</span> +</span><span id="Generator.renametable_sql-2436"><a href="#Generator.renametable_sql-2436"><span class="linenos">2436</span></a> <span class="n">expression</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span> +</span><span id="Generator.renametable_sql-2437"><a href="#Generator.renametable_sql-2437"><span class="linenos">2437</span></a> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">exp</span><span class="o">.</span><span class="n">table_</span><span class="p">(</span><span class="n">n</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Table</span><span class="p">)</span> <span class="k">else</span> <span class="n">n</span> +</span><span id="Generator.renametable_sql-2438"><a href="#Generator.renametable_sql-2438"><span class="linenos">2438</span></a> <span class="p">)</span> +</span><span id="Generator.renametable_sql-2439"><a href="#Generator.renametable_sql-2439"><span class="linenos">2439</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.renametable_sql-2440"><a href="#Generator.renametable_sql-2440"><span class="linenos">2440</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"RENAME TO </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13259,28 +13302,28 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.altertable_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altertable_sql-2434"><a href="#Generator.altertable_sql-2434"><span class="linenos">2434</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</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">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.altertable_sql-2435"><a href="#Generator.altertable_sql-2435"><span class="linenos">2435</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> -</span><span id="Generator.altertable_sql-2436"><a href="#Generator.altertable_sql-2436"><span class="linenos">2436</span></a> -</span><span id="Generator.altertable_sql-2437"><a href="#Generator.altertable_sql-2437"><span class="linenos">2437</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> -</span><span id="Generator.altertable_sql-2438"><a href="#Generator.altertable_sql-2438"><span class="linenos">2438</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_ADD_COLUMN_KEYWORD</span><span class="p">:</span> -</span><span id="Generator.altertable_sql-2439"><a href="#Generator.altertable_sql-2439"><span class="linenos">2439</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> -</span><span id="Generator.altertable_sql-2440"><a href="#Generator.altertable_sql-2440"><span class="linenos">2440</span></a> <span class="n">expression</span><span class="p">,</span> -</span><span id="Generator.altertable_sql-2441"><a href="#Generator.altertable_sql-2441"><span class="linenos">2441</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> -</span><span id="Generator.altertable_sql-2442"><a href="#Generator.altertable_sql-2442"><span class="linenos">2442</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">,</span> -</span><span id="Generator.altertable_sql-2443"><a href="#Generator.altertable_sql-2443"><span class="linenos">2443</span></a> <span class="p">)</span> -</span><span id="Generator.altertable_sql-2444"><a href="#Generator.altertable_sql-2444"><span class="linenos">2444</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.altertable_sql-2445"><a href="#Generator.altertable_sql-2445"><span class="linenos">2445</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="o">=</span><span class="s1">'actions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.altertable_sql-2446"><a href="#Generator.altertable_sql-2446"><span class="linenos">2446</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> -</span><span id="Generator.altertable_sql-2447"><a href="#Generator.altertable_sql-2447"><span class="linenos">2447</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> -</span><span id="Generator.altertable_sql-2448"><a href="#Generator.altertable_sql-2448"><span class="linenos">2448</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> -</span><span id="Generator.altertable_sql-2449"><a href="#Generator.altertable_sql-2449"><span class="linenos">2449</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.altertable_sql-2450"><a href="#Generator.altertable_sql-2450"><span class="linenos">2450</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.altertable_sql-2451"><a href="#Generator.altertable_sql-2451"><span class="linenos">2451</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.altertable_sql-2452"><a href="#Generator.altertable_sql-2452"><span class="linenos">2452</span></a> -</span><span id="Generator.altertable_sql-2453"><a href="#Generator.altertable_sql-2453"><span class="linenos">2453</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.altertable_sql-2454"><a href="#Generator.altertable_sql-2454"><span class="linenos">2454</span></a> <span class="n">only</span> <span class="o">=</span> <span class="s2">" ONLY"</span> <span class="k">if</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">"only"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.altertable_sql-2455"><a href="#Generator.altertable_sql-2455"><span class="linenos">2455</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">only</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.altertable_sql-2442"><a href="#Generator.altertable_sql-2442"><span class="linenos">2442</span></a> <span class="k">def</span> <span class="nf">altertable_sql</span><span class="p">(</span><span class="bp">self</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">AlterTable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.altertable_sql-2443"><a href="#Generator.altertable_sql-2443"><span class="linenos">2443</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"actions"</span><span class="p">]</span> +</span><span id="Generator.altertable_sql-2444"><a href="#Generator.altertable_sql-2444"><span class="linenos">2444</span></a> +</span><span id="Generator.altertable_sql-2445"><a href="#Generator.altertable_sql-2445"><span class="linenos">2445</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">ColumnDef</span><span class="p">):</span> +</span><span id="Generator.altertable_sql-2446"><a href="#Generator.altertable_sql-2446"><span class="linenos">2446</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ALTER_TABLE_ADD_COLUMN_KEYWORD</span><span class="p">:</span> +</span><span id="Generator.altertable_sql-2447"><a href="#Generator.altertable_sql-2447"><span class="linenos">2447</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span> +</span><span id="Generator.altertable_sql-2448"><a href="#Generator.altertable_sql-2448"><span class="linenos">2448</span></a> <span class="n">expression</span><span class="p">,</span> +</span><span id="Generator.altertable_sql-2449"><a href="#Generator.altertable_sql-2449"><span class="linenos">2449</span></a> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> +</span><span id="Generator.altertable_sql-2450"><a href="#Generator.altertable_sql-2450"><span class="linenos">2450</span></a> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMN "</span><span class="p">,</span> +</span><span id="Generator.altertable_sql-2451"><a href="#Generator.altertable_sql-2451"><span class="linenos">2451</span></a> <span class="p">)</span> +</span><span id="Generator.altertable_sql-2452"><a href="#Generator.altertable_sql-2452"><span class="linenos">2452</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.altertable_sql-2453"><a href="#Generator.altertable_sql-2453"><span class="linenos">2453</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="n">key</span><span class="o">=</span><span class="s1">'actions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.altertable_sql-2454"><a href="#Generator.altertable_sql-2454"><span class="linenos">2454</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Schema</span><span class="p">):</span> +</span><span id="Generator.altertable_sql-2455"><a href="#Generator.altertable_sql-2455"><span class="linenos">2455</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s2">"ADD COLUMNS "</span><span class="p">)</span> +</span><span id="Generator.altertable_sql-2456"><a href="#Generator.altertable_sql-2456"><span class="linenos">2456</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">actions</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">Delete</span><span class="p">):</span> +</span><span id="Generator.altertable_sql-2457"><a href="#Generator.altertable_sql-2457"><span class="linenos">2457</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.altertable_sql-2458"><a href="#Generator.altertable_sql-2458"><span class="linenos">2458</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.altertable_sql-2459"><a href="#Generator.altertable_sql-2459"><span class="linenos">2459</span></a> <span class="n">actions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"actions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.altertable_sql-2460"><a href="#Generator.altertable_sql-2460"><span class="linenos">2460</span></a> +</span><span id="Generator.altertable_sql-2461"><a href="#Generator.altertable_sql-2461"><span class="linenos">2461</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS"</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.altertable_sql-2462"><a href="#Generator.altertable_sql-2462"><span class="linenos">2462</span></a> <span class="n">only</span> <span class="o">=</span> <span class="s2">" ONLY"</span> <span class="k">if</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">"only"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.altertable_sql-2463"><a href="#Generator.altertable_sql-2463"><span class="linenos">2463</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ALTER TABLE</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">only</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">actions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13298,10 +13341,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.droppartition_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.droppartition_sql-2457"><a href="#Generator.droppartition_sql-2457"><span class="linenos">2457</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</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">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.droppartition_sql-2458"><a href="#Generator.droppartition_sql-2458"><span class="linenos">2458</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.droppartition_sql-2459"><a href="#Generator.droppartition_sql-2459"><span class="linenos">2459</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> -</span><span id="Generator.droppartition_sql-2460"><a href="#Generator.droppartition_sql-2460"><span class="linenos">2460</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.droppartition_sql-2465"><a href="#Generator.droppartition_sql-2465"><span class="linenos">2465</span></a> <span class="k">def</span> <span class="nf">droppartition_sql</span><span class="p">(</span><span class="bp">self</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">DropPartition</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.droppartition_sql-2466"><a href="#Generator.droppartition_sql-2466"><span class="linenos">2466</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.droppartition_sql-2467"><a href="#Generator.droppartition_sql-2467"><span class="linenos">2467</span></a> <span class="n">exists</span> <span class="o">=</span> <span class="s2">" IF EXISTS "</span> <span class="k">if</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">"exists"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">" "</span> +</span><span id="Generator.droppartition_sql-2468"><a href="#Generator.droppartition_sql-2468"><span class="linenos">2468</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DROP</span><span class="si">{</span><span class="n">exists</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13319,16 +13362,16 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.addconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.addconstraint_sql-2462"><a href="#Generator.addconstraint_sql-2462"><span class="linenos">2462</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</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">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.addconstraint_sql-2463"><a href="#Generator.addconstraint_sql-2463"><span class="linenos">2463</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.addconstraint_sql-2464"><a href="#Generator.addconstraint_sql-2464"><span class="linenos">2464</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.addconstraint_sql-2465"><a href="#Generator.addconstraint_sql-2465"><span class="linenos">2465</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> -</span><span id="Generator.addconstraint_sql-2466"><a href="#Generator.addconstraint_sql-2466"><span class="linenos">2466</span></a> -</span><span id="Generator.addconstraint_sql-2467"><a href="#Generator.addconstraint_sql-2467"><span class="linenos">2467</span></a> <span class="n">enforced</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">"enforced"</span><span class="p">)</span> -</span><span id="Generator.addconstraint_sql-2468"><a href="#Generator.addconstraint_sql-2468"><span class="linenos">2468</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.addconstraint_sql-2469"><a href="#Generator.addconstraint_sql-2469"><span class="linenos">2469</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.addconstraint_sql-2470"><a href="#Generator.addconstraint_sql-2470"><span class="linenos">2470</span></a> -</span><span id="Generator.addconstraint_sql-2471"><a href="#Generator.addconstraint_sql-2471"><span class="linenos">2471</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.addconstraint_sql-2470"><a href="#Generator.addconstraint_sql-2470"><span class="linenos">2470</span></a> <span class="k">def</span> <span class="nf">addconstraint_sql</span><span class="p">(</span><span class="bp">self</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">AddConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.addconstraint_sql-2471"><a href="#Generator.addconstraint_sql-2471"><span class="linenos">2471</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.addconstraint_sql-2472"><a href="#Generator.addconstraint_sql-2472"><span class="linenos">2472</span></a> <span class="n">expression_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.addconstraint_sql-2473"><a href="#Generator.addconstraint_sql-2473"><span class="linenos">2473</span></a> <span class="n">add_constraint</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ADD CONSTRAINT </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">"ADD"</span> +</span><span id="Generator.addconstraint_sql-2474"><a href="#Generator.addconstraint_sql-2474"><span class="linenos">2474</span></a> +</span><span id="Generator.addconstraint_sql-2475"><a href="#Generator.addconstraint_sql-2475"><span class="linenos">2475</span></a> <span class="n">enforced</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">"enforced"</span><span class="p">)</span> +</span><span id="Generator.addconstraint_sql-2476"><a href="#Generator.addconstraint_sql-2476"><span class="linenos">2476</span></a> <span class="k">if</span> <span class="n">enforced</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.addconstraint_sql-2477"><a href="#Generator.addconstraint_sql-2477"><span class="linenos">2477</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> CHECK (</span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="s1">' ENFORCED'</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">enforced</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.addconstraint_sql-2478"><a href="#Generator.addconstraint_sql-2478"><span class="linenos">2478</span></a> +</span><span id="Generator.addconstraint_sql-2479"><a href="#Generator.addconstraint_sql-2479"><span class="linenos">2479</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">add_constraint</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expression_</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13346,13 +13389,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.distinct_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distinct_sql-2473"><a href="#Generator.distinct_sql-2473"><span class="linenos">2473</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</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">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.distinct_sql-2474"><a href="#Generator.distinct_sql-2474"><span class="linenos">2474</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.distinct_sql-2475"><a href="#Generator.distinct_sql-2475"><span class="linenos">2475</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.distinct_sql-2476"><a href="#Generator.distinct_sql-2476"><span class="linenos">2476</span></a> -</span><span id="Generator.distinct_sql-2477"><a href="#Generator.distinct_sql-2477"><span class="linenos">2477</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> -</span><span id="Generator.distinct_sql-2478"><a href="#Generator.distinct_sql-2478"><span class="linenos">2478</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.distinct_sql-2479"><a href="#Generator.distinct_sql-2479"><span class="linenos">2479</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distinct_sql-2481"><a href="#Generator.distinct_sql-2481"><span class="linenos">2481</span></a> <span class="k">def</span> <span class="nf">distinct_sql</span><span class="p">(</span><span class="bp">self</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">Distinct</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.distinct_sql-2482"><a href="#Generator.distinct_sql-2482"><span class="linenos">2482</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.distinct_sql-2483"><a href="#Generator.distinct_sql-2483"><span class="linenos">2483</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.distinct_sql-2484"><a href="#Generator.distinct_sql-2484"><span class="linenos">2484</span></a> +</span><span id="Generator.distinct_sql-2485"><a href="#Generator.distinct_sql-2485"><span class="linenos">2485</span></a> <span class="n">on</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"on"</span><span class="p">)</span> +</span><span id="Generator.distinct_sql-2486"><a href="#Generator.distinct_sql-2486"><span class="linenos">2486</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" ON </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">on</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.distinct_sql-2487"><a href="#Generator.distinct_sql-2487"><span class="linenos">2487</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"DISTINCT</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">on</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13370,8 +13413,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.ignorenulls_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ignorenulls_sql-2481"><a href="#Generator.ignorenulls_sql-2481"><span class="linenos">2481</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</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">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.ignorenulls_sql-2482"><a href="#Generator.ignorenulls_sql-2482"><span class="linenos">2482</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ignorenulls_sql-2489"><a href="#Generator.ignorenulls_sql-2489"><span class="linenos">2489</span></a> <span class="k">def</span> <span class="nf">ignorenulls_sql</span><span class="p">(</span><span class="bp">self</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">IgnoreNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.ignorenulls_sql-2490"><a href="#Generator.ignorenulls_sql-2490"><span class="linenos">2490</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> IGNORE NULLS"</span> </span></pre></div> @@ -13389,8 +13432,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.respectnulls_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.respectnulls_sql-2484"><a href="#Generator.respectnulls_sql-2484"><span class="linenos">2484</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</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">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.respectnulls_sql-2485"><a href="#Generator.respectnulls_sql-2485"><span class="linenos">2485</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.respectnulls_sql-2492"><a href="#Generator.respectnulls_sql-2492"><span class="linenos">2492</span></a> <span class="k">def</span> <span class="nf">respectnulls_sql</span><span class="p">(</span><span class="bp">self</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">RespectNulls</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.respectnulls_sql-2493"><a href="#Generator.respectnulls_sql-2493"><span class="linenos">2493</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> RESPECT NULLS"</span> </span></pre></div> @@ -13408,13 +13451,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.intdiv_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intdiv_sql-2487"><a href="#Generator.intdiv_sql-2487"><span class="linenos">2487</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</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">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.intdiv_sql-2488"><a href="#Generator.intdiv_sql-2488"><span class="linenos">2488</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator.intdiv_sql-2489"><a href="#Generator.intdiv_sql-2489"><span class="linenos">2489</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> -</span><span id="Generator.intdiv_sql-2490"><a href="#Generator.intdiv_sql-2490"><span class="linenos">2490</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()),</span> -</span><span id="Generator.intdiv_sql-2491"><a href="#Generator.intdiv_sql-2491"><span class="linenos">2491</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> -</span><span id="Generator.intdiv_sql-2492"><a href="#Generator.intdiv_sql-2492"><span class="linenos">2492</span></a> <span class="p">)</span> -</span><span id="Generator.intdiv_sql-2493"><a href="#Generator.intdiv_sql-2493"><span class="linenos">2493</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.intdiv_sql-2495"><a href="#Generator.intdiv_sql-2495"><span class="linenos">2495</span></a> <span class="k">def</span> <span class="nf">intdiv_sql</span><span class="p">(</span><span class="bp">self</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">IntDiv</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.intdiv_sql-2496"><a href="#Generator.intdiv_sql-2496"><span class="linenos">2496</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator.intdiv_sql-2497"><a href="#Generator.intdiv_sql-2497"><span class="linenos">2497</span></a> <span class="n">exp</span><span class="o">.</span><span class="n">Cast</span><span class="p">(</span> +</span><span id="Generator.intdiv_sql-2498"><a href="#Generator.intdiv_sql-2498"><span class="linenos">2498</span></a> <span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">Div</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">expression</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">copy</span><span class="p">()),</span> +</span><span id="Generator.intdiv_sql-2499"><a href="#Generator.intdiv_sql-2499"><span class="linenos">2499</span></a> <span class="n">to</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="n">this</span><span class="o">=</span><span class="n">exp</span><span class="o">.</span><span class="n">DataType</span><span class="o">.</span><span class="n">Type</span><span class="o">.</span><span class="n">INT</span><span class="p">),</span> +</span><span id="Generator.intdiv_sql-2500"><a href="#Generator.intdiv_sql-2500"><span class="linenos">2500</span></a> <span class="p">)</span> +</span><span id="Generator.intdiv_sql-2501"><a href="#Generator.intdiv_sql-2501"><span class="linenos">2501</span></a> <span class="p">)</span> </span></pre></div> @@ -13432,8 +13475,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dpipe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dpipe_sql-2495"><a href="#Generator.dpipe_sql-2495"><span class="linenos">2495</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</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">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dpipe_sql-2496"><a href="#Generator.dpipe_sql-2496"><span class="linenos">2496</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dpipe_sql-2503"><a href="#Generator.dpipe_sql-2503"><span class="linenos">2503</span></a> <span class="k">def</span> <span class="nf">dpipe_sql</span><span class="p">(</span><span class="bp">self</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">DPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dpipe_sql-2504"><a href="#Generator.dpipe_sql-2504"><span class="linenos">2504</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"||"</span><span class="p">)</span> </span></pre></div> @@ -13451,10 +13494,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.safedpipe_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.safedpipe_sql-2498"><a href="#Generator.safedpipe_sql-2498"><span class="linenos">2498</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</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">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.safedpipe_sql-2499"><a href="#Generator.safedpipe_sql-2499"><span class="linenos">2499</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> -</span><span id="Generator.safedpipe_sql-2500"><a href="#Generator.safedpipe_sql-2500"><span class="linenos">2500</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> -</span><span id="Generator.safedpipe_sql-2501"><a href="#Generator.safedpipe_sql-2501"><span class="linenos">2501</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.safedpipe_sql-2506"><a href="#Generator.safedpipe_sql-2506"><span class="linenos">2506</span></a> <span class="k">def</span> <span class="nf">safedpipe_sql</span><span class="p">(</span><span class="bp">self</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">SafeDPipe</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.safedpipe_sql-2507"><a href="#Generator.safedpipe_sql-2507"><span class="linenos">2507</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">STRICT_STRING_CONCAT</span><span class="p">:</span> +</span><span id="Generator.safedpipe_sql-2508"><a href="#Generator.safedpipe_sql-2508"><span class="linenos">2508</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"CONCAT"</span><span class="p">,</span> <span class="o">*</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span> +</span><span id="Generator.safedpipe_sql-2509"><a href="#Generator.safedpipe_sql-2509"><span class="linenos">2509</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">dpipe_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> </span></pre></div> @@ -13472,8 +13515,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.div_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.div_sql-2503"><a href="#Generator.div_sql-2503"><span class="linenos">2503</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</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">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.div_sql-2504"><a href="#Generator.div_sql-2504"><span class="linenos">2504</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.div_sql-2511"><a href="#Generator.div_sql-2511"><span class="linenos">2511</span></a> <span class="k">def</span> <span class="nf">div_sql</span><span class="p">(</span><span class="bp">self</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">Div</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.div_sql-2512"><a href="#Generator.div_sql-2512"><span class="linenos">2512</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"/"</span><span class="p">)</span> </span></pre></div> @@ -13491,8 +13534,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.overlaps_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.overlaps_sql-2506"><a href="#Generator.overlaps_sql-2506"><span class="linenos">2506</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</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">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.overlaps_sql-2507"><a href="#Generator.overlaps_sql-2507"><span class="linenos">2507</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.overlaps_sql-2514"><a href="#Generator.overlaps_sql-2514"><span class="linenos">2514</span></a> <span class="k">def</span> <span class="nf">overlaps_sql</span><span class="p">(</span><span class="bp">self</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">Overlaps</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.overlaps_sql-2515"><a href="#Generator.overlaps_sql-2515"><span class="linenos">2515</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OVERLAPS"</span><span class="p">)</span> </span></pre></div> @@ -13510,8 +13553,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.distance_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distance_sql-2509"><a href="#Generator.distance_sql-2509"><span class="linenos">2509</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</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">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.distance_sql-2510"><a href="#Generator.distance_sql-2510"><span class="linenos">2510</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.distance_sql-2517"><a href="#Generator.distance_sql-2517"><span class="linenos">2517</span></a> <span class="k">def</span> <span class="nf">distance_sql</span><span class="p">(</span><span class="bp">self</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">Distance</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.distance_sql-2518"><a href="#Generator.distance_sql-2518"><span class="linenos">2518</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<->"</span><span class="p">)</span> </span></pre></div> @@ -13529,8 +13572,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dot_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dot_sql-2512"><a href="#Generator.dot_sql-2512"><span class="linenos">2512</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</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">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dot_sql-2513"><a href="#Generator.dot_sql-2513"><span class="linenos">2513</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dot_sql-2520"><a href="#Generator.dot_sql-2520"><span class="linenos">2520</span></a> <span class="k">def</span> <span class="nf">dot_sql</span><span class="p">(</span><span class="bp">self</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">Dot</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dot_sql-2521"><a href="#Generator.dot_sql-2521"><span class="linenos">2521</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">.</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -13548,8 +13591,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.eq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.eq_sql-2515"><a href="#Generator.eq_sql-2515"><span class="linenos">2515</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</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">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.eq_sql-2516"><a href="#Generator.eq_sql-2516"><span class="linenos">2516</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.eq_sql-2523"><a href="#Generator.eq_sql-2523"><span class="linenos">2523</span></a> <span class="k">def</span> <span class="nf">eq_sql</span><span class="p">(</span><span class="bp">self</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">EQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.eq_sql-2524"><a href="#Generator.eq_sql-2524"><span class="linenos">2524</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"="</span><span class="p">)</span> </span></pre></div> @@ -13567,8 +13610,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.escape_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.escape_sql-2518"><a href="#Generator.escape_sql-2518"><span class="linenos">2518</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</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">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.escape_sql-2519"><a href="#Generator.escape_sql-2519"><span class="linenos">2519</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.escape_sql-2526"><a href="#Generator.escape_sql-2526"><span class="linenos">2526</span></a> <span class="k">def</span> <span class="nf">escape_sql</span><span class="p">(</span><span class="bp">self</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">Escape</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.escape_sql-2527"><a href="#Generator.escape_sql-2527"><span class="linenos">2527</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ESCAPE"</span><span class="p">)</span> </span></pre></div> @@ -13586,8 +13629,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.glob_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.glob_sql-2521"><a href="#Generator.glob_sql-2521"><span class="linenos">2521</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</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">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.glob_sql-2522"><a href="#Generator.glob_sql-2522"><span class="linenos">2522</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.glob_sql-2529"><a href="#Generator.glob_sql-2529"><span class="linenos">2529</span></a> <span class="k">def</span> <span class="nf">glob_sql</span><span class="p">(</span><span class="bp">self</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">Glob</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.glob_sql-2530"><a href="#Generator.glob_sql-2530"><span class="linenos">2530</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"GLOB"</span><span class="p">)</span> </span></pre></div> @@ -13605,8 +13648,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.gt_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gt_sql-2524"><a href="#Generator.gt_sql-2524"><span class="linenos">2524</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</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">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.gt_sql-2525"><a href="#Generator.gt_sql-2525"><span class="linenos">2525</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gt_sql-2532"><a href="#Generator.gt_sql-2532"><span class="linenos">2532</span></a> <span class="k">def</span> <span class="nf">gt_sql</span><span class="p">(</span><span class="bp">self</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">GT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.gt_sql-2533"><a href="#Generator.gt_sql-2533"><span class="linenos">2533</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">"</span><span class="p">)</span> </span></pre></div> @@ -13624,8 +13667,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.gte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gte_sql-2527"><a href="#Generator.gte_sql-2527"><span class="linenos">2527</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</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">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.gte_sql-2528"><a href="#Generator.gte_sql-2528"><span class="linenos">2528</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.gte_sql-2535"><a href="#Generator.gte_sql-2535"><span class="linenos">2535</span></a> <span class="k">def</span> <span class="nf">gte_sql</span><span class="p">(</span><span class="bp">self</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">GTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.gte_sql-2536"><a href="#Generator.gte_sql-2536"><span class="linenos">2536</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">">="</span><span class="p">)</span> </span></pre></div> @@ -13643,8 +13686,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.ilike_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilike_sql-2530"><a href="#Generator.ilike_sql-2530"><span class="linenos">2530</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</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">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.ilike_sql-2531"><a href="#Generator.ilike_sql-2531"><span class="linenos">2531</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilike_sql-2538"><a href="#Generator.ilike_sql-2538"><span class="linenos">2538</span></a> <span class="k">def</span> <span class="nf">ilike_sql</span><span class="p">(</span><span class="bp">self</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">ILike</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.ilike_sql-2539"><a href="#Generator.ilike_sql-2539"><span class="linenos">2539</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE"</span><span class="p">)</span> </span></pre></div> @@ -13662,8 +13705,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.ilikeany_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilikeany_sql-2533"><a href="#Generator.ilikeany_sql-2533"><span class="linenos">2533</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</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">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.ilikeany_sql-2534"><a href="#Generator.ilikeany_sql-2534"><span class="linenos">2534</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.ilikeany_sql-2541"><a href="#Generator.ilikeany_sql-2541"><span class="linenos">2541</span></a> <span class="k">def</span> <span class="nf">ilikeany_sql</span><span class="p">(</span><span class="bp">self</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">ILikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.ilikeany_sql-2542"><a href="#Generator.ilikeany_sql-2542"><span class="linenos">2542</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"ILIKE ANY"</span><span class="p">)</span> </span></pre></div> @@ -13681,12 +13724,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.is_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.is_sql-2536"><a href="#Generator.is_sql-2536"><span class="linenos">2536</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</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">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.is_sql-2537"><a href="#Generator.is_sql-2537"><span class="linenos">2537</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Boolean</span><span class="p">):</span> -</span><span id="Generator.is_sql-2538"><a href="#Generator.is_sql-2538"><span class="linenos">2538</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> -</span><span id="Generator.is_sql-2539"><a href="#Generator.is_sql-2539"><span class="linenos">2539</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> -</span><span id="Generator.is_sql-2540"><a href="#Generator.is_sql-2540"><span class="linenos">2540</span></a> <span class="p">)</span> -</span><span id="Generator.is_sql-2541"><a href="#Generator.is_sql-2541"><span class="linenos">2541</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.is_sql-2544"><a href="#Generator.is_sql-2544"><span class="linenos">2544</span></a> <span class="k">def</span> <span class="nf">is_sql</span><span class="p">(</span><span class="bp">self</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">Is</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.is_sql-2545"><a href="#Generator.is_sql-2545"><span class="linenos">2545</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">IS_BOOL_ALLOWED</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Boolean</span><span class="p">):</span> +</span><span id="Generator.is_sql-2546"><a href="#Generator.is_sql-2546"><span class="linenos">2546</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span> +</span><span id="Generator.is_sql-2547"><a href="#Generator.is_sql-2547"><span class="linenos">2547</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span> <span class="k">else</span> <span class="n">exp</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span> +</span><span id="Generator.is_sql-2548"><a href="#Generator.is_sql-2548"><span class="linenos">2548</span></a> <span class="p">)</span> +</span><span id="Generator.is_sql-2549"><a href="#Generator.is_sql-2549"><span class="linenos">2549</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS"</span><span class="p">)</span> </span></pre></div> @@ -13704,8 +13747,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.like_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.like_sql-2543"><a href="#Generator.like_sql-2543"><span class="linenos">2543</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</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">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.like_sql-2544"><a href="#Generator.like_sql-2544"><span class="linenos">2544</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.like_sql-2551"><a href="#Generator.like_sql-2551"><span class="linenos">2551</span></a> <span class="k">def</span> <span class="nf">like_sql</span><span class="p">(</span><span class="bp">self</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">Like</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.like_sql-2552"><a href="#Generator.like_sql-2552"><span class="linenos">2552</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE"</span><span class="p">)</span> </span></pre></div> @@ -13723,8 +13766,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.likeany_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeany_sql-2546"><a href="#Generator.likeany_sql-2546"><span class="linenos">2546</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</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">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.likeany_sql-2547"><a href="#Generator.likeany_sql-2547"><span class="linenos">2547</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.likeany_sql-2554"><a href="#Generator.likeany_sql-2554"><span class="linenos">2554</span></a> <span class="k">def</span> <span class="nf">likeany_sql</span><span class="p">(</span><span class="bp">self</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">LikeAny</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.likeany_sql-2555"><a href="#Generator.likeany_sql-2555"><span class="linenos">2555</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"LIKE ANY"</span><span class="p">)</span> </span></pre></div> @@ -13742,8 +13785,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.similarto_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.similarto_sql-2549"><a href="#Generator.similarto_sql-2549"><span class="linenos">2549</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</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">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.similarto_sql-2550"><a href="#Generator.similarto_sql-2550"><span class="linenos">2550</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.similarto_sql-2557"><a href="#Generator.similarto_sql-2557"><span class="linenos">2557</span></a> <span class="k">def</span> <span class="nf">similarto_sql</span><span class="p">(</span><span class="bp">self</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">SimilarTo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.similarto_sql-2558"><a href="#Generator.similarto_sql-2558"><span class="linenos">2558</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"SIMILAR TO"</span><span class="p">)</span> </span></pre></div> @@ -13761,8 +13804,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.lt_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lt_sql-2552"><a href="#Generator.lt_sql-2552"><span class="linenos">2552</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</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">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lt_sql-2553"><a href="#Generator.lt_sql-2553"><span class="linenos">2553</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lt_sql-2560"><a href="#Generator.lt_sql-2560"><span class="linenos">2560</span></a> <span class="k">def</span> <span class="nf">lt_sql</span><span class="p">(</span><span class="bp">self</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">LT</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lt_sql-2561"><a href="#Generator.lt_sql-2561"><span class="linenos">2561</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<"</span><span class="p">)</span> </span></pre></div> @@ -13780,8 +13823,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.lte_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lte_sql-2555"><a href="#Generator.lte_sql-2555"><span class="linenos">2555</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</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">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.lte_sql-2556"><a href="#Generator.lte_sql-2556"><span class="linenos">2556</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.lte_sql-2563"><a href="#Generator.lte_sql-2563"><span class="linenos">2563</span></a> <span class="k">def</span> <span class="nf">lte_sql</span><span class="p">(</span><span class="bp">self</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">LTE</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.lte_sql-2564"><a href="#Generator.lte_sql-2564"><span class="linenos">2564</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<="</span><span class="p">)</span> </span></pre></div> @@ -13799,8 +13842,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mod_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mod_sql-2558"><a href="#Generator.mod_sql-2558"><span class="linenos">2558</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</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">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mod_sql-2559"><a href="#Generator.mod_sql-2559"><span class="linenos">2559</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mod_sql-2566"><a href="#Generator.mod_sql-2566"><span class="linenos">2566</span></a> <span class="k">def</span> <span class="nf">mod_sql</span><span class="p">(</span><span class="bp">self</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">Mod</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mod_sql-2567"><a href="#Generator.mod_sql-2567"><span class="linenos">2567</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"%"</span><span class="p">)</span> </span></pre></div> @@ -13818,8 +13861,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.mul_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mul_sql-2561"><a href="#Generator.mul_sql-2561"><span class="linenos">2561</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</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">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.mul_sql-2562"><a href="#Generator.mul_sql-2562"><span class="linenos">2562</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.mul_sql-2569"><a href="#Generator.mul_sql-2569"><span class="linenos">2569</span></a> <span class="k">def</span> <span class="nf">mul_sql</span><span class="p">(</span><span class="bp">self</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">Mul</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.mul_sql-2570"><a href="#Generator.mul_sql-2570"><span class="linenos">2570</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"*"</span><span class="p">)</span> </span></pre></div> @@ -13837,8 +13880,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.neq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neq_sql-2564"><a href="#Generator.neq_sql-2564"><span class="linenos">2564</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</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">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.neq_sql-2565"><a href="#Generator.neq_sql-2565"><span class="linenos">2565</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.neq_sql-2572"><a href="#Generator.neq_sql-2572"><span class="linenos">2572</span></a> <span class="k">def</span> <span class="nf">neq_sql</span><span class="p">(</span><span class="bp">self</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">NEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.neq_sql-2573"><a href="#Generator.neq_sql-2573"><span class="linenos">2573</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"<>"</span><span class="p">)</span> </span></pre></div> @@ -13856,8 +13899,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.nullsafeeq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeeq_sql-2567"><a href="#Generator.nullsafeeq_sql-2567"><span class="linenos">2567</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.nullsafeeq_sql-2568"><a href="#Generator.nullsafeeq_sql-2568"><span class="linenos">2568</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeeq_sql-2575"><a href="#Generator.nullsafeeq_sql-2575"><span class="linenos">2575</span></a> <span class="k">def</span> <span class="nf">nullsafeeq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.nullsafeeq_sql-2576"><a href="#Generator.nullsafeeq_sql-2576"><span class="linenos">2576</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS NOT DISTINCT FROM"</span><span class="p">)</span> </span></pre></div> @@ -13875,8 +13918,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.nullsafeneq_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeneq_sql-2570"><a href="#Generator.nullsafeneq_sql-2570"><span class="linenos">2570</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.nullsafeneq_sql-2571"><a href="#Generator.nullsafeneq_sql-2571"><span class="linenos">2571</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nullsafeneq_sql-2578"><a href="#Generator.nullsafeneq_sql-2578"><span class="linenos">2578</span></a> <span class="k">def</span> <span class="nf">nullsafeneq_sql</span><span class="p">(</span><span class="bp">self</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">NullSafeNEQ</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.nullsafeneq_sql-2579"><a href="#Generator.nullsafeneq_sql-2579"><span class="linenos">2579</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"IS DISTINCT FROM"</span><span class="p">)</span> </span></pre></div> @@ -13894,8 +13937,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.or_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.or_sql-2573"><a href="#Generator.or_sql-2573"><span class="linenos">2573</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</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">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.or_sql-2574"><a href="#Generator.or_sql-2574"><span class="linenos">2574</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.or_sql-2581"><a href="#Generator.or_sql-2581"><span class="linenos">2581</span></a> <span class="k">def</span> <span class="nf">or_sql</span><span class="p">(</span><span class="bp">self</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">Or</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.or_sql-2582"><a href="#Generator.or_sql-2582"><span class="linenos">2582</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">connector_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"OR"</span><span class="p">)</span> </span></pre></div> @@ -13913,8 +13956,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.slice_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.slice_sql-2576"><a href="#Generator.slice_sql-2576"><span class="linenos">2576</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</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">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.slice_sql-2577"><a href="#Generator.slice_sql-2577"><span class="linenos">2577</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.slice_sql-2584"><a href="#Generator.slice_sql-2584"><span class="linenos">2584</span></a> <span class="k">def</span> <span class="nf">slice_sql</span><span class="p">(</span><span class="bp">self</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">Slice</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.slice_sql-2585"><a href="#Generator.slice_sql-2585"><span class="linenos">2585</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">":"</span><span class="p">)</span> </span></pre></div> @@ -13932,8 +13975,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.sub_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sub_sql-2579"><a href="#Generator.sub_sql-2579"><span class="linenos">2579</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</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">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.sub_sql-2580"><a href="#Generator.sub_sql-2580"><span class="linenos">2580</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.sub_sql-2587"><a href="#Generator.sub_sql-2587"><span class="linenos">2587</span></a> <span class="k">def</span> <span class="nf">sub_sql</span><span class="p">(</span><span class="bp">self</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">Sub</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.sub_sql-2588"><a href="#Generator.sub_sql-2588"><span class="linenos">2588</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"-"</span><span class="p">)</span> </span></pre></div> @@ -13951,8 +13994,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.trycast_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trycast_sql-2582"><a href="#Generator.trycast_sql-2582"><span class="linenos">2582</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</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">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.trycast_sql-2583"><a href="#Generator.trycast_sql-2583"><span class="linenos">2583</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY_"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.trycast_sql-2590"><a href="#Generator.trycast_sql-2590"><span class="linenos">2590</span></a> <span class="k">def</span> <span class="nf">trycast_sql</span><span class="p">(</span><span class="bp">self</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">TryCast</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.trycast_sql-2591"><a href="#Generator.trycast_sql-2591"><span class="linenos">2591</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cast_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">safe_prefix</span><span class="o">=</span><span class="s2">"TRY_"</span><span class="p">)</span> </span></pre></div> @@ -13970,11 +14013,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.log_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.log_sql-2585"><a href="#Generator.log_sql-2585"><span class="linenos">2585</span></a> <span class="k">def</span> <span class="nf">log_sql</span><span class="p">(</span><span class="bp">self</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">Log</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.log_sql-2586"><a href="#Generator.log_sql-2586"><span class="linenos">2586</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> -</span><span id="Generator.log_sql-2587"><a href="#Generator.log_sql-2587"><span class="linenos">2587</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> -</span><span id="Generator.log_sql-2588"><a href="#Generator.log_sql-2588"><span class="linenos">2588</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> -</span><span id="Generator.log_sql-2589"><a href="#Generator.log_sql-2589"><span class="linenos">2589</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LOG"</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.log_sql-2593"><a href="#Generator.log_sql-2593"><span class="linenos">2593</span></a> <span class="k">def</span> <span class="nf">log_sql</span><span class="p">(</span><span class="bp">self</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">Log</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.log_sql-2594"><a href="#Generator.log_sql-2594"><span class="linenos">2594</span></a> <span class="n">args</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> +</span><span id="Generator.log_sql-2595"><a href="#Generator.log_sql-2595"><span class="linenos">2595</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">LOG_BASE_FIRST</span><span class="p">:</span> +</span><span id="Generator.log_sql-2596"><a href="#Generator.log_sql-2596"><span class="linenos">2596</span></a> <span class="n">args</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span> +</span><span id="Generator.log_sql-2597"><a href="#Generator.log_sql-2597"><span class="linenos">2597</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"LOG"</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -13992,12 +14035,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.use_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.use_sql-2591"><a href="#Generator.use_sql-2591"><span class="linenos">2591</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</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">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.use_sql-2592"><a href="#Generator.use_sql-2592"><span class="linenos">2592</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.use_sql-2593"><a href="#Generator.use_sql-2593"><span class="linenos">2593</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.use_sql-2594"><a href="#Generator.use_sql-2594"><span class="linenos">2594</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.use_sql-2595"><a href="#Generator.use_sql-2595"><span class="linenos">2595</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.use_sql-2596"><a href="#Generator.use_sql-2596"><span class="linenos">2596</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.use_sql-2599"><a href="#Generator.use_sql-2599"><span class="linenos">2599</span></a> <span class="k">def</span> <span class="nf">use_sql</span><span class="p">(</span><span class="bp">self</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">Use</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.use_sql-2600"><a href="#Generator.use_sql-2600"><span class="linenos">2600</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.use_sql-2601"><a href="#Generator.use_sql-2601"><span class="linenos">2601</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.use_sql-2602"><a href="#Generator.use_sql-2602"><span class="linenos">2602</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.use_sql-2603"><a href="#Generator.use_sql-2603"><span class="linenos">2603</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.use_sql-2604"><a href="#Generator.use_sql-2604"><span class="linenos">2604</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USE</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14015,9 +14058,9 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.binary"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.binary-2598"><a href="#Generator.binary-2598"><span class="linenos">2598</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</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">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.binary-2599"><a href="#Generator.binary-2599"><span class="linenos">2599</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> -</span><span id="Generator.binary-2600"><a href="#Generator.binary-2600"><span class="linenos">2600</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.binary-2606"><a href="#Generator.binary-2606"><span class="linenos">2606</span></a> <span class="k">def</span> <span class="nf">binary</span><span class="p">(</span><span class="bp">self</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">Binary</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.binary-2607"><a href="#Generator.binary-2607"><span class="linenos">2607</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">comments</span><span class="o">=</span><span class="n">expression</span><span class="o">.</span><span class="n">comments</span><span class="p">)</span> +</span><span id="Generator.binary-2608"><a href="#Generator.binary-2608"><span class="linenos">2608</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14035,24 +14078,24 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.function_fallback_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.function_fallback_sql-2602"><a href="#Generator.function_fallback_sql-2602"><span class="linenos">2602</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</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">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2603"><a href="#Generator.function_fallback_sql-2603"><span class="linenos">2603</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.function_fallback_sql-2604"><a href="#Generator.function_fallback_sql-2604"><span class="linenos">2604</span></a> -</span><span id="Generator.function_fallback_sql-2605"><a href="#Generator.function_fallback_sql-2605"><span class="linenos">2605</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2606"><a href="#Generator.function_fallback_sql-2606"><span class="linenos">2606</span></a> <span class="n">arg_value</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="n">key</span><span class="p">)</span> -</span><span id="Generator.function_fallback_sql-2607"><a href="#Generator.function_fallback_sql-2607"><span class="linenos">2607</span></a> -</span><span id="Generator.function_fallback_sql-2608"><a href="#Generator.function_fallback_sql-2608"><span class="linenos">2608</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> -</span><span id="Generator.function_fallback_sql-2609"><a href="#Generator.function_fallback_sql-2609"><span class="linenos">2609</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2610"><a href="#Generator.function_fallback_sql-2610"><span class="linenos">2610</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> -</span><span id="Generator.function_fallback_sql-2611"><a href="#Generator.function_fallback_sql-2611"><span class="linenos">2611</span></a> <span class="k">elif</span> <span class="n">arg_value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2612"><a href="#Generator.function_fallback_sql-2612"><span class="linenos">2612</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> -</span><span id="Generator.function_fallback_sql-2613"><a href="#Generator.function_fallback_sql-2613"><span class="linenos">2613</span></a> -</span><span id="Generator.function_fallback_sql-2614"><a href="#Generator.function_fallback_sql-2614"><span class="linenos">2614</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2615"><a href="#Generator.function_fallback_sql-2615"><span class="linenos">2615</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> -</span><span id="Generator.function_fallback_sql-2616"><a href="#Generator.function_fallback_sql-2616"><span class="linenos">2616</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.function_fallback_sql-2617"><a href="#Generator.function_fallback_sql-2617"><span class="linenos">2617</span></a> <span class="n">name</span> <span class="o">=</span> <span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">_meta</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">))</span> <span class="ow">or</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> -</span><span id="Generator.function_fallback_sql-2618"><a href="#Generator.function_fallback_sql-2618"><span class="linenos">2618</span></a> -</span><span id="Generator.function_fallback_sql-2619"><a href="#Generator.function_fallback_sql-2619"><span class="linenos">2619</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.function_fallback_sql-2610"><a href="#Generator.function_fallback_sql-2610"><span class="linenos">2610</span></a> <span class="k">def</span> <span class="nf">function_fallback_sql</span><span class="p">(</span><span class="bp">self</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">Func</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2611"><a href="#Generator.function_fallback_sql-2611"><span class="linenos">2611</span></a> <span class="n">args</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.function_fallback_sql-2612"><a href="#Generator.function_fallback_sql-2612"><span class="linenos">2612</span></a> +</span><span id="Generator.function_fallback_sql-2613"><a href="#Generator.function_fallback_sql-2613"><span class="linenos">2613</span></a> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">expression</span><span class="o">.</span><span class="n">arg_types</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2614"><a href="#Generator.function_fallback_sql-2614"><span class="linenos">2614</span></a> <span class="n">arg_value</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="n">key</span><span class="p">)</span> +</span><span id="Generator.function_fallback_sql-2615"><a href="#Generator.function_fallback_sql-2615"><span class="linenos">2615</span></a> +</span><span id="Generator.function_fallback_sql-2616"><a href="#Generator.function_fallback_sql-2616"><span class="linenos">2616</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg_value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> +</span><span id="Generator.function_fallback_sql-2617"><a href="#Generator.function_fallback_sql-2617"><span class="linenos">2617</span></a> <span class="k">for</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">arg_value</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2618"><a href="#Generator.function_fallback_sql-2618"><span class="linenos">2618</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> +</span><span id="Generator.function_fallback_sql-2619"><a href="#Generator.function_fallback_sql-2619"><span class="linenos">2619</span></a> <span class="k">elif</span> <span class="n">arg_value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2620"><a href="#Generator.function_fallback_sql-2620"><span class="linenos">2620</span></a> <span class="n">args</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">arg_value</span><span class="p">)</span> +</span><span id="Generator.function_fallback_sql-2621"><a href="#Generator.function_fallback_sql-2621"><span class="linenos">2621</span></a> +</span><span id="Generator.function_fallback_sql-2622"><a href="#Generator.function_fallback_sql-2622"><span class="linenos">2622</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">normalize_functions</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2623"><a href="#Generator.function_fallback_sql-2623"><span class="linenos">2623</span></a> <span class="n">name</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> +</span><span id="Generator.function_fallback_sql-2624"><a href="#Generator.function_fallback_sql-2624"><span class="linenos">2624</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.function_fallback_sql-2625"><a href="#Generator.function_fallback_sql-2625"><span class="linenos">2625</span></a> <span class="n">name</span> <span class="o">=</span> <span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">_meta</span> <span class="ow">and</span> <span class="n">expression</span><span class="o">.</span><span class="n">meta</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">))</span> <span class="ow">or</span> <span class="n">expression</span><span class="o">.</span><span class="n">sql_name</span><span class="p">()</span> +</span><span id="Generator.function_fallback_sql-2626"><a href="#Generator.function_fallback_sql-2626"><span class="linenos">2626</span></a> +</span><span id="Generator.function_fallback_sql-2627"><a href="#Generator.function_fallback_sql-2627"><span class="linenos">2627</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -14070,14 +14113,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.func"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.func-2621"><a href="#Generator.func-2621"><span class="linenos">2621</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> -</span><span id="Generator.func-2622"><a href="#Generator.func-2622"><span class="linenos">2622</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.func-2623"><a href="#Generator.func-2623"><span class="linenos">2623</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> -</span><span id="Generator.func-2624"><a href="#Generator.func-2624"><span class="linenos">2624</span></a> <span class="o">*</span><span class="n">args</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">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> -</span><span id="Generator.func-2625"><a href="#Generator.func-2625"><span class="linenos">2625</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> -</span><span id="Generator.func-2626"><a href="#Generator.func-2626"><span class="linenos">2626</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> -</span><span id="Generator.func-2627"><a href="#Generator.func-2627"><span class="linenos">2627</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.func-2628"><a href="#Generator.func-2628"><span class="linenos">2628</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.func-2629"><a href="#Generator.func-2629"><span class="linenos">2629</span></a> <span class="k">def</span> <span class="nf">func</span><span class="p">(</span> +</span><span id="Generator.func-2630"><a href="#Generator.func-2630"><span class="linenos">2630</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.func-2631"><a href="#Generator.func-2631"><span class="linenos">2631</span></a> <span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> +</span><span id="Generator.func-2632"><a href="#Generator.func-2632"><span class="linenos">2632</span></a> <span class="o">*</span><span class="n">args</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">exp</span><span class="o">.</span><span class="n">Expression</span> <span class="o">|</span> <span class="nb">str</span><span class="p">],</span> +</span><span id="Generator.func-2633"><a href="#Generator.func-2633"><span class="linenos">2633</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"("</span><span class="p">,</span> +</span><span id="Generator.func-2634"><a href="#Generator.func-2634"><span class="linenos">2634</span></a> <span class="n">suffix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">")"</span><span class="p">,</span> +</span><span id="Generator.func-2635"><a href="#Generator.func-2635"><span class="linenos">2635</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.func-2636"><a href="#Generator.func-2636"><span class="linenos">2636</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">normalize_func</span><span class="p">(</span><span class="n">name</span><span class="p">)</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">format_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span><span class="si">}{</span><span class="n">suffix</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14095,11 +14138,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.format_args"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_args-2630"><a href="#Generator.format_args-2630"><span class="linenos">2630</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</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="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.format_args-2631"><a href="#Generator.format_args-2631"><span class="linenos">2631</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> -</span><span id="Generator.format_args-2632"><a href="#Generator.format_args-2632"><span class="linenos">2632</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> -</span><span id="Generator.format_args-2633"><a href="#Generator.format_args-2633"><span class="linenos">2633</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.format_args-2634"><a href="#Generator.format_args-2634"><span class="linenos">2634</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_args-2638"><a href="#Generator.format_args-2638"><span class="linenos">2638</span></a> <span class="k">def</span> <span class="nf">format_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</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="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">])</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.format_args-2639"><a href="#Generator.format_args-2639"><span class="linenos">2639</span></a> <span class="n">arg_sqls</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">if</span> <span class="n">arg</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> +</span><span id="Generator.format_args-2640"><a href="#Generator.format_args-2640"><span class="linenos">2640</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">text_width</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max_text_width</span><span class="p">:</span> +</span><span id="Generator.format_args-2641"><a href="#Generator.format_args-2641"><span class="linenos">2641</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="sa">f</span><span class="s2">",</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">skip_last</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.format_args-2642"><a href="#Generator.format_args-2642"><span class="linenos">2642</span></a> <span class="k">return</span> <span class="s2">", "</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">arg_sqls</span><span class="p">)</span> </span></pre></div> @@ -14117,8 +14160,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.text_width"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.text_width-2636"><a href="#Generator.text_width-2636"><span class="linenos">2636</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> -</span><span id="Generator.text_width-2637"><a href="#Generator.text_width-2637"><span class="linenos">2637</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.text_width-2644"><a href="#Generator.text_width-2644"><span class="linenos">2644</span></a> <span class="k">def</span> <span class="nf">text_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">args</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">Iterable</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span> +</span><span id="Generator.text_width-2645"><a href="#Generator.text_width-2645"><span class="linenos">2645</span></a> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">arg</span><span class="p">)</span> <span class="k">for</span> <span class="n">arg</span> <span class="ow">in</span> <span class="n">args</span><span class="p">)</span> </span></pre></div> @@ -14136,10 +14179,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.format_time"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_time-2639"><a href="#Generator.format_time-2639"><span class="linenos">2639</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> -</span><span id="Generator.format_time-2640"><a href="#Generator.format_time-2640"><span class="linenos">2640</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> -</span><span id="Generator.format_time-2641"><a href="#Generator.format_time-2641"><span class="linenos">2641</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> -</span><span id="Generator.format_time-2642"><a href="#Generator.format_time-2642"><span class="linenos">2642</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.format_time-2647"><a href="#Generator.format_time-2647"><span class="linenos">2647</span></a> <span class="k">def</span> <span class="nf">format_time</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]:</span> +</span><span id="Generator.format_time-2648"><a href="#Generator.format_time-2648"><span class="linenos">2648</span></a> <span class="k">return</span> <span class="n">format_time</span><span class="p">(</span> +</span><span id="Generator.format_time-2649"><a href="#Generator.format_time-2649"><span class="linenos">2649</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"format"</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_MAPPING</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">INVERSE_TIME_TRIE</span> +</span><span id="Generator.format_time-2650"><a href="#Generator.format_time-2650"><span class="linenos">2650</span></a> <span class="p">)</span> </span></pre></div> @@ -14157,51 +14200,51 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.expressions"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.expressions-2644"><a href="#Generator.expressions-2644"><span class="linenos">2644</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> -</span><span id="Generator.expressions-2645"><a href="#Generator.expressions-2645"><span class="linenos">2645</span></a> <span class="bp">self</span><span class="p">,</span> -</span><span id="Generator.expressions-2646"><a href="#Generator.expressions-2646"><span class="linenos">2646</span></a> <span class="n">expression</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.expressions-2647"><a href="#Generator.expressions-2647"><span class="linenos">2647</span></a> <span class="n">key</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.expressions-2648"><a href="#Generator.expressions-2648"><span class="linenos">2648</span></a> <span class="n">sqls</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">Collection</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> -</span><span id="Generator.expressions-2649"><a href="#Generator.expressions-2649"><span class="linenos">2649</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.expressions-2650"><a href="#Generator.expressions-2650"><span class="linenos">2650</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> -</span><span id="Generator.expressions-2651"><a href="#Generator.expressions-2651"><span class="linenos">2651</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.expressions-2652"><a href="#Generator.expressions-2652"><span class="linenos">2652</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> -</span><span id="Generator.expressions-2653"><a href="#Generator.expressions-2653"><span class="linenos">2653</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> -</span><span id="Generator.expressions-2654"><a href="#Generator.expressions-2654"><span class="linenos">2654</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.expressions-2655"><a href="#Generator.expressions-2655"><span class="linenos">2655</span></a> <span class="n">expressions</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="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> -</span><span id="Generator.expressions-2656"><a href="#Generator.expressions-2656"><span class="linenos">2656</span></a> -</span><span id="Generator.expressions-2657"><a href="#Generator.expressions-2657"><span class="linenos">2657</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> -</span><span id="Generator.expressions-2658"><a href="#Generator.expressions-2658"><span class="linenos">2658</span></a> <span class="k">return</span> <span class="s2">""</span> -</span><span id="Generator.expressions-2659"><a href="#Generator.expressions-2659"><span class="linenos">2659</span></a> -</span><span id="Generator.expressions-2660"><a href="#Generator.expressions-2660"><span class="linenos">2660</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator.expressions-2661"><a href="#Generator.expressions-2661"><span class="linenos">2661</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sql</span> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">sql</span><span class="p">)</span> -</span><span id="Generator.expressions-2662"><a href="#Generator.expressions-2662"><span class="linenos">2662</span></a> -</span><span id="Generator.expressions-2663"><a href="#Generator.expressions-2663"><span class="linenos">2663</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.expressions-2652"><a href="#Generator.expressions-2652"><span class="linenos">2652</span></a> <span class="k">def</span> <span class="nf">expressions</span><span class="p">(</span> +</span><span id="Generator.expressions-2653"><a href="#Generator.expressions-2653"><span class="linenos">2653</span></a> <span class="bp">self</span><span class="p">,</span> +</span><span id="Generator.expressions-2654"><a href="#Generator.expressions-2654"><span class="linenos">2654</span></a> <span class="n">expression</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">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.expressions-2655"><a href="#Generator.expressions-2655"><span class="linenos">2655</span></a> <span class="n">key</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="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.expressions-2656"><a href="#Generator.expressions-2656"><span class="linenos">2656</span></a> <span class="n">sqls</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">Collection</span><span class="p">[</span><span class="nb">str</span> <span class="o">|</span> <span class="n">exp</span><span class="o">.</span><span class="n">Expression</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> +</span><span id="Generator.expressions-2657"><a href="#Generator.expressions-2657"><span class="linenos">2657</span></a> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.expressions-2658"><a href="#Generator.expressions-2658"><span class="linenos">2658</span></a> <span class="n">indent</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span> +</span><span id="Generator.expressions-2659"><a href="#Generator.expressions-2659"><span class="linenos">2659</span></a> <span class="n">skip_first</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.expressions-2660"><a href="#Generator.expressions-2660"><span class="linenos">2660</span></a> <span class="n">sep</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">", "</span><span class="p">,</span> +</span><span id="Generator.expressions-2661"><a href="#Generator.expressions-2661"><span class="linenos">2661</span></a> <span class="n">prefix</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">""</span><span class="p">,</span> +</span><span id="Generator.expressions-2662"><a href="#Generator.expressions-2662"><span class="linenos">2662</span></a> <span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.expressions-2663"><a href="#Generator.expressions-2663"><span class="linenos">2663</span></a> <span class="n">expressions</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="n">key</span> <span class="ow">or</span> <span class="s2">"expressions"</span><span class="p">)</span> <span class="k">if</span> <span class="n">expression</span> <span class="k">else</span> <span class="n">sqls</span> </span><span id="Generator.expressions-2664"><a href="#Generator.expressions-2664"><span class="linenos">2664</span></a> -</span><span id="Generator.expressions-2665"><a href="#Generator.expressions-2665"><span class="linenos">2665</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> -</span><span id="Generator.expressions-2666"><a href="#Generator.expressions-2666"><span class="linenos">2666</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> -</span><span id="Generator.expressions-2667"><a href="#Generator.expressions-2667"><span class="linenos">2667</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> -</span><span id="Generator.expressions-2668"><a href="#Generator.expressions-2668"><span class="linenos">2668</span></a> -</span><span id="Generator.expressions-2669"><a href="#Generator.expressions-2669"><span class="linenos">2669</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> -</span><span id="Generator.expressions-2670"><a href="#Generator.expressions-2670"><span class="linenos">2670</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> -</span><span id="Generator.expressions-2671"><a href="#Generator.expressions-2671"><span class="linenos">2671</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.expressions-2672"><a href="#Generator.expressions-2672"><span class="linenos">2672</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">sql</span><span class="p">:</span> -</span><span id="Generator.expressions-2673"><a href="#Generator.expressions-2673"><span class="linenos">2673</span></a> <span class="k">continue</span> -</span><span id="Generator.expressions-2674"><a href="#Generator.expressions-2674"><span class="linenos">2674</span></a> -</span><span id="Generator.expressions-2675"><a href="#Generator.expressions-2675"><span class="linenos">2675</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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="k">else</span> <span class="s2">""</span> +</span><span id="Generator.expressions-2665"><a href="#Generator.expressions-2665"><span class="linenos">2665</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">expressions</span><span class="p">:</span> +</span><span id="Generator.expressions-2666"><a href="#Generator.expressions-2666"><span class="linenos">2666</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator.expressions-2667"><a href="#Generator.expressions-2667"><span class="linenos">2667</span></a> +</span><span id="Generator.expressions-2668"><a href="#Generator.expressions-2668"><span class="linenos">2668</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator.expressions-2669"><a href="#Generator.expressions-2669"><span class="linenos">2669</span></a> <span class="k">return</span> <span class="n">sep</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sql</span> <span class="k">for</span> <span class="n">sql</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">expressions</span><span class="p">)</span> <span class="k">if</span> <span class="n">sql</span><span class="p">)</span> +</span><span id="Generator.expressions-2670"><a href="#Generator.expressions-2670"><span class="linenos">2670</span></a> +</span><span id="Generator.expressions-2671"><a href="#Generator.expressions-2671"><span class="linenos">2671</span></a> <span class="n">num_sqls</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator.expressions-2672"><a href="#Generator.expressions-2672"><span class="linenos">2672</span></a> +</span><span id="Generator.expressions-2673"><a href="#Generator.expressions-2673"><span class="linenos">2673</span></a> <span class="c1"># These are calculated once in case we have the leading_comma / pretty option set, correspondingly</span> +</span><span id="Generator.expressions-2674"><a href="#Generator.expressions-2674"><span class="linenos">2674</span></a> <span class="n">pad</span> <span class="o">=</span> <span class="s2">" "</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">pad</span> +</span><span id="Generator.expressions-2675"><a href="#Generator.expressions-2675"><span class="linenos">2675</span></a> <span class="n">stripped_sep</span> <span class="o">=</span> <span class="n">sep</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> </span><span id="Generator.expressions-2676"><a href="#Generator.expressions-2676"><span class="linenos">2676</span></a> -</span><span id="Generator.expressions-2677"><a href="#Generator.expressions-2677"><span class="linenos">2677</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> -</span><span id="Generator.expressions-2678"><a href="#Generator.expressions-2678"><span class="linenos">2678</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> -</span><span id="Generator.expressions-2679"><a href="#Generator.expressions-2679"><span class="linenos">2679</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.expressions-2680"><a href="#Generator.expressions-2680"><span class="linenos">2680</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.expressions-2681"><a href="#Generator.expressions-2681"><span class="linenos">2681</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> -</span><span id="Generator.expressions-2682"><a href="#Generator.expressions-2682"><span class="linenos">2682</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.expressions-2683"><a href="#Generator.expressions-2683"><span class="linenos">2683</span></a> <span class="p">)</span> -</span><span id="Generator.expressions-2684"><a href="#Generator.expressions-2684"><span class="linenos">2684</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.expressions-2685"><a href="#Generator.expressions-2685"><span class="linenos">2685</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.expressions-2686"><a href="#Generator.expressions-2686"><span class="linenos">2686</span></a> -</span><span id="Generator.expressions-2687"><a href="#Generator.expressions-2687"><span class="linenos">2687</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> -</span><span id="Generator.expressions-2688"><a href="#Generator.expressions-2688"><span class="linenos">2688</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="n">skip_first</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> +</span><span id="Generator.expressions-2677"><a href="#Generator.expressions-2677"><span class="linenos">2677</span></a> <span class="n">result_sqls</span> <span class="o">=</span> <span class="p">[]</span> +</span><span id="Generator.expressions-2678"><a href="#Generator.expressions-2678"><span class="linenos">2678</span></a> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">expressions</span><span class="p">):</span> +</span><span id="Generator.expressions-2679"><a href="#Generator.expressions-2679"><span class="linenos">2679</span></a> <span class="n">sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.expressions-2680"><a href="#Generator.expressions-2680"><span class="linenos">2680</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">sql</span><span class="p">:</span> +</span><span id="Generator.expressions-2681"><a href="#Generator.expressions-2681"><span class="linenos">2681</span></a> <span class="k">continue</span> +</span><span id="Generator.expressions-2682"><a href="#Generator.expressions-2682"><span class="linenos">2682</span></a> +</span><span id="Generator.expressions-2683"><a href="#Generator.expressions-2683"><span class="linenos">2683</span></a> <span class="n">comments</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">maybe_comment</span><span class="p">(</span><span class="s2">""</span><span class="p">,</span> <span class="n">e</span><span class="p">)</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">e</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="k">else</span> <span class="s2">""</span> +</span><span id="Generator.expressions-2684"><a href="#Generator.expressions-2684"><span class="linenos">2684</span></a> +</span><span id="Generator.expressions-2685"><a href="#Generator.expressions-2685"><span class="linenos">2685</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span><span class="p">:</span> +</span><span id="Generator.expressions-2686"><a href="#Generator.expressions-2686"><span class="linenos">2686</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">leading_comma</span><span class="p">:</span> +</span><span id="Generator.expressions-2687"><a href="#Generator.expressions-2687"><span class="linenos">2687</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">></span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="n">pad</span><span class="si">}{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.expressions-2688"><a href="#Generator.expressions-2688"><span class="linenos">2688</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.expressions-2689"><a href="#Generator.expressions-2689"><span class="linenos">2689</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> +</span><span id="Generator.expressions-2690"><a href="#Generator.expressions-2690"><span class="linenos">2690</span></a> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">stripped_sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">comments</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.expressions-2691"><a href="#Generator.expressions-2691"><span class="linenos">2691</span></a> <span class="p">)</span> +</span><span id="Generator.expressions-2692"><a href="#Generator.expressions-2692"><span class="linenos">2692</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.expressions-2693"><a href="#Generator.expressions-2693"><span class="linenos">2693</span></a> <span class="n">result_sqls</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">prefix</span><span class="si">}{</span><span class="n">sql</span><span class="si">}{</span><span class="n">comments</span><span class="si">}{</span><span class="n">sep</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="n">num_sqls</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.expressions-2694"><a href="#Generator.expressions-2694"><span class="linenos">2694</span></a> +</span><span id="Generator.expressions-2695"><a href="#Generator.expressions-2695"><span class="linenos">2695</span></a> <span class="n">result_sql</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pretty</span> <span class="k">else</span> <span class="s2">""</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">result_sqls</span><span class="p">)</span> +</span><span id="Generator.expressions-2696"><a href="#Generator.expressions-2696"><span class="linenos">2696</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">indent</span><span class="p">(</span><span class="n">result_sql</span><span class="p">,</span> <span class="n">skip_first</span><span class="o">=</span><span class="n">skip_first</span><span class="p">)</span> <span class="k">if</span> <span class="n">indent</span> <span class="k">else</span> <span class="n">result_sql</span> </span></pre></div> @@ -14219,12 +14262,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.op_expressions"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.op_expressions-2690"><a href="#Generator.op_expressions-2690"><span class="linenos">2690</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</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">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.op_expressions-2691"><a href="#Generator.op_expressions-2691"><span class="linenos">2691</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> -</span><span id="Generator.op_expressions-2692"><a href="#Generator.op_expressions-2692"><span class="linenos">2692</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> -</span><span id="Generator.op_expressions-2693"><a href="#Generator.op_expressions-2693"><span class="linenos">2693</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> -</span><span id="Generator.op_expressions-2694"><a href="#Generator.op_expressions-2694"><span class="linenos">2694</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.op_expressions-2695"><a href="#Generator.op_expressions-2695"><span class="linenos">2695</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.op_expressions-2698"><a href="#Generator.op_expressions-2698"><span class="linenos">2698</span></a> <span class="k">def</span> <span class="nf">op_expressions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</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">Expression</span><span class="p">,</span> <span class="n">flat</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.op_expressions-2699"><a href="#Generator.op_expressions-2699"><span class="linenos">2699</span></a> <span class="n">flat</span> <span class="o">=</span> <span class="n">flat</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">parent</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="p">)</span> +</span><span id="Generator.op_expressions-2700"><a href="#Generator.op_expressions-2700"><span class="linenos">2700</span></a> <span class="n">expressions_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="n">flat</span><span class="p">)</span> +</span><span id="Generator.op_expressions-2701"><a href="#Generator.op_expressions-2701"><span class="linenos">2701</span></a> <span class="k">if</span> <span class="n">flat</span><span class="p">:</span> +</span><span id="Generator.op_expressions-2702"><a href="#Generator.op_expressions-2702"><span class="linenos">2702</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">op</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.op_expressions-2703"><a href="#Generator.op_expressions-2703"><span class="linenos">2703</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="w"> </span><span class="k">if</span><span class="w"> </span><span class="n">expressions_sql</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">''</span><span class="si">}{</span><span class="n">expressions_sql</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14242,11 +14285,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.naked_property"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.naked_property-2697"><a href="#Generator.naked_property-2697"><span class="linenos">2697</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</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">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.naked_property-2698"><a href="#Generator.naked_property-2698"><span class="linenos">2698</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> -</span><span id="Generator.naked_property-2699"><a href="#Generator.naked_property-2699"><span class="linenos">2699</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> -</span><span id="Generator.naked_property-2700"><a href="#Generator.naked_property-2700"><span class="linenos">2700</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> -</span><span id="Generator.naked_property-2701"><a href="#Generator.naked_property-2701"><span class="linenos">2701</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.naked_property-2705"><a href="#Generator.naked_property-2705"><span class="linenos">2705</span></a> <span class="k">def</span> <span class="nf">naked_property</span><span class="p">(</span><span class="bp">self</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">Property</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.naked_property-2706"><a href="#Generator.naked_property-2706"><span class="linenos">2706</span></a> <span class="n">property_name</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Properties</span><span class="o">.</span><span class="n">PROPERTY_TO_NAME</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="p">)</span> +</span><span id="Generator.naked_property-2707"><a href="#Generator.naked_property-2707"><span class="linenos">2707</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">property_name</span><span class="p">:</span> +</span><span id="Generator.naked_property-2708"><a href="#Generator.naked_property-2708"><span class="linenos">2708</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Unsupported property </span><span class="si">{</span><span class="n">expression</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span> +</span><span id="Generator.naked_property-2709"><a href="#Generator.naked_property-2709"><span class="linenos">2709</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">property_name</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14264,12 +14307,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.set_operation"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_operation-2703"><a href="#Generator.set_operation-2703"><span class="linenos">2703</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.set_operation-2704"><a href="#Generator.set_operation-2704"><span class="linenos">2704</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.set_operation-2705"><a href="#Generator.set_operation-2705"><span class="linenos">2705</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> -</span><span id="Generator.set_operation-2706"><a href="#Generator.set_operation-2706"><span class="linenos">2706</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> -</span><span id="Generator.set_operation-2707"><a href="#Generator.set_operation-2707"><span class="linenos">2707</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.set_operation-2708"><a href="#Generator.set_operation-2708"><span class="linenos">2708</span></a> <span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.set_operation-2711"><a href="#Generator.set_operation-2711"><span class="linenos">2711</span></a> <span class="k">def</span> <span class="nf">set_operation</span><span class="p">(</span><span class="bp">self</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">Expression</span><span class="p">,</span> <span class="n">op</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.set_operation-2712"><a href="#Generator.set_operation-2712"><span class="linenos">2712</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.set_operation-2713"><a href="#Generator.set_operation-2713"><span class="linenos">2713</span></a> <span class="n">op</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="n">op</span><span class="p">)</span> +</span><span id="Generator.set_operation-2714"><a href="#Generator.set_operation-2714"><span class="linenos">2714</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">query_modifiers</span><span class="p">(</span> +</span><span id="Generator.set_operation-2715"><a href="#Generator.set_operation-2715"><span class="linenos">2715</span></a> <span class="n">expression</span><span class="p">,</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">op</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">()</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.set_operation-2716"><a href="#Generator.set_operation-2716"><span class="linenos">2716</span></a> <span class="p">)</span> </span></pre></div> @@ -14287,8 +14330,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.tag_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tag_sql-2710"><a href="#Generator.tag_sql-2710"><span class="linenos">2710</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</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">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tag_sql-2711"><a href="#Generator.tag_sql-2711"><span class="linenos">2711</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</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="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</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="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tag_sql-2718"><a href="#Generator.tag_sql-2718"><span class="linenos">2718</span></a> <span class="k">def</span> <span class="nf">tag_sql</span><span class="p">(</span><span class="bp">self</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">Tag</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tag_sql-2719"><a href="#Generator.tag_sql-2719"><span class="linenos">2719</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</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="s1">'prefix'</span><span class="p">)</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">)</span><span class="si">}{</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="s1">'postfix'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14306,8 +14349,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.token_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.token_sql-2713"><a href="#Generator.token_sql-2713"><span class="linenos">2713</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.token_sql-2714"><a href="#Generator.token_sql-2714"><span class="linenos">2714</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.token_sql-2721"><a href="#Generator.token_sql-2721"><span class="linenos">2721</span></a> <span class="k">def</span> <span class="nf">token_sql</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">token_type</span><span class="p">:</span> <span class="n">TokenType</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.token_sql-2722"><a href="#Generator.token_sql-2722"><span class="linenos">2722</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">TOKEN_MAPPING</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">token_type</span><span class="p">,</span> <span class="n">token_type</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> </span></pre></div> @@ -14325,13 +14368,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.userdefinedfunction_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.userdefinedfunction_sql-2716"><a href="#Generator.userdefinedfunction_sql-2716"><span class="linenos">2716</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</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">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.userdefinedfunction_sql-2717"><a href="#Generator.userdefinedfunction_sql-2717"><span class="linenos">2717</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.userdefinedfunction_sql-2718"><a href="#Generator.userdefinedfunction_sql-2718"><span class="linenos">2718</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.userdefinedfunction_sql-2719"><a href="#Generator.userdefinedfunction_sql-2719"><span class="linenos">2719</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> -</span><span id="Generator.userdefinedfunction_sql-2720"><a href="#Generator.userdefinedfunction_sql-2720"><span class="linenos">2720</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</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">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.userdefinedfunction_sql-2721"><a href="#Generator.userdefinedfunction_sql-2721"><span class="linenos">2721</span></a> <span class="p">)</span> -</span><span id="Generator.userdefinedfunction_sql-2722"><a href="#Generator.userdefinedfunction_sql-2722"><span class="linenos">2722</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.userdefinedfunction_sql-2724"><a href="#Generator.userdefinedfunction_sql-2724"><span class="linenos">2724</span></a> <span class="k">def</span> <span class="nf">userdefinedfunction_sql</span><span class="p">(</span><span class="bp">self</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">UserDefinedFunction</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.userdefinedfunction_sql-2725"><a href="#Generator.userdefinedfunction_sql-2725"><span class="linenos">2725</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.userdefinedfunction_sql-2726"><a href="#Generator.userdefinedfunction_sql-2726"><span class="linenos">2726</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">no_identify</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">,</span> <span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.userdefinedfunction_sql-2727"><a href="#Generator.userdefinedfunction_sql-2727"><span class="linenos">2727</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="p">(</span> +</span><span id="Generator.userdefinedfunction_sql-2728"><a href="#Generator.userdefinedfunction_sql-2728"><span class="linenos">2728</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">wrap</span><span class="p">(</span><span class="n">expressions</span><span class="p">)</span> <span class="k">if</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">"wrapped"</span><span class="p">)</span> <span class="k">else</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.userdefinedfunction_sql-2729"><a href="#Generator.userdefinedfunction_sql-2729"><span class="linenos">2729</span></a> <span class="p">)</span> +</span><span id="Generator.userdefinedfunction_sql-2730"><a href="#Generator.userdefinedfunction_sql-2730"><span class="linenos">2730</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14349,10 +14392,10 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.joinhint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.joinhint_sql-2724"><a href="#Generator.joinhint_sql-2724"><span class="linenos">2724</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</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">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.joinhint_sql-2725"><a href="#Generator.joinhint_sql-2725"><span class="linenos">2725</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.joinhint_sql-2726"><a href="#Generator.joinhint_sql-2726"><span class="linenos">2726</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.joinhint_sql-2727"><a href="#Generator.joinhint_sql-2727"><span class="linenos">2727</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.joinhint_sql-2732"><a href="#Generator.joinhint_sql-2732"><span class="linenos">2732</span></a> <span class="k">def</span> <span class="nf">joinhint_sql</span><span class="p">(</span><span class="bp">self</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">JoinHint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.joinhint_sql-2733"><a href="#Generator.joinhint_sql-2733"><span class="linenos">2733</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.joinhint_sql-2734"><a href="#Generator.joinhint_sql-2734"><span class="linenos">2734</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.joinhint_sql-2735"><a href="#Generator.joinhint_sql-2735"><span class="linenos">2735</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -14370,8 +14413,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.kwarg_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.kwarg_sql-2729"><a href="#Generator.kwarg_sql-2729"><span class="linenos">2729</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</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">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.kwarg_sql-2730"><a href="#Generator.kwarg_sql-2730"><span class="linenos">2730</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.kwarg_sql-2737"><a href="#Generator.kwarg_sql-2737"><span class="linenos">2737</span></a> <span class="k">def</span> <span class="nf">kwarg_sql</span><span class="p">(</span><span class="bp">self</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">Kwarg</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.kwarg_sql-2738"><a href="#Generator.kwarg_sql-2738"><span class="linenos">2738</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">binary</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"=>"</span><span class="p">)</span> </span></pre></div> @@ -14389,25 +14432,25 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.when_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.when_sql-2732"><a href="#Generator.when_sql-2732"><span class="linenos">2732</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</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">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.when_sql-2733"><a href="#Generator.when_sql-2733"><span class="linenos">2733</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> -</span><span id="Generator.when_sql-2734"><a href="#Generator.when_sql-2734"><span class="linenos">2734</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</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">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.when_sql-2735"><a href="#Generator.when_sql-2735"><span class="linenos">2735</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="Generator.when_sql-2736"><a href="#Generator.when_sql-2736"><span class="linenos">2736</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.when_sql-2737"><a href="#Generator.when_sql-2737"><span class="linenos">2737</span></a> -</span><span id="Generator.when_sql-2738"><a href="#Generator.when_sql-2738"><span class="linenos">2738</span></a> <span class="n">then_expression</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">"then"</span><span class="p">)</span> -</span><span id="Generator.when_sql-2739"><a href="#Generator.when_sql-2739"><span class="linenos">2739</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> -</span><span id="Generator.when_sql-2740"><a href="#Generator.when_sql-2740"><span class="linenos">2740</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.when_sql-2741"><a href="#Generator.when_sql-2741"><span class="linenos">2741</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> -</span><span id="Generator.when_sql-2742"><a href="#Generator.when_sql-2742"><span class="linenos">2742</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.when_sql-2743"><a href="#Generator.when_sql-2743"><span class="linenos">2743</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> -</span><span id="Generator.when_sql-2744"><a href="#Generator.when_sql-2744"><span class="linenos">2744</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_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">"expressions"</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="Generator.when_sql-2745"><a href="#Generator.when_sql-2745"><span class="linenos">2745</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.when_sql-2746"><a href="#Generator.when_sql-2746"><span class="linenos">2746</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.when_sql-2747"><a href="#Generator.when_sql-2747"><span class="linenos">2747</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.when_sql-2748"><a href="#Generator.when_sql-2748"><span class="linenos">2748</span></a> <span class="k">else</span><span class="p">:</span> -</span><span id="Generator.when_sql-2749"><a href="#Generator.when_sql-2749"><span class="linenos">2749</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> -</span><span id="Generator.when_sql-2750"><a href="#Generator.when_sql-2750"><span class="linenos">2750</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.when_sql-2740"><a href="#Generator.when_sql-2740"><span class="linenos">2740</span></a> <span class="k">def</span> <span class="nf">when_sql</span><span class="p">(</span><span class="bp">self</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">When</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.when_sql-2741"><a href="#Generator.when_sql-2741"><span class="linenos">2741</span></a> <span class="n">matched</span> <span class="o">=</span> <span class="s2">"MATCHED"</span> <span class="k">if</span> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"matched"</span><span class="p">]</span> <span class="k">else</span> <span class="s2">"NOT MATCHED"</span> +</span><span id="Generator.when_sql-2742"><a href="#Generator.when_sql-2742"><span class="linenos">2742</span></a> <span class="n">source</span> <span class="o">=</span> <span class="s2">" BY SOURCE"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">MATCHED_BY_SOURCE</span> <span class="ow">and</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">"source"</span><span class="p">)</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.when_sql-2743"><a href="#Generator.when_sql-2743"><span class="linenos">2743</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="Generator.when_sql-2744"><a href="#Generator.when_sql-2744"><span class="linenos">2744</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AND </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.when_sql-2745"><a href="#Generator.when_sql-2745"><span class="linenos">2745</span></a> +</span><span id="Generator.when_sql-2746"><a href="#Generator.when_sql-2746"><span class="linenos">2746</span></a> <span class="n">then_expression</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">"then"</span><span class="p">)</span> +</span><span id="Generator.when_sql-2747"><a href="#Generator.when_sql-2747"><span class="linenos">2747</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Insert</span><span class="p">):</span> +</span><span id="Generator.when_sql-2748"><a href="#Generator.when_sql-2748"><span class="linenos">2748</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"INSERT </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.when_sql-2749"><a href="#Generator.when_sql-2749"><span class="linenos">2749</span></a> <span class="k">if</span> <span class="s2">"expression"</span> <span class="ow">in</span> <span class="n">then_expression</span><span class="o">.</span><span class="n">args</span><span class="p">:</span> +</span><span id="Generator.when_sql-2750"><a href="#Generator.when_sql-2750"><span class="linenos">2750</span></a> <span class="n">then</span> <span class="o">+=</span> <span class="sa">f</span><span class="s2">" VALUES </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.when_sql-2751"><a href="#Generator.when_sql-2751"><span class="linenos">2751</span></a> <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span> <span class="n">exp</span><span class="o">.</span><span class="n">Update</span><span class="p">):</span> +</span><span id="Generator.when_sql-2752"><a href="#Generator.when_sql-2752"><span class="linenos">2752</span></a> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">then_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">"expressions"</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="Generator.when_sql-2753"><a href="#Generator.when_sql-2753"><span class="linenos">2753</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expressions'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.when_sql-2754"><a href="#Generator.when_sql-2754"><span class="linenos">2754</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.when_sql-2755"><a href="#Generator.when_sql-2755"><span class="linenos">2755</span></a> <span class="n">then</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"UPDATE SET </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">then_expression</span><span class="p">,</span><span class="w"> </span><span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.when_sql-2756"><a href="#Generator.when_sql-2756"><span class="linenos">2756</span></a> <span class="k">else</span><span class="p">:</span> +</span><span id="Generator.when_sql-2757"><a href="#Generator.when_sql-2757"><span class="linenos">2757</span></a> <span class="n">then</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">then_expression</span><span class="p">)</span> +</span><span id="Generator.when_sql-2758"><a href="#Generator.when_sql-2758"><span class="linenos">2758</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WHEN </span><span class="si">{</span><span class="n">matched</span><span class="si">}{</span><span class="n">source</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2"> THEN </span><span class="si">{</span><span class="n">then</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14425,22 +14468,22 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.merge_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.merge_sql-2752"><a href="#Generator.merge_sql-2752"><span class="linenos">2752</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</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">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.merge_sql-2753"><a href="#Generator.merge_sql-2753"><span class="linenos">2753</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> -</span><span id="Generator.merge_sql-2754"><a href="#Generator.merge_sql-2754"><span class="linenos">2754</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> -</span><span id="Generator.merge_sql-2755"><a href="#Generator.merge_sql-2755"><span class="linenos">2755</span></a> -</span><span id="Generator.merge_sql-2756"><a href="#Generator.merge_sql-2756"><span class="linenos">2756</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="n">table</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">"hints"</span><span class="p">)</span> -</span><span id="Generator.merge_sql-2757"><a href="#Generator.merge_sql-2757"><span class="linenos">2757</span></a> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="n">table</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">hints</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">):</span> -</span><span id="Generator.merge_sql-2758"><a href="#Generator.merge_sql-2758"><span class="linenos">2758</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> -</span><span id="Generator.merge_sql-2759"><a href="#Generator.merge_sql-2759"><span class="linenos">2759</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> -</span><span id="Generator.merge_sql-2760"><a href="#Generator.merge_sql-2760"><span class="linenos">2760</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'alias'</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">())</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.merge_sql-2761"><a href="#Generator.merge_sql-2761"><span class="linenos">2761</span></a> -</span><span id="Generator.merge_sql-2762"><a href="#Generator.merge_sql-2762"><span class="linenos">2762</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> -</span><span id="Generator.merge_sql-2763"><a href="#Generator.merge_sql-2763"><span class="linenos">2763</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.merge_sql-2764"><a href="#Generator.merge_sql-2764"><span class="linenos">2764</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.merge_sql-2765"><a href="#Generator.merge_sql-2765"><span class="linenos">2765</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.merge_sql-2766"><a href="#Generator.merge_sql-2766"><span class="linenos">2766</span></a> -</span><span id="Generator.merge_sql-2767"><a href="#Generator.merge_sql-2767"><span class="linenos">2767</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">table_alias</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.merge_sql-2760"><a href="#Generator.merge_sql-2760"><span class="linenos">2760</span></a> <span class="k">def</span> <span class="nf">merge_sql</span><span class="p">(</span><span class="bp">self</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">Merge</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.merge_sql-2761"><a href="#Generator.merge_sql-2761"><span class="linenos">2761</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">expression</span><span class="o">.</span><span class="n">this</span> +</span><span id="Generator.merge_sql-2762"><a href="#Generator.merge_sql-2762"><span class="linenos">2762</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="s2">""</span> +</span><span id="Generator.merge_sql-2763"><a href="#Generator.merge_sql-2763"><span class="linenos">2763</span></a> +</span><span id="Generator.merge_sql-2764"><a href="#Generator.merge_sql-2764"><span class="linenos">2764</span></a> <span class="n">hints</span> <span class="o">=</span> <span class="n">table</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">"hints"</span><span class="p">)</span> +</span><span id="Generator.merge_sql-2765"><a href="#Generator.merge_sql-2765"><span class="linenos">2765</span></a> <span class="k">if</span> <span class="n">hints</span> <span class="ow">and</span> <span class="n">table</span><span class="o">.</span><span class="n">alias</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">hints</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">exp</span><span class="o">.</span><span class="n">WithTableHint</span><span class="p">):</span> +</span><span id="Generator.merge_sql-2766"><a href="#Generator.merge_sql-2766"><span class="linenos">2766</span></a> <span class="c1"># T-SQL syntax is MERGE ... <target_table> [WITH (<merge_hint>)] [[AS] table_alias]</span> +</span><span id="Generator.merge_sql-2767"><a href="#Generator.merge_sql-2767"><span class="linenos">2767</span></a> <span class="n">table</span> <span class="o">=</span> <span class="n">table</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span> +</span><span id="Generator.merge_sql-2768"><a href="#Generator.merge_sql-2768"><span class="linenos">2768</span></a> <span class="n">table_alias</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">'alias'</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">())</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.merge_sql-2769"><a href="#Generator.merge_sql-2769"><span class="linenos">2769</span></a> +</span><span id="Generator.merge_sql-2770"><a href="#Generator.merge_sql-2770"><span class="linenos">2770</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">table</span><span class="p">)</span> +</span><span id="Generator.merge_sql-2771"><a href="#Generator.merge_sql-2771"><span class="linenos">2771</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'using'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.merge_sql-2772"><a href="#Generator.merge_sql-2772"><span class="linenos">2772</span></a> <span class="n">on</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"ON </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'on'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.merge_sql-2773"><a href="#Generator.merge_sql-2773"><span class="linenos">2773</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.merge_sql-2774"><a href="#Generator.merge_sql-2774"><span class="linenos">2774</span></a> +</span><span id="Generator.merge_sql-2775"><a href="#Generator.merge_sql-2775"><span class="linenos">2775</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"MERGE INTO </span><span class="si">{</span><span class="n">this</span><span class="si">}{</span><span class="n">table_alias</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">on</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14458,11 +14501,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.tochar_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tochar_sql-2769"><a href="#Generator.tochar_sql-2769"><span class="linenos">2769</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</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">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.tochar_sql-2770"><a href="#Generator.tochar_sql-2770"><span class="linenos">2770</span></a> <span class="k">if</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">"format"</span><span class="p">):</span> -</span><span id="Generator.tochar_sql-2771"><a href="#Generator.tochar_sql-2771"><span class="linenos">2771</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> -</span><span id="Generator.tochar_sql-2772"><a href="#Generator.tochar_sql-2772"><span class="linenos">2772</span></a> -</span><span id="Generator.tochar_sql-2773"><a href="#Generator.tochar_sql-2773"><span class="linenos">2773</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.tochar_sql-2777"><a href="#Generator.tochar_sql-2777"><span class="linenos">2777</span></a> <span class="k">def</span> <span class="nf">tochar_sql</span><span class="p">(</span><span class="bp">self</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">ToChar</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.tochar_sql-2778"><a href="#Generator.tochar_sql-2778"><span class="linenos">2778</span></a> <span class="k">if</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">"format"</span><span class="p">):</span> +</span><span id="Generator.tochar_sql-2779"><a href="#Generator.tochar_sql-2779"><span class="linenos">2779</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Format argument unsupported for TO_CHAR/TO_VARCHAR function"</span><span class="p">)</span> +</span><span id="Generator.tochar_sql-2780"><a href="#Generator.tochar_sql-2780"><span class="linenos">2780</span></a> +</span><span id="Generator.tochar_sql-2781"><a href="#Generator.tochar_sql-2781"><span class="linenos">2781</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">cast</span><span class="p">(</span><span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="p">,</span> <span class="s2">"text"</span><span class="p">))</span> </span></pre></div> @@ -14480,12 +14523,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dictproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictproperty_sql-2775"><a href="#Generator.dictproperty_sql-2775"><span class="linenos">2775</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dictproperty_sql-2776"><a href="#Generator.dictproperty_sql-2776"><span class="linenos">2776</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.dictproperty_sql-2777"><a href="#Generator.dictproperty_sql-2777"><span class="linenos">2777</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.dictproperty_sql-2778"><a href="#Generator.dictproperty_sql-2778"><span class="linenos">2778</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.dictproperty_sql-2779"><a href="#Generator.dictproperty_sql-2779"><span class="linenos">2779</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> -</span><span id="Generator.dictproperty_sql-2780"><a href="#Generator.dictproperty_sql-2780"><span class="linenos">2780</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictproperty_sql-2783"><a href="#Generator.dictproperty_sql-2783"><span class="linenos">2783</span></a> <span class="k">def</span> <span class="nf">dictproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dictproperty_sql-2784"><a href="#Generator.dictproperty_sql-2784"><span class="linenos">2784</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.dictproperty_sql-2785"><a href="#Generator.dictproperty_sql-2785"><span class="linenos">2785</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.dictproperty_sql-2786"><a href="#Generator.dictproperty_sql-2786"><span class="linenos">2786</span></a> <span class="n">settings_sql</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"settings"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.dictproperty_sql-2787"><a href="#Generator.dictproperty_sql-2787"><span class="linenos">2787</span></a> <span class="n">args</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sep</span><span class="p">(</span><span class="s1">''</span><span class="p">)</span><span class="si">}{</span><span class="n">settings_sql</span><span class="si">}{</span><span class="bp">self</span><span class="o">.</span><span class="n">seg</span><span class="p">(</span><span class="s1">')'</span><span class="p">,</span><span class="w"> </span><span class="n">sep</span><span class="o">=</span><span class="s1">''</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">settings_sql</span> <span class="k">else</span> <span class="s2">"()"</span> +</span><span id="Generator.dictproperty_sql-2788"><a href="#Generator.dictproperty_sql-2788"><span class="linenos">2788</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">args</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -14503,11 +14546,11 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dictrange_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictrange_sql-2782"><a href="#Generator.dictrange_sql-2782"><span class="linenos">2782</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</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">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dictrange_sql-2783"><a href="#Generator.dictrange_sql-2783"><span class="linenos">2783</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.dictrange_sql-2784"><a href="#Generator.dictrange_sql-2784"><span class="linenos">2784</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> -</span><span id="Generator.dictrange_sql-2785"><a href="#Generator.dictrange_sql-2785"><span class="linenos">2785</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> -</span><span id="Generator.dictrange_sql-2786"><a href="#Generator.dictrange_sql-2786"><span class="linenos">2786</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictrange_sql-2790"><a href="#Generator.dictrange_sql-2790"><span class="linenos">2790</span></a> <span class="k">def</span> <span class="nf">dictrange_sql</span><span class="p">(</span><span class="bp">self</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">DictRange</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dictrange_sql-2791"><a href="#Generator.dictrange_sql-2791"><span class="linenos">2791</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.dictrange_sql-2792"><a href="#Generator.dictrange_sql-2792"><span class="linenos">2792</span></a> <span class="nb">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"max"</span><span class="p">)</span> +</span><span id="Generator.dictrange_sql-2793"><a href="#Generator.dictrange_sql-2793"><span class="linenos">2793</span></a> <span class="nb">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"min"</span><span class="p">)</span> +</span><span id="Generator.dictrange_sql-2794"><a href="#Generator.dictrange_sql-2794"><span class="linenos">2794</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">(MIN </span><span class="si">{</span><span class="nb">min</span><span class="si">}</span><span class="s2"> MAX </span><span class="si">{</span><span class="nb">max</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -14525,8 +14568,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.dictsubproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictsubproperty_sql-2788"><a href="#Generator.dictsubproperty_sql-2788"><span class="linenos">2788</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.dictsubproperty_sql-2789"><a href="#Generator.dictsubproperty_sql-2789"><span class="linenos">2789</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.dictsubproperty_sql-2796"><a href="#Generator.dictsubproperty_sql-2796"><span class="linenos">2796</span></a> <span class="k">def</span> <span class="nf">dictsubproperty_sql</span><span class="p">(</span><span class="bp">self</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">DictSubProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.dictsubproperty_sql-2797"><a href="#Generator.dictsubproperty_sql-2797"><span class="linenos">2797</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'value'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14544,8 +14587,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.oncluster_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.oncluster_sql-2791"><a href="#Generator.oncluster_sql-2791"><span class="linenos">2791</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</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">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.oncluster_sql-2792"><a href="#Generator.oncluster_sql-2792"><span class="linenos">2792</span></a> <span class="k">return</span> <span class="s2">""</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.oncluster_sql-2799"><a href="#Generator.oncluster_sql-2799"><span class="linenos">2799</span></a> <span class="k">def</span> <span class="nf">oncluster_sql</span><span class="p">(</span><span class="bp">self</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">OnCluster</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.oncluster_sql-2800"><a href="#Generator.oncluster_sql-2800"><span class="linenos">2800</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -14563,12 +14606,12 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.clusteredbyproperty_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.clusteredbyproperty_sql-2794"><a href="#Generator.clusteredbyproperty_sql-2794"><span class="linenos">2794</span></a> <span class="k">def</span> <span class="nf">clusteredbyproperty_sql</span><span class="p">(</span><span class="bp">self</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">ClusteredByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.clusteredbyproperty_sql-2795"><a href="#Generator.clusteredbyproperty_sql-2795"><span class="linenos">2795</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.clusteredbyproperty_sql-2796"><a href="#Generator.clusteredbyproperty_sql-2796"><span class="linenos">2796</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"sorted_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> -</span><span id="Generator.clusteredbyproperty_sql-2797"><a href="#Generator.clusteredbyproperty_sql-2797"><span class="linenos">2797</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SORTED BY (</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">sorted_by</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.clusteredbyproperty_sql-2798"><a href="#Generator.clusteredbyproperty_sql-2798"><span class="linenos">2798</span></a> <span class="n">buckets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"buckets"</span><span class="p">)</span> -</span><span id="Generator.clusteredbyproperty_sql-2799"><a href="#Generator.clusteredbyproperty_sql-2799"><span class="linenos">2799</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLUSTERED BY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2"> INTO </span><span class="si">{</span><span class="n">buckets</span><span class="si">}</span><span class="s2"> BUCKETS"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.clusteredbyproperty_sql-2802"><a href="#Generator.clusteredbyproperty_sql-2802"><span class="linenos">2802</span></a> <span class="k">def</span> <span class="nf">clusteredbyproperty_sql</span><span class="p">(</span><span class="bp">self</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">ClusteredByProperty</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.clusteredbyproperty_sql-2803"><a href="#Generator.clusteredbyproperty_sql-2803"><span class="linenos">2803</span></a> <span class="n">expressions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"expressions"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.clusteredbyproperty_sql-2804"><a href="#Generator.clusteredbyproperty_sql-2804"><span class="linenos">2804</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"sorted_by"</span><span class="p">,</span> <span class="n">flat</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> +</span><span id="Generator.clusteredbyproperty_sql-2805"><a href="#Generator.clusteredbyproperty_sql-2805"><span class="linenos">2805</span></a> <span class="n">sorted_by</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" SORTED BY (</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2">)"</span> <span class="k">if</span> <span class="n">sorted_by</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.clusteredbyproperty_sql-2806"><a href="#Generator.clusteredbyproperty_sql-2806"><span class="linenos">2806</span></a> <span class="n">buckets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"buckets"</span><span class="p">)</span> +</span><span id="Generator.clusteredbyproperty_sql-2807"><a href="#Generator.clusteredbyproperty_sql-2807"><span class="linenos">2807</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"CLUSTERED BY (</span><span class="si">{</span><span class="n">expressions</span><span class="si">}</span><span class="s2">)</span><span class="si">{</span><span class="n">sorted_by</span><span class="si">}</span><span class="s2"> INTO </span><span class="si">{</span><span class="n">buckets</span><span class="si">}</span><span class="s2"> BUCKETS"</span> </span></pre></div> @@ -14586,14 +14629,14 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.anyvalue_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.anyvalue_sql-2801"><a href="#Generator.anyvalue_sql-2801"><span class="linenos">2801</span></a> <span class="k">def</span> <span class="nf">anyvalue_sql</span><span class="p">(</span><span class="bp">self</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">AnyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.anyvalue_sql-2802"><a href="#Generator.anyvalue_sql-2802"><span class="linenos">2802</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.anyvalue_sql-2803"><a href="#Generator.anyvalue_sql-2803"><span class="linenos">2803</span></a> <span class="n">having</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">)</span> -</span><span id="Generator.anyvalue_sql-2804"><a href="#Generator.anyvalue_sql-2804"><span class="linenos">2804</span></a> -</span><span id="Generator.anyvalue_sql-2805"><a href="#Generator.anyvalue_sql-2805"><span class="linenos">2805</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> -</span><span id="Generator.anyvalue_sql-2806"><a href="#Generator.anyvalue_sql-2806"><span class="linenos">2806</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> HAVING </span><span class="si">{</span><span class="s1">'MAX'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="s1">'max'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'MIN'</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">having</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.anyvalue_sql-2807"><a href="#Generator.anyvalue_sql-2807"><span class="linenos">2807</span></a> -</span><span id="Generator.anyvalue_sql-2808"><a href="#Generator.anyvalue_sql-2808"><span class="linenos">2808</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ANY_VALUE"</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.anyvalue_sql-2809"><a href="#Generator.anyvalue_sql-2809"><span class="linenos">2809</span></a> <span class="k">def</span> <span class="nf">anyvalue_sql</span><span class="p">(</span><span class="bp">self</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">AnyValue</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.anyvalue_sql-2810"><a href="#Generator.anyvalue_sql-2810"><span class="linenos">2810</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.anyvalue_sql-2811"><a href="#Generator.anyvalue_sql-2811"><span class="linenos">2811</span></a> <span class="n">having</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"having"</span><span class="p">)</span> +</span><span id="Generator.anyvalue_sql-2812"><a href="#Generator.anyvalue_sql-2812"><span class="linenos">2812</span></a> +</span><span id="Generator.anyvalue_sql-2813"><a href="#Generator.anyvalue_sql-2813"><span class="linenos">2813</span></a> <span class="k">if</span> <span class="n">having</span><span class="p">:</span> +</span><span id="Generator.anyvalue_sql-2814"><a href="#Generator.anyvalue_sql-2814"><span class="linenos">2814</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> HAVING </span><span class="si">{</span><span class="s1">'MAX'</span><span class="w"> </span><span class="k">if</span><span class="w"> </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="s1">'max'</span><span class="p">)</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="s1">'MIN'</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="n">having</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.anyvalue_sql-2815"><a href="#Generator.anyvalue_sql-2815"><span class="linenos">2815</span></a> +</span><span id="Generator.anyvalue_sql-2816"><a href="#Generator.anyvalue_sql-2816"><span class="linenos">2816</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"ANY_VALUE"</span><span class="p">,</span> <span class="n">this</span><span class="p">)</span> </span></pre></div> @@ -14611,20 +14654,20 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.querytransform_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.querytransform_sql-2810"><a href="#Generator.querytransform_sql-2810"><span class="linenos">2810</span></a> <span class="k">def</span> <span class="nf">querytransform_sql</span><span class="p">(</span><span class="bp">self</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">QueryTransform</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.querytransform_sql-2811"><a href="#Generator.querytransform_sql-2811"><span class="linenos">2811</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRANSFORM"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> -</span><span id="Generator.querytransform_sql-2812"><a href="#Generator.querytransform_sql-2812"><span class="linenos">2812</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_before"</span><span class="p">)</span> -</span><span id="Generator.querytransform_sql-2813"><a href="#Generator.querytransform_sql-2813"><span class="linenos">2813</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_before</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_before</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.querytransform_sql-2814"><a href="#Generator.querytransform_sql-2814"><span class="linenos">2814</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_writer"</span><span class="p">)</span> -</span><span id="Generator.querytransform_sql-2815"><a href="#Generator.querytransform_sql-2815"><span class="linenos">2815</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDWRITER </span><span class="si">{</span><span class="n">record_writer</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_writer</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.querytransform_sql-2816"><a href="#Generator.querytransform_sql-2816"><span class="linenos">2816</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'command_script'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.querytransform_sql-2817"><a href="#Generator.querytransform_sql-2817"><span class="linenos">2817</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> -</span><span id="Generator.querytransform_sql-2818"><a href="#Generator.querytransform_sql-2818"><span class="linenos">2818</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.querytransform_sql-2819"><a href="#Generator.querytransform_sql-2819"><span class="linenos">2819</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_after"</span><span class="p">)</span> -</span><span id="Generator.querytransform_sql-2820"><a href="#Generator.querytransform_sql-2820"><span class="linenos">2820</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_after</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_after</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.querytransform_sql-2821"><a href="#Generator.querytransform_sql-2821"><span class="linenos">2821</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_reader"</span><span class="p">)</span> -</span><span id="Generator.querytransform_sql-2822"><a href="#Generator.querytransform_sql-2822"><span class="linenos">2822</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDREADER </span><span class="si">{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_reader</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.querytransform_sql-2823"><a href="#Generator.querytransform_sql-2823"><span class="linenos">2823</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">transform</span><span class="si">}{</span><span class="n">row_format_before</span><span class="si">}{</span><span class="n">record_writer</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">row_format_after</span><span class="si">}{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.querytransform_sql-2818"><a href="#Generator.querytransform_sql-2818"><span class="linenos">2818</span></a> <span class="k">def</span> <span class="nf">querytransform_sql</span><span class="p">(</span><span class="bp">self</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">QueryTransform</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.querytransform_sql-2819"><a href="#Generator.querytransform_sql-2819"><span class="linenos">2819</span></a> <span class="n">transform</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"TRANSFORM"</span><span class="p">,</span> <span class="o">*</span><span class="n">expression</span><span class="o">.</span><span class="n">expressions</span><span class="p">)</span> +</span><span id="Generator.querytransform_sql-2820"><a href="#Generator.querytransform_sql-2820"><span class="linenos">2820</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_before"</span><span class="p">)</span> +</span><span id="Generator.querytransform_sql-2821"><a href="#Generator.querytransform_sql-2821"><span class="linenos">2821</span></a> <span class="n">row_format_before</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_before</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_before</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.querytransform_sql-2822"><a href="#Generator.querytransform_sql-2822"><span class="linenos">2822</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_writer"</span><span class="p">)</span> +</span><span id="Generator.querytransform_sql-2823"><a href="#Generator.querytransform_sql-2823"><span class="linenos">2823</span></a> <span class="n">record_writer</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDWRITER </span><span class="si">{</span><span class="n">record_writer</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_writer</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.querytransform_sql-2824"><a href="#Generator.querytransform_sql-2824"><span class="linenos">2824</span></a> <span class="n">using</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'command_script'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.querytransform_sql-2825"><a href="#Generator.querytransform_sql-2825"><span class="linenos">2825</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="Generator.querytransform_sql-2826"><a href="#Generator.querytransform_sql-2826"><span class="linenos">2826</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" AS </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.querytransform_sql-2827"><a href="#Generator.querytransform_sql-2827"><span class="linenos">2827</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"row_format_after"</span><span class="p">)</span> +</span><span id="Generator.querytransform_sql-2828"><a href="#Generator.querytransform_sql-2828"><span class="linenos">2828</span></a> <span class="n">row_format_after</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">row_format_after</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">row_format_after</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.querytransform_sql-2829"><a href="#Generator.querytransform_sql-2829"><span class="linenos">2829</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"record_reader"</span><span class="p">)</span> +</span><span id="Generator.querytransform_sql-2830"><a href="#Generator.querytransform_sql-2830"><span class="linenos">2830</span></a> <span class="n">record_reader</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" RECORDREADER </span><span class="si">{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">record_reader</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.querytransform_sql-2831"><a href="#Generator.querytransform_sql-2831"><span class="linenos">2831</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">transform</span><span class="si">}{</span><span class="n">row_format_before</span><span class="si">}{</span><span class="n">record_writer</span><span class="si">}{</span><span class="n">using</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">row_format_after</span><span class="si">}{</span><span class="n">record_reader</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14642,37 +14685,37 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.indexconstraintoption_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indexconstraintoption_sql-2825"><a href="#Generator.indexconstraintoption_sql-2825"><span class="linenos">2825</span></a> <span class="k">def</span> <span class="nf">indexconstraintoption_sql</span><span class="p">(</span><span class="bp">self</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">IndexConstraintOption</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2826"><a href="#Generator.indexconstraintoption_sql-2826"><span class="linenos">2826</span></a> <span class="n">key_block_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"key_block_size"</span><span class="p">)</span> -</span><span id="Generator.indexconstraintoption_sql-2827"><a href="#Generator.indexconstraintoption_sql-2827"><span class="linenos">2827</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2828"><a href="#Generator.indexconstraintoption_sql-2828"><span class="linenos">2828</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KEY_BLOCK_SIZE = </span><span class="si">{</span><span class="n">key_block_size</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.indexconstraintoption_sql-2829"><a href="#Generator.indexconstraintoption_sql-2829"><span class="linenos">2829</span></a> -</span><span id="Generator.indexconstraintoption_sql-2830"><a href="#Generator.indexconstraintoption_sql-2830"><span class="linenos">2830</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> -</span><span id="Generator.indexconstraintoption_sql-2831"><a href="#Generator.indexconstraintoption_sql-2831"><span class="linenos">2831</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2832"><a href="#Generator.indexconstraintoption_sql-2832"><span class="linenos">2832</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.indexconstraintoption_sql-2833"><a href="#Generator.indexconstraintoption_sql-2833"><span class="linenos">2833</span></a> -</span><span id="Generator.indexconstraintoption_sql-2834"><a href="#Generator.indexconstraintoption_sql-2834"><span class="linenos">2834</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"parser"</span><span class="p">)</span> -</span><span id="Generator.indexconstraintoption_sql-2835"><a href="#Generator.indexconstraintoption_sql-2835"><span class="linenos">2835</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2836"><a href="#Generator.indexconstraintoption_sql-2836"><span class="linenos">2836</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH PARSER </span><span class="si">{</span><span class="n">parser</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indexconstraintoption_sql-2833"><a href="#Generator.indexconstraintoption_sql-2833"><span class="linenos">2833</span></a> <span class="k">def</span> <span class="nf">indexconstraintoption_sql</span><span class="p">(</span><span class="bp">self</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">IndexConstraintOption</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2834"><a href="#Generator.indexconstraintoption_sql-2834"><span class="linenos">2834</span></a> <span class="n">key_block_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"key_block_size"</span><span class="p">)</span> +</span><span id="Generator.indexconstraintoption_sql-2835"><a href="#Generator.indexconstraintoption_sql-2835"><span class="linenos">2835</span></a> <span class="k">if</span> <span class="n">key_block_size</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2836"><a href="#Generator.indexconstraintoption_sql-2836"><span class="linenos">2836</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"KEY_BLOCK_SIZE = </span><span class="si">{</span><span class="n">key_block_size</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator.indexconstraintoption_sql-2837"><a href="#Generator.indexconstraintoption_sql-2837"><span class="linenos">2837</span></a> -</span><span id="Generator.indexconstraintoption_sql-2838"><a href="#Generator.indexconstraintoption_sql-2838"><span class="linenos">2838</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"comment"</span><span class="p">)</span> -</span><span id="Generator.indexconstraintoption_sql-2839"><a href="#Generator.indexconstraintoption_sql-2839"><span class="linenos">2839</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2840"><a href="#Generator.indexconstraintoption_sql-2840"><span class="linenos">2840</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT </span><span class="si">{</span><span class="n">comment</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.indexconstraintoption_sql-2838"><a href="#Generator.indexconstraintoption_sql-2838"><span class="linenos">2838</span></a> <span class="n">using</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"using"</span><span class="p">)</span> +</span><span id="Generator.indexconstraintoption_sql-2839"><a href="#Generator.indexconstraintoption_sql-2839"><span class="linenos">2839</span></a> <span class="k">if</span> <span class="n">using</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2840"><a href="#Generator.indexconstraintoption_sql-2840"><span class="linenos">2840</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"USING </span><span class="si">{</span><span class="n">using</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator.indexconstraintoption_sql-2841"><a href="#Generator.indexconstraintoption_sql-2841"><span class="linenos">2841</span></a> -</span><span id="Generator.indexconstraintoption_sql-2842"><a href="#Generator.indexconstraintoption_sql-2842"><span class="linenos">2842</span></a> <span class="n">visible</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">"visible"</span><span class="p">)</span> -</span><span id="Generator.indexconstraintoption_sql-2843"><a href="#Generator.indexconstraintoption_sql-2843"><span class="linenos">2843</span></a> <span class="k">if</span> <span class="n">visible</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2844"><a href="#Generator.indexconstraintoption_sql-2844"><span class="linenos">2844</span></a> <span class="k">return</span> <span class="s2">"VISIBLE"</span> <span class="k">if</span> <span class="n">visible</span> <span class="k">else</span> <span class="s2">"INVISIBLE"</span> +</span><span id="Generator.indexconstraintoption_sql-2842"><a href="#Generator.indexconstraintoption_sql-2842"><span class="linenos">2842</span></a> <span class="n">parser</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"parser"</span><span class="p">)</span> +</span><span id="Generator.indexconstraintoption_sql-2843"><a href="#Generator.indexconstraintoption_sql-2843"><span class="linenos">2843</span></a> <span class="k">if</span> <span class="n">parser</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2844"><a href="#Generator.indexconstraintoption_sql-2844"><span class="linenos">2844</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"WITH PARSER </span><span class="si">{</span><span class="n">parser</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator.indexconstraintoption_sql-2845"><a href="#Generator.indexconstraintoption_sql-2845"><span class="linenos">2845</span></a> -</span><span id="Generator.indexconstraintoption_sql-2846"><a href="#Generator.indexconstraintoption_sql-2846"><span class="linenos">2846</span></a> <span class="n">engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"engine_attr"</span><span class="p">)</span> -</span><span id="Generator.indexconstraintoption_sql-2847"><a href="#Generator.indexconstraintoption_sql-2847"><span class="linenos">2847</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2848"><a href="#Generator.indexconstraintoption_sql-2848"><span class="linenos">2848</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.indexconstraintoption_sql-2846"><a href="#Generator.indexconstraintoption_sql-2846"><span class="linenos">2846</span></a> <span class="n">comment</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"comment"</span><span class="p">)</span> +</span><span id="Generator.indexconstraintoption_sql-2847"><a href="#Generator.indexconstraintoption_sql-2847"><span class="linenos">2847</span></a> <span class="k">if</span> <span class="n">comment</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2848"><a href="#Generator.indexconstraintoption_sql-2848"><span class="linenos">2848</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"COMMENT </span><span class="si">{</span><span class="n">comment</span><span class="si">}</span><span class="s2">"</span> </span><span id="Generator.indexconstraintoption_sql-2849"><a href="#Generator.indexconstraintoption_sql-2849"><span class="linenos">2849</span></a> -</span><span id="Generator.indexconstraintoption_sql-2850"><a href="#Generator.indexconstraintoption_sql-2850"><span class="linenos">2850</span></a> <span class="n">secondary_engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"secondary_engine_attr"</span><span class="p">)</span> -</span><span id="Generator.indexconstraintoption_sql-2851"><a href="#Generator.indexconstraintoption_sql-2851"><span class="linenos">2851</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> -</span><span id="Generator.indexconstraintoption_sql-2852"><a href="#Generator.indexconstraintoption_sql-2852"><span class="linenos">2852</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SECONDARY_ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">secondary_engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.indexconstraintoption_sql-2850"><a href="#Generator.indexconstraintoption_sql-2850"><span class="linenos">2850</span></a> <span class="n">visible</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">"visible"</span><span class="p">)</span> +</span><span id="Generator.indexconstraintoption_sql-2851"><a href="#Generator.indexconstraintoption_sql-2851"><span class="linenos">2851</span></a> <span class="k">if</span> <span class="n">visible</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2852"><a href="#Generator.indexconstraintoption_sql-2852"><span class="linenos">2852</span></a> <span class="k">return</span> <span class="s2">"VISIBLE"</span> <span class="k">if</span> <span class="n">visible</span> <span class="k">else</span> <span class="s2">"INVISIBLE"</span> </span><span id="Generator.indexconstraintoption_sql-2853"><a href="#Generator.indexconstraintoption_sql-2853"><span class="linenos">2853</span></a> -</span><span id="Generator.indexconstraintoption_sql-2854"><a href="#Generator.indexconstraintoption_sql-2854"><span class="linenos">2854</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported index constraint option."</span><span class="p">)</span> -</span><span id="Generator.indexconstraintoption_sql-2855"><a href="#Generator.indexconstraintoption_sql-2855"><span class="linenos">2855</span></a> <span class="k">return</span> <span class="s2">""</span> +</span><span id="Generator.indexconstraintoption_sql-2854"><a href="#Generator.indexconstraintoption_sql-2854"><span class="linenos">2854</span></a> <span class="n">engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"engine_attr"</span><span class="p">)</span> +</span><span id="Generator.indexconstraintoption_sql-2855"><a href="#Generator.indexconstraintoption_sql-2855"><span class="linenos">2855</span></a> <span class="k">if</span> <span class="n">engine_attr</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2856"><a href="#Generator.indexconstraintoption_sql-2856"><span class="linenos">2856</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.indexconstraintoption_sql-2857"><a href="#Generator.indexconstraintoption_sql-2857"><span class="linenos">2857</span></a> +</span><span id="Generator.indexconstraintoption_sql-2858"><a href="#Generator.indexconstraintoption_sql-2858"><span class="linenos">2858</span></a> <span class="n">secondary_engine_attr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"secondary_engine_attr"</span><span class="p">)</span> +</span><span id="Generator.indexconstraintoption_sql-2859"><a href="#Generator.indexconstraintoption_sql-2859"><span class="linenos">2859</span></a> <span class="k">if</span> <span class="n">secondary_engine_attr</span><span class="p">:</span> +</span><span id="Generator.indexconstraintoption_sql-2860"><a href="#Generator.indexconstraintoption_sql-2860"><span class="linenos">2860</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"SECONDARY_ENGINE_ATTRIBUTE = </span><span class="si">{</span><span class="n">secondary_engine_attr</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.indexconstraintoption_sql-2861"><a href="#Generator.indexconstraintoption_sql-2861"><span class="linenos">2861</span></a> +</span><span id="Generator.indexconstraintoption_sql-2862"><a href="#Generator.indexconstraintoption_sql-2862"><span class="linenos">2862</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">unsupported</span><span class="p">(</span><span class="s2">"Unsupported index constraint option."</span><span class="p">)</span> +</span><span id="Generator.indexconstraintoption_sql-2863"><a href="#Generator.indexconstraintoption_sql-2863"><span class="linenos">2863</span></a> <span class="k">return</span> <span class="s2">""</span> </span></pre></div> @@ -14690,18 +14733,18 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.indexcolumnconstraint_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indexcolumnconstraint_sql-2857"><a href="#Generator.indexcolumnconstraint_sql-2857"><span class="linenos">2857</span></a> <span class="k">def</span> <span class="nf">indexcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</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">IndexColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.indexcolumnconstraint_sql-2858"><a href="#Generator.indexcolumnconstraint_sql-2858"><span class="linenos">2858</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> -</span><span id="Generator.indexcolumnconstraint_sql-2859"><a href="#Generator.indexcolumnconstraint_sql-2859"><span class="linenos">2859</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> INDEX"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">"INDEX"</span> -</span><span id="Generator.indexcolumnconstraint_sql-2860"><a href="#Generator.indexcolumnconstraint_sql-2860"><span class="linenos">2860</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.indexcolumnconstraint_sql-2861"><a href="#Generator.indexcolumnconstraint_sql-2861"><span class="linenos">2861</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.indexcolumnconstraint_sql-2862"><a href="#Generator.indexcolumnconstraint_sql-2862"><span class="linenos">2862</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"index_type"</span><span class="p">)</span> -</span><span id="Generator.indexcolumnconstraint_sql-2863"><a href="#Generator.indexcolumnconstraint_sql-2863"><span class="linenos">2863</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">index_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index_type</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.indexcolumnconstraint_sql-2864"><a href="#Generator.indexcolumnconstraint_sql-2864"><span class="linenos">2864</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> -</span><span id="Generator.indexcolumnconstraint_sql-2865"><a href="#Generator.indexcolumnconstraint_sql-2865"><span class="linenos">2865</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.indexcolumnconstraint_sql-2866"><a href="#Generator.indexcolumnconstraint_sql-2866"><span class="linenos">2866</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> -</span><span id="Generator.indexcolumnconstraint_sql-2867"><a href="#Generator.indexcolumnconstraint_sql-2867"><span class="linenos">2867</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.indexcolumnconstraint_sql-2868"><a href="#Generator.indexcolumnconstraint_sql-2868"><span class="linenos">2868</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">index_type</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.indexcolumnconstraint_sql-2865"><a href="#Generator.indexcolumnconstraint_sql-2865"><span class="linenos">2865</span></a> <span class="k">def</span> <span class="nf">indexcolumnconstraint_sql</span><span class="p">(</span><span class="bp">self</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">IndexColumnConstraint</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.indexcolumnconstraint_sql-2866"><a href="#Generator.indexcolumnconstraint_sql-2866"><span class="linenos">2866</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"kind"</span><span class="p">)</span> +</span><span id="Generator.indexcolumnconstraint_sql-2867"><a href="#Generator.indexcolumnconstraint_sql-2867"><span class="linenos">2867</span></a> <span class="n">kind</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}</span><span class="s2"> INDEX"</span> <span class="k">if</span> <span class="n">kind</span> <span class="k">else</span> <span class="s2">"INDEX"</span> +</span><span id="Generator.indexcolumnconstraint_sql-2868"><a href="#Generator.indexcolumnconstraint_sql-2868"><span class="linenos">2868</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.indexcolumnconstraint_sql-2869"><a href="#Generator.indexcolumnconstraint_sql-2869"><span class="linenos">2869</span></a> <span class="n">this</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">this</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.indexcolumnconstraint_sql-2870"><a href="#Generator.indexcolumnconstraint_sql-2870"><span class="linenos">2870</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"index_type"</span><span class="p">)</span> +</span><span id="Generator.indexcolumnconstraint_sql-2871"><a href="#Generator.indexcolumnconstraint_sql-2871"><span class="linenos">2871</span></a> <span class="n">index_type</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" USING </span><span class="si">{</span><span class="n">index_type</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">index_type</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.indexcolumnconstraint_sql-2872"><a href="#Generator.indexcolumnconstraint_sql-2872"><span class="linenos">2872</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"schema"</span><span class="p">)</span> +</span><span id="Generator.indexcolumnconstraint_sql-2873"><a href="#Generator.indexcolumnconstraint_sql-2873"><span class="linenos">2873</span></a> <span class="n">schema</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">schema</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">schema</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.indexcolumnconstraint_sql-2874"><a href="#Generator.indexcolumnconstraint_sql-2874"><span class="linenos">2874</span></a> <span class="n">options</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">expressions</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="s2">"options"</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s2">" "</span><span class="p">)</span> +</span><span id="Generator.indexcolumnconstraint_sql-2875"><a href="#Generator.indexcolumnconstraint_sql-2875"><span class="linenos">2875</span></a> <span class="n">options</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" </span><span class="si">{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">options</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.indexcolumnconstraint_sql-2876"><a href="#Generator.indexcolumnconstraint_sql-2876"><span class="linenos">2876</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">kind</span><span class="si">}{</span><span class="n">this</span><span class="si">}{</span><span class="n">index_type</span><span class="si">}{</span><span class="n">schema</span><span class="si">}{</span><span class="n">options</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14719,20 +14762,20 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.nvl2_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nvl2_sql-2870"><a href="#Generator.nvl2_sql-2870"><span class="linenos">2870</span></a> <span class="k">def</span> <span class="nf">nvl2_sql</span><span class="p">(</span><span class="bp">self</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">Nvl2</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.nvl2_sql-2871"><a href="#Generator.nvl2_sql-2871"><span class="linenos">2871</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">NVL2_SUPPORTED</span><span class="p">:</span> -</span><span id="Generator.nvl2_sql-2872"><a href="#Generator.nvl2_sql-2872"><span class="linenos">2872</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> -</span><span id="Generator.nvl2_sql-2873"><a href="#Generator.nvl2_sql-2873"><span class="linenos">2873</span></a> -</span><span id="Generator.nvl2_sql-2874"><a href="#Generator.nvl2_sql-2874"><span class="linenos">2874</span></a> <span class="n">case</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span> -</span><span id="Generator.nvl2_sql-2875"><a href="#Generator.nvl2_sql-2875"><span class="linenos">2875</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">())</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> -</span><span id="Generator.nvl2_sql-2876"><a href="#Generator.nvl2_sql-2876"><span class="linenos">2876</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"true"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> -</span><span id="Generator.nvl2_sql-2877"><a href="#Generator.nvl2_sql-2877"><span class="linenos">2877</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> -</span><span id="Generator.nvl2_sql-2878"><a href="#Generator.nvl2_sql-2878"><span class="linenos">2878</span></a> <span class="p">)</span> -</span><span id="Generator.nvl2_sql-2879"><a href="#Generator.nvl2_sql-2879"><span class="linenos">2879</span></a> <span class="n">else_cond</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">"false"</span><span class="p">)</span> -</span><span id="Generator.nvl2_sql-2880"><a href="#Generator.nvl2_sql-2880"><span class="linenos">2880</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> -</span><span id="Generator.nvl2_sql-2881"><a href="#Generator.nvl2_sql-2881"><span class="linenos">2881</span></a> <span class="k">case</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">else_cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> -</span><span id="Generator.nvl2_sql-2882"><a href="#Generator.nvl2_sql-2882"><span class="linenos">2882</span></a> -</span><span id="Generator.nvl2_sql-2883"><a href="#Generator.nvl2_sql-2883"><span class="linenos">2883</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.nvl2_sql-2878"><a href="#Generator.nvl2_sql-2878"><span class="linenos">2878</span></a> <span class="k">def</span> <span class="nf">nvl2_sql</span><span class="p">(</span><span class="bp">self</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">Nvl2</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.nvl2_sql-2879"><a href="#Generator.nvl2_sql-2879"><span class="linenos">2879</span></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">NVL2_SUPPORTED</span><span class="p">:</span> +</span><span id="Generator.nvl2_sql-2880"><a href="#Generator.nvl2_sql-2880"><span class="linenos">2880</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">function_fallback_sql</span><span class="p">(</span><span class="n">expression</span><span class="p">)</span> +</span><span id="Generator.nvl2_sql-2881"><a href="#Generator.nvl2_sql-2881"><span class="linenos">2881</span></a> +</span><span id="Generator.nvl2_sql-2882"><a href="#Generator.nvl2_sql-2882"><span class="linenos">2882</span></a> <span class="n">case</span> <span class="o">=</span> <span class="n">exp</span><span class="o">.</span><span class="n">Case</span><span class="p">()</span><span class="o">.</span><span class="n">when</span><span class="p">(</span> +</span><span id="Generator.nvl2_sql-2883"><a href="#Generator.nvl2_sql-2883"><span class="linenos">2883</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">this</span><span class="o">.</span><span class="n">is_</span><span class="p">(</span><span class="n">exp</span><span class="o">.</span><span class="n">null</span><span class="p">())</span><span class="o">.</span><span class="n">not_</span><span class="p">(</span><span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">),</span> +</span><span id="Generator.nvl2_sql-2884"><a href="#Generator.nvl2_sql-2884"><span class="linenos">2884</span></a> <span class="n">expression</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s2">"true"</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> +</span><span id="Generator.nvl2_sql-2885"><a href="#Generator.nvl2_sql-2885"><span class="linenos">2885</span></a> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> +</span><span id="Generator.nvl2_sql-2886"><a href="#Generator.nvl2_sql-2886"><span class="linenos">2886</span></a> <span class="p">)</span> +</span><span id="Generator.nvl2_sql-2887"><a href="#Generator.nvl2_sql-2887"><span class="linenos">2887</span></a> <span class="n">else_cond</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">"false"</span><span class="p">)</span> +</span><span id="Generator.nvl2_sql-2888"><a href="#Generator.nvl2_sql-2888"><span class="linenos">2888</span></a> <span class="k">if</span> <span class="n">else_cond</span><span class="p">:</span> +</span><span id="Generator.nvl2_sql-2889"><a href="#Generator.nvl2_sql-2889"><span class="linenos">2889</span></a> <span class="k">case</span><span class="o">.</span><span class="n">else_</span><span class="p">(</span><span class="n">else_cond</span><span class="o">.</span><span class="n">copy</span><span class="p">(),</span> <span class="n">copy</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span> +</span><span id="Generator.nvl2_sql-2890"><a href="#Generator.nvl2_sql-2890"><span class="linenos">2890</span></a> +</span><span id="Generator.nvl2_sql-2891"><a href="#Generator.nvl2_sql-2891"><span class="linenos">2891</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">case</span><span class="p">)</span> </span></pre></div> @@ -14750,13 +14793,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.comprehension_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.comprehension_sql-2885"><a href="#Generator.comprehension_sql-2885"><span class="linenos">2885</span></a> <span class="k">def</span> <span class="nf">comprehension_sql</span><span class="p">(</span><span class="bp">self</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">Comprehension</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.comprehension_sql-2886"><a href="#Generator.comprehension_sql-2886"><span class="linenos">2886</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.comprehension_sql-2887"><a href="#Generator.comprehension_sql-2887"><span class="linenos">2887</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.comprehension_sql-2888"><a href="#Generator.comprehension_sql-2888"><span class="linenos">2888</span></a> <span class="n">iterator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"iterator"</span><span class="p">)</span> -</span><span id="Generator.comprehension_sql-2889"><a href="#Generator.comprehension_sql-2889"><span class="linenos">2889</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> -</span><span id="Generator.comprehension_sql-2890"><a href="#Generator.comprehension_sql-2890"><span class="linenos">2890</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" IF </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> -</span><span id="Generator.comprehension_sql-2891"><a href="#Generator.comprehension_sql-2891"><span class="linenos">2891</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">iterator</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.comprehension_sql-2893"><a href="#Generator.comprehension_sql-2893"><span class="linenos">2893</span></a> <span class="k">def</span> <span class="nf">comprehension_sql</span><span class="p">(</span><span class="bp">self</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">Comprehension</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.comprehension_sql-2894"><a href="#Generator.comprehension_sql-2894"><span class="linenos">2894</span></a> <span class="n">this</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.comprehension_sql-2895"><a href="#Generator.comprehension_sql-2895"><span class="linenos">2895</span></a> <span class="n">expr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.comprehension_sql-2896"><a href="#Generator.comprehension_sql-2896"><span class="linenos">2896</span></a> <span class="n">iterator</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"iterator"</span><span class="p">)</span> +</span><span id="Generator.comprehension_sql-2897"><a href="#Generator.comprehension_sql-2897"><span class="linenos">2897</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"condition"</span><span class="p">)</span> +</span><span id="Generator.comprehension_sql-2898"><a href="#Generator.comprehension_sql-2898"><span class="linenos">2898</span></a> <span class="n">condition</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">" IF </span><span class="si">{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="n">condition</span> <span class="k">else</span> <span class="s2">""</span> +</span><span id="Generator.comprehension_sql-2899"><a href="#Generator.comprehension_sql-2899"><span class="linenos">2899</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">this</span><span class="si">}</span><span class="s2"> FOR </span><span class="si">{</span><span class="n">expr</span><span class="si">}</span><span class="s2"> IN </span><span class="si">{</span><span class="n">iterator</span><span class="si">}{</span><span class="n">condition</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14774,8 +14817,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.columnprefix_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnprefix_sql-2893"><a href="#Generator.columnprefix_sql-2893"><span class="linenos">2893</span></a> <span class="k">def</span> <span class="nf">columnprefix_sql</span><span class="p">(</span><span class="bp">self</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">ColumnPrefix</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.columnprefix_sql-2894"><a href="#Generator.columnprefix_sql-2894"><span class="linenos">2894</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.columnprefix_sql-2901"><a href="#Generator.columnprefix_sql-2901"><span class="linenos">2901</span></a> <span class="k">def</span> <span class="nf">columnprefix_sql</span><span class="p">(</span><span class="bp">self</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">ColumnPrefix</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.columnprefix_sql-2902"><a href="#Generator.columnprefix_sql-2902"><span class="linenos">2902</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2">(</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">)"</span> </span></pre></div> @@ -14793,8 +14836,8 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.opclass_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.opclass_sql-2896"><a href="#Generator.opclass_sql-2896"><span class="linenos">2896</span></a> <span class="k">def</span> <span class="nf">opclass_sql</span><span class="p">(</span><span class="bp">self</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">Opclass</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.opclass_sql-2897"><a href="#Generator.opclass_sql-2897"><span class="linenos">2897</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.opclass_sql-2904"><a href="#Generator.opclass_sql-2904"><span class="linenos">2904</span></a> <span class="k">def</span> <span class="nf">opclass_sql</span><span class="p">(</span><span class="bp">self</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">Opclass</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.opclass_sql-2905"><a href="#Generator.opclass_sql-2905"><span class="linenos">2905</span></a> <span class="k">return</span> <span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'this'</span><span class="p">)</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span><span class="w"> </span><span class="s1">'expression'</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span> </span></pre></div> @@ -14812,13 +14855,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#Generator.predict_sql"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.predict_sql-2899"><a href="#Generator.predict_sql-2899"><span class="linenos">2899</span></a> <span class="k">def</span> <span class="nf">predict_sql</span><span class="p">(</span><span class="bp">self</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">Predict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> -</span><span id="Generator.predict_sql-2900"><a href="#Generator.predict_sql-2900"><span class="linenos">2900</span></a> <span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> -</span><span id="Generator.predict_sql-2901"><a href="#Generator.predict_sql-2901"><span class="linenos">2901</span></a> <span class="n">model</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"MODEL </span><span class="si">{</span><span class="n">model</span><span class="si">}</span><span class="s2">"</span> -</span><span id="Generator.predict_sql-2902"><a href="#Generator.predict_sql-2902"><span class="linenos">2902</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> -</span><span id="Generator.predict_sql-2903"><a href="#Generator.predict_sql-2903"><span class="linenos">2903</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Subquery</span><span class="p">)</span> <span class="k">else</span> <span class="n">table</span> -</span><span id="Generator.predict_sql-2904"><a href="#Generator.predict_sql-2904"><span class="linenos">2904</span></a> <span class="n">parameters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"params_struct"</span><span class="p">)</span> -</span><span id="Generator.predict_sql-2905"><a href="#Generator.predict_sql-2905"><span class="linenos">2905</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"PREDICT"</span><span class="p">,</span> <span class="n">model</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">parameters</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="Generator.predict_sql-2907"><a href="#Generator.predict_sql-2907"><span class="linenos">2907</span></a> <span class="k">def</span> <span class="nf">predict_sql</span><span class="p">(</span><span class="bp">self</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">Predict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span> +</span><span id="Generator.predict_sql-2908"><a href="#Generator.predict_sql-2908"><span class="linenos">2908</span></a> <span class="n">model</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"this"</span><span class="p">)</span> +</span><span id="Generator.predict_sql-2909"><a href="#Generator.predict_sql-2909"><span class="linenos">2909</span></a> <span class="n">model</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"MODEL </span><span class="si">{</span><span class="n">model</span><span class="si">}</span><span class="s2">"</span> +</span><span id="Generator.predict_sql-2910"><a href="#Generator.predict_sql-2910"><span class="linenos">2910</span></a> <span class="n">table</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"expression"</span><span class="p">)</span> +</span><span id="Generator.predict_sql-2911"><a href="#Generator.predict_sql-2911"><span class="linenos">2911</span></a> <span class="n">table</span> <span class="o">=</span> <span class="sa">f</span><span class="s2">"TABLE </span><span class="si">{</span><span class="n">table</span><span class="si">}</span><span class="s2">"</span> <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">expression</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">Subquery</span><span class="p">)</span> <span class="k">else</span> <span class="n">table</span> +</span><span id="Generator.predict_sql-2912"><a href="#Generator.predict_sql-2912"><span class="linenos">2912</span></a> <span class="n">parameters</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sql</span><span class="p">(</span><span class="n">expression</span><span class="p">,</span> <span class="s2">"params_struct"</span><span class="p">)</span> +</span><span id="Generator.predict_sql-2913"><a href="#Generator.predict_sql-2913"><span class="linenos">2913</span></a> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">(</span><span class="s2">"PREDICT"</span><span class="p">,</span> <span class="n">model</span><span class="p">,</span> <span class="n">table</span><span class="p">,</span> <span class="n">parameters</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span> </span></pre></div> @@ -14837,13 +14880,13 @@ which can be slow to compute, so only use it if you set _hash on each node.</li> </div> <a class="headerlink" href="#cached_generator"></a> - <div class="pdoc-code codehilite"><pre><span></span><span id="cached_generator-2908"><a href="#cached_generator-2908"><span class="linenos">2908</span></a><span class="k">def</span> <span class="nf">cached_generator</span><span class="p">(</span> -</span><span id="cached_generator-2909"><a href="#cached_generator-2909"><span class="linenos">2909</span></a> <span class="n">cache</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="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> -</span><span id="cached_generator-2910"><a href="#cached_generator-2910"><span class="linenos">2910</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</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="nb">str</span><span class="p">]:</span> -</span><span id="cached_generator-2911"><a href="#cached_generator-2911"><span class="linenos">2911</span></a><span class="w"> </span><span class="sd">"""Returns a cached generator."""</span> -</span><span id="cached_generator-2912"><a href="#cached_generator-2912"><span class="linenos">2912</span></a> <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">cache</span> -</span><span id="cached_generator-2913"><a href="#cached_generator-2913"><span class="linenos">2913</span></a> <span class="n">generator</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="s2">"safe"</span><span class="p">)</span> -</span><span id="cached_generator-2914"><a href="#cached_generator-2914"><span class="linenos">2914</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> + <div class="pdoc-code codehilite"><pre><span></span><span id="cached_generator-2916"><a href="#cached_generator-2916"><span class="linenos">2916</span></a><span class="k">def</span> <span class="nf">cached_generator</span><span class="p">(</span> +</span><span id="cached_generator-2917"><a href="#cached_generator-2917"><span class="linenos">2917</span></a> <span class="n">cache</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="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span> +</span><span id="cached_generator-2918"><a href="#cached_generator-2918"><span class="linenos">2918</span></a><span class="p">)</span> <span class="o">-></span> <span class="n">t</span><span class="o">.</span><span class="n">Callable</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="nb">str</span><span class="p">]:</span> +</span><span id="cached_generator-2919"><a href="#cached_generator-2919"><span class="linenos">2919</span></a><span class="w"> </span><span class="sd">"""Returns a cached generator."""</span> +</span><span id="cached_generator-2920"><a href="#cached_generator-2920"><span class="linenos">2920</span></a> <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span> <span class="k">if</span> <span class="n">cache</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">cache</span> +</span><span id="cached_generator-2921"><a href="#cached_generator-2921"><span class="linenos">2921</span></a> <span class="n">generator</span> <span class="o">=</span> <span class="n">Generator</span><span class="p">(</span><span class="n">normalize</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">identify</span><span class="o">=</span><span class="s2">"safe"</span><span class="p">)</span> +</span><span id="cached_generator-2922"><a href="#cached_generator-2922"><span class="linenos">2922</span></a> <span class="k">return</span> <span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="n">generator</span><span class="o">.</span><span class="n">generate</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="n">cache</span><span class="p">)</span> </span></pre></div> |